A
A
Alexander Simonov2017-10-25 10:20:53
Unity
Alexander Simonov, 2017-10-25 10:20:53

How can I do the same editing of my class in the inspector?

Good afternoon!
If you create a public Vector3 field in unity, then you can create it directly in the inspector, that is, you do not need to write new Vector3 (x, y, z) in the code. In the inspector, you just need to pass what the constructor accepts.
How to make a similar Vector3 class so that you can configure it in the same way through the inspector?
For example I have:
class A {
public float a;
public float b;
public A(float a, float b) {
this.a = a;
this.b = b;
}
}
And in some component I declare
public A objA;
And so that when I hang this component, I can set up the a and b fields of the class in the inspector.
I hope I explained it clearly, just to formulate a question for Google, I didn’t have enough experience in customization and in the unit in particular, all I found was how to remake the component editor.
Thank you all in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Gaydak, 2017-10-25
@SimasikS

With simple data types that the editor already knows how to serialize.. (like float in your example)
it will be enough to declare your class serializable

[System.Serializable]
class A {
public float a;
.......
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question