if syntax for blank variable.

Hi all,

I need to know the syntax for testing if a transform, gameobject, and camera variables have anything in them.

eg.

if (var has contence)
{
   do stuff
}

Any help would be appreciated.

Test whether it's null or not:

if (someVar != null) {stuff}
// or
if (someVar) {stuff}

better to use print() and console or logs, so you will get more info:

var x = ...//gameobject, transform, etc print(x.anyproperty);

like

print(x.name); //for gameObject print(x.position); //for Transform etc

if its empty it will return Null or wrong reference object.

You just need to know properties of different objects.

Hi… maybe you are looking for something like this…

Using variable texture as a public variable, but not asigned in the inspector
`
public Texture2D textura;

if (GUI.Button (new Rect (100,100,100,100), texture))
{

			try
			{
				Debug.Log(texture.name);
			}
			catch
			{
				Debug.Log("There is no texture");
			}
			
		}`

This code get the unassigned error, but I don’t know if is the best way to implement a try catch code because use if (texture==null) do not work and shows the same error. Hope someone have a better answer for this.