Saturday, 29 July 2023

Variables between scripts

 If we want to access one variable (int data) from an external script, we must do:

1-ORIGINAL ONE.cs


   public static int data=0

2- SECOND TWO.cs

 

ONE.dinero = 1;

As u can see, the only secret its to declare "public static" your variable.

Of course, your 2 scripts must be on the same scene assigned to a GameObject.



Access external scripts

 

External scripts

WE HAVE A GENERAL SCRIPT (CONTAINS OUR FUNCTIONS)

1- OL1AScript.cs

WE HAVE OUR MAIN SCRIPT (2):

2- main.cs 

....

WE WANT TO ACCESS to (1) FROM OUR SCRIPT (2):



BOTH SCRIPTS MUST BE ASSIGNED TO A "GAMEOBJECT"  (create it on Unity, "Create Empty")

- Now, in "main.cs" (1) inside "public void Start"...
          OL1AScript ol1script = GetComponent<OL1AScript >();

          ol1script = GetComponent<OL1AScript >();

Saturday, 1 July 2023

Hola Mundo Unity

 Como hacer un primer programa muy sencillo tipo "Hola Mundo" en Unity:

Hola Mundo

Gracias a ACKOSMIC.com


 

Tuesday, 11 April 2023

Basic components for an object, physics

 Lets see how to make an animated object on our game.

We need an IMAGE that we will drag and drop to our EDITOR...

Backgrounds: how to add it

 Do you know how  to add a background to your game/app in Unity?


Lets look how...


Thursday, 30 March 2023

Unity SpriteRenderer "error"

 how to solve this error...

error CS1061: 'SpriteRenderer' does not contain a definition for 'IsUsingDeformableBuffer'

TO SOLVE THIS ERROR, GO TO "WINDOW-PACKAGEMANAGER" AND RESET PACKAGES:


 
 

"got to PackageManager, type 2D remove all, and install it again!"

thanks to https://stackoverflow.com/questions/71168878/unity-spriterenderer-error-what-i-need-to-do


Wednesday, 29 March 2023

Intellisense

Intellisense (auto code)

We go to:

EDIT-PREFERENCES-EXTERNAL TOOLS

Select «Visual Studio».

IN «Generate csproj files», check everything

 


Tuesday, 28 March 2023

HUGE COMPONENTS SIZE

Componentes «gigantes»

PROBLEM: big size components on our editor. 

SOLVE:

add your  «Camera» inside your «Canvas»:

1- in «Canvas», «Render Mode» select «Screen Space-Camera»


2- drag and drop «Main Camera» to «Render Camera»  Canvas ( inspector)

Variables between scripts

 If we want to access one variable (int data) from an external script, we must do: 1-ORIGINAL ONE.cs     public static int data = 0 ;  2-...