Skip to main content

GameObjectExtensions.GetComponentInActor

Declaration#

public static T GetComponentInActor(GameObject gameObject, Actor actor)

Parameters#

NameDescription
gameObjectGameObject requesting check
actorActor to use (if null gameObject will be used)

Description#

Get component under an Actor

Usage#

Example
using NullSave.GDTK;using UnityEngine;
public class CodeSample : MonoBehaviour{
    public Actor actor;
    private void Awake()    {        // You can set actor in the inspector        // You can also get it from the parent        // This travels up to the root until it finds one        if (actor == null)        {            actor = GetComponentInParent<Actor>();        }    }
    public void ExampleMethod()    {        // This travels down from the actor (like GetComponentInChildren)        AudioSource result = gameObject.GetComponentInActor<AudioSource>(actor);    }
}