S
S
Suren2018-04-30 17:50:28
C++ / C#
Suren, 2018-04-30 17:50:28

Interaction with script parameters on object by ID?

The next problem, or rather not even a problem, but a gap in knowledge, or maybe in logical thinking)
I have a definition. number of objects, their number does not matter, all objects have one script attached.
The script is simple, there are just different fields for parameters, one of the parameters I specified ID.
There is also a script that collects these objects into an Array and assigns IDs.
And there will be a class that receives an ID and, based on it, throws all the parameters of this object onto the UI.
So, the question is, how can I take information about the parameters of the particular object that was clicked on? It is logical that by ID, but I can’t figure out how to do this, please tell me)

public class MainParam : MonoBehaviour
{
    public string Name;
    public int idCube;
    public int power;
    public int defanse;
    public Abillity abillity;
    
}

public enum Abillity
{
    Stun,
    Attack,
    MagickAttack
}

class Visual : MonoBehaviour
{
    public MainParam[] mainParam;

    public void Awake()
    {
        mainParam = GameObject.FindObjectsOfType<MainParam>();
        Chek();
    }

    public void Chek()
    {
        for(int i = 0; i < mainParam.Length; i++)
        {
            mainParam[i].idCube = i;
        }
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question