Plz someone with big brain help

can somebody explain what a State is and what this code here does

[CreateAssetMenu(menuName = "Staaaaate")]

public class State : ScriptableObject
{
    [TextArea(10, 14)] [SerializeField] string stor5ytext;
    [SerializeField] State state;
    public string GetStoryText()
    {
        return stor5ytext;

    }

}

is it a scriptable object or does it have to be attached to one
how does naming the “staaaaate” work after i create it in unity
what’s the difference between State and “staaaaaaate”
why is does the information i put into stor5ytext not stay?
did i do it wrong XD i rewatch the episode where he did it and basically copy pasted it and it works now but it doesn’t make sense to me
unfortunately i must sleep so i can work but ill get back to you tomorrow is u reply

Hi,

State is nothing but a class. You could rename it if you want, maybe to “StoryPart”.

Since it inherits from ScriptableObject, we get some special functionality in Unity. The objects we create from this class are “scriptable objects”.

And the purpose of the State objects is to hold information, here: a text/string, which we are going to display in our game.

“Staaaaate” is the name of the menu item which gets created in Unity via the CreateAssetMenu attribute.

Did this help?


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms