unt Flashcards

1
Q

A raycast is

A

a laser beam with a length, it can create collisions. Often used to detect which game object a user clicked on.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

To get a position of a mouse in world space, type

A

Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A scriptable object is a

A

script you save into the assets folder.

The variables and functions defined inside are accessible in all scenes and persist between pressing play.

Note: They do not persist in when the real end player closes the game.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

One use case for a scriptable object script is to hold one global variable in each script because

A

it allows you to drag a reference to that script into a prefabs monobehavior script so the rest of the script can get the value from there a unified place.

This happens by telling unity instead of your public variable being a float, it is actually of type “MyScriptableObjectScriptName”, and then inside the prefabs monobehavior script, you will call MyScriptableObjectScriptNameInstance.Value to get the value stored inside the scriptable object script.

This means that the scriptable object script will need to define the Value variable so it can later be called inside the monobehavior.

Note: This is only useful for global variables, not variables that are unique to a particular instance. ie instance’s health bar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

One use case for a scriptable object script is to define event type like GameEventType1 and

A

this event type will have a list of subscribers, and a loop to call a function on all the subscribers whenever this event is raised. e.g. I game object and I am die, I raise a death event with a parameter of myself, and then in response, all the listeners will call destroy on themselves if their ID is the same as the parameter.

The GameEvent scriptable object is just a unique event type (channel) that will store its own list of subscribers.
The GameEventListener monobehavior will have dragged in the type of event GameEvent it is listening to and it will dragged in the function call defined in the inspector for it to invoke in response to the event.
The function response should live where.

If the function you are calling is dragged into the inspector into a UnityAction, then to call it you call that variableName.invoke()

So each scriptable object event is a unique type of event, and inside

If you have a public function, you

Ok, so all the listeners have an OnEventRaised function defined, so when the GameEventType1 event is raised, it calls OnEventRaised on all the listeners.

The reason Unite Austin 2017 video uses Response.invoke() is because he wants to be able to drag in the function call to invoke rather than define it in the code repeatedly.

Then on the prefab you will have a GameEventListener monobehavior script and it will take take in the inspector a reference to the GameEventType1 and the function it needs to call in response.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In c#, before you write the function name, you must

A

write the return type

ie
void MyFunc()
int MyFunc()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In c#, a static field if changed in one class instance will

A

change in all of the instances

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

in c# the delegate keyword denotes

A

a function with no body that will be overridden

How well did you know this?
1
Not at all
2
3
4
5
Perfectly