-
Notifications
You must be signed in to change notification settings - Fork 0
MonoBehaviour Extension
Sets the active state of the GameObject associated with the MonoBehaviour.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.SetActive(true);Parameters:
-
active: The active state to set.
Checks if the GameObject associated with the MonoBehaviour is a prefab.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
bool isPrefab = scriptInstance.IsPrefab();Returns:
-
bool:trueif the GameObject is a prefab,falseotherwise.
Executes an action when a condition is met.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteWhen(() => YourAction(), () => YourCondition());Parameters:
-
action: The action to execute. -
condition: The condition to check.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action until a condition is met.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteUntil(() => YourAction(), () => YourCondition());Parameters:
-
action: The action to execute. -
condition: The condition to check.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action a certain number of times or until a condition is met.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteCountUntil(() => YourAction(), count, () => YourCondition());Parameters:
-
action: The action to execute. -
count: The maximum number of times to execute the action. -
condition: The condition to check.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action at a certain interval a certain number of times or until a condition is met.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteIntervalUntil(() => YourAction(), interval, count, () => YourCondition());Parameters:
-
action: The action to execute. -
interval: The interval in seconds between each execution. -
count: The maximum number of times to execute the action. -
condition: The condition to check. -
timeScale: Whether to use scaled or unscaled time.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action at a certain interval until a condition is met.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteIntervalUntil(() => YourAction(), interval, () => YourCondition());Parameters:
-
action: The action to execute. -
interval: The interval in seconds between each execution. -
condition: The condition to check. -
timeScale: Whether to use scaled or unscaled time.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action if a certain condition is met until another condition is met.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteIfUntil(() => YourAction(), () => ExecuteCondition(), () => FinishCondition());Parameters:
-
action: The action to execute. -
executeCondition: The condition to check for executing the action. -
finishCondition: The condition to check for finishing the execution.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action after a certain delay.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteDelay(() => YourAction(), delayInSeconds, true);Parameters:
-
action: The action to execute. -
seconds: The delay in seconds before executing the action. -
timeScale: Whether to use scaled or unscaled time.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action a certain number of times.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteCount(() => YourAction(), count);Parameters:
-
action: The action to execute. -
count: The number of times to execute the action.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action at a certain interval indefinitely.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteInterval(() => YourAction(), interval, true);Parameters:
-
action: The action to execute. -
interval: The interval in seconds between each execution. -
timeScale: Whether to use scaled or unscaled time.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action at a certain interval for a certain duration.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteInterval(() => YourAction(), interval, duration, true);Parameters:
-
action: The action to execute. -
interval: The interval in seconds between each execution. -
duration: The duration in seconds for the execution. -
timeScale: Whether to use scaled or unscaled time.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action at a certain interval a certain number of times.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteIntervalCount(() => YourAction(), count, interval, true);Parameters:
-
action: The action to execute. -
count: The number of times to execute the action. -
interval: The interval in seconds between each execution. -
timeScale: Whether
to use scaled or unscaled time.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action on the next frame.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteNextFrame(() => YourAction());Parameters:
-
action: The action to execute.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action at the end of the frame.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteEndOfFrame(() => YourAction());Parameters:
-
action: The action to execute.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action after a certain number of frames.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteAfterFrames(() => YourAction(), numberOfFrames);Parameters:
-
action: The action to execute. -
frames: The number of frames to wait before executing the action.
Returns:
-
Coroutine: A Coroutine running the execution.
Executes an action when the next FixedUpdate is called.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.ExecuteWhenFixedUpdate(() => YourAction());Parameters:
-
action: The action to execute.
Returns:
-
Coroutine: A Coroutine running the execution.
Restarts a Coroutine.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.RestartCoroutine("YourCoroutineMethodName");Parameters:
-
methodName: The name of the Coroutine method.
Returns:
-
Coroutine: A Coroutine running the execution.
Starts a Coroutine in a synchronized manner.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.StartCoroutineSync(YourCoroutine());Parameters:
-
enumerator: The IEnumerator to run.
Returns:
-
Coroutine: A Coroutine running the execution.
Waits for a certain amount of time.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.StartCoroutine(WaitForSeconds(seconds, true));Parameters:
-
second: The amount of time to wait in seconds. -
timeScale: Whether to use scaled or unscaled time.
Returns:
-
Coroutine: A Coroutine running the execution.
Waits for a certain amount of time using scaled time.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.StartCoroutine(WaitForSeconds(seconds));Parameters:
-
second: The amount of time to wait in seconds.
Returns:
-
Coroutine: A Coroutine running the execution.
Waits for a certain amount of time using unscaled time.
MonoBehaviour scriptInstance = // Obtain a MonoBehaviour instance;
scriptInstance.StartCoroutine(WaitForSecondsRealtime(seconds));Parameters:
-
second: The amount of time to wait in seconds.
Returns:
-
Coroutine: A Coroutine running the execution.