/// <summary> /// Untracks target; removes target from tracking list /// </summary> private static void UntrackTarget(GameObject target) { #if UNITY_2019_2_OR_NEWER target.TryGetComponent(out IndicatorTarget ITarget); #else IndicatorTarget ITarget = target.GetComponent <IndicatorTarget>(); #endif ITarget.enabled = false; Targets.Remove(ITarget); }
/// <summary> /// Returns the IndicatorTarget component of the target /// </summary> private static IndicatorTarget GetIndicatorTarget(GameObject target) { IndicatorTarget ITarget = target.GetComponent <IndicatorTarget>(); if (ITarget != null) { for (int i = 0; i < Targets.Count; i++) { if (ITarget = Targets[i]) { return(ITarget); } } } return(null); }
/// <summary> /// Tracks target; add a IndicatorTarget component to the target if it doesn't already exist and add to tracking list. /// </summary> private static void TrackTarget(GameObject target) { #if UNITY_2019_2_OR_NEWER target.TryGetComponent(out IndicatorTarget ITarget); #else IndicatorTarget ITarget = target.GetComponent <IndicatorTarget>(); #endif //If the target doesn't have a indicator... Add one if (ITarget == null) { ITarget = target.AddComponent <IndicatorTarget>(); } //Else if the target already has an indicator, check if it just needs to be added to the tracking list if not already else if (!Targets.Contains(ITarget)) { Targets.Add(ITarget); } else { Debug.Log("Target is already being tracked."); } ITarget.enabled = true; }
private void Awake() { mTarget = GetComponent <IndicatorTarget>(); }