Okay, I think I've figured this out! Correct me if I'm wrong! :)

Thanks to the comments here and on Udemy, I think…MAYBE… I’ve finally wrapped by brain around the Public Methods and Return Types lecture.

I also went back and listened to the entire course from the very first video, and took 13 pages of notes. :laughing:

I’ve ATTEMPTED to visualise my understanding. It’s a lot of screenshots, but it’s a complicated video to get through. I’ve written my understanding of things on the screenshots. If I’m wrong, PLEASE let me know! :blush:

02

03

11

13

Currently, I still don’t understand how we’ll change things so the CURRENT state will display different text to the STARTING state, but I presume this will be covered in the next videos.

3 Likes

Hi Belinda,

Nice set of notes there, a couple of remarks as requested in your other topic;


Note 8

One minor thing I would add;

image

The attribute [SerializeField] doesn’t make a field in the Inspector, it exposes your private field from the class. Your line;

[SerializeField] Text textComponent;

could also be written as;

[SerializeField] private Text textComponent;

private being the access modifier for the member variable (field) in question. C# defaults to private which is why you can get away with not specifying it.

Note 11

Again, a minor thing, as opposed to “taking care of”, it is actually inheriting from ScriptableObject.

A child class (State) can reuse (inherit), extend or modify the behaviour of a parent class (ScriptableObject). anything which is public (or protected / internal) in the parent class will be available within the derived class.

Hierarchy would look like this;

See also;

Note 20 (the first one :wink: )

“The textarea code”, we’d refer to that as an attribute.

Note 20 (the second one)

“Story Text”, in case you hadn’t realised, Unity has a built-in prettify feature which will take variable names and make them more readable, so, storyText became “Story Text” in the Inspector, Unity upper-cased the first letter, and placed a space before the next capital letter.

Note 22

Yes, you could think of a method as a behaviour, something that class can do.

Note 24

It’s not so much the type of the method, but the return type of the method, this indicates that what the method returns, in this case, will be of type string. An error would occur if you tried to return a value of a different type, unless you cast it to a string (if possible) first.

Note 36

You are declaring a variable of type State, the variable is named state.


Only minor points above, offered for the sake of clarity. All in all a very good write up demonstrating your understanding, well done :slight_smile:

1 Like

Thanks so much mate, I appreciate the clarifications! :blush: :blush:

Two twenties, for goodness! I thought I checked for double-ups, dangit! :):laughing:

:smiley: :smiley:

Privacy & Terms