Skip to main content
Tweeted twitter.com/StackGameDev/status/1294378266598539265
grammar, clarity
Source Link
Pikalek
  • 12.5k
  • 5
  • 45
  • 52

I'm using a "toggle visibility" script on many objects in my scene, and in my gameControllergameController class I'm storing references to them in an array like this:

public Fields[] fields;

then I access them by the array index:

fields[0].setVisibility(true);

This works fine, but this list is growing and everything is getting unmaintainable.

So I would like to iterate thru the references to the objects, find the script by it'sits game object name, and call the required function setVisibility(state).

A call, if possible should look like this:

GameObjectName.ScriptName.FunctionCall.State

In this way, I would have a clear overview of my code.

Is this possible in Unity C#?

Thanks!

I'm using a "toggle visibility" script on many objects in my scene, and in my gameController class I'm storing references to them in an array like this:

public Fields[] fields;

then I access them by the array index:

fields[0].setVisibility(true);

This works fine, but this list is growing and everything is getting unmaintainable.

So I would like to iterate thru the references to the objects, find the script by it's game object name, and call the required function setVisibility(state).

A call, if possible should look like this:

GameObjectName.ScriptName.FunctionCall.State

In this way, I would have a clear overview of my code.

Is this possible in Unity C#?

Thanks!

I'm using a "toggle visibility" script on many objects in my scene, and in my gameController class I'm storing references to them in an array like this:

public Fields[] fields;

then I access them by the array index:

fields[0].setVisibility(true);

This works fine, but this list is growing and everything is getting unmaintainable.

So I would like to iterate thru the references to the objects, find the script by its game object name, and call the required function setVisibility(state).

A call, if possible should look like this:

GameObjectName.ScriptName.FunctionCall.State

In this way, I would have a clear overview of my code.

Is this possible in Unity C#?

I'm using a "toggle visibility" script on many objects in my scene, and in my gameController class I'm storing a referencereferences to them in an array like this:

public Fields[] fields;

then I access them by the array index:

fields[0].setVisibility(true);

This works fine, but this list is growing and everything is getting unreadableunmaintainable.

So I would like to iterate thru the Empty who is holdingreferences to the objects, find the script by hisit's game object name, and setcall the required function setVisibility.(state)setVisibility(state).

A call, if possible should look like this:

GameObjectName.ScriptName.FunctionCall.State

In this way, I would have a clear overview of my code.

Is this possible in Unity C#?

Thanks!

I'm using a "toggle visibility" script on many objects in my scene, and in my gameController class I'm storing a reference in an array like this:

public Fields[] fields;

then I access them by the array index:

fields[0].setVisibility(true);

This works fine, but this list is growing and everything is getting unreadable.

So I would like to iterate thru the Empty who is holding the objects, find the script by his game object name, and set the required function setVisibility.(state).

A call, if possible should look like this:

GameObjectName.ScriptName.FunctionCall.State

In this way, I would have a clear overview of my code.

Is this possible in Unity C#?

Thanks!

I'm using a "toggle visibility" script on many objects in my scene, and in my gameController class I'm storing references to them in an array like this:

public Fields[] fields;

then I access them by the array index:

fields[0].setVisibility(true);

This works fine, but this list is growing and everything is getting unmaintainable.

So I would like to iterate thru the references to the objects, find the script by it's game object name, and call the required function setVisibility(state).

A call, if possible should look like this:

GameObjectName.ScriptName.FunctionCall.State

In this way, I would have a clear overview of my code.

Is this possible in Unity C#?

Thanks!

added 207 characters in body
Source Link
karl
  • 33
  • 4

I'm using the samea "toggle visibility" script on many objects in my scene, and in my gameController class I'm storing a reference in an array like this:

public Fields[] fields;

and then I access them by the array index:

fields[0].setFunctionsetVisibility(true);

This works fine, but this list is growing and everything is getting unreadable.

So I would like to iterate thru the Empty who is holding the objects, find the script by his game object name, and set the required function setVisibility.(state).

A call, if possible should look like this:

GameObjectName.ScriptName.FunctionCall.State

In this way, I would have a clear overview of my code.

Is this possible in Unity C#? Thanks

Thanks!

I'm using the same script on many objects, and in my gameController class I'm storing a reference in an array like this:

public Fields[] fields;

and then I access them by the array index:

fields[0].setFunction();

This works fine, but this list is growing and everything is getting unreadable.

So I would like to iterate thru the Empty who is holding the objects, find the script by his game object name, and set the required function.

Is this possible in Unity C#? Thanks!

I'm using a "toggle visibility" script on many objects in my scene, and in my gameController class I'm storing a reference in an array like this:

public Fields[] fields;

then I access them by the array index:

fields[0].setVisibility(true);

This works fine, but this list is growing and everything is getting unreadable.

So I would like to iterate thru the Empty who is holding the objects, find the script by his game object name, and set the required function setVisibility.(state).

A call, if possible should look like this:

GameObjectName.ScriptName.FunctionCall.State

In this way, I would have a clear overview of my code.

Is this possible in Unity C#?

Thanks!

Source Link
karl
  • 33
  • 4
Loading