// Use this for initialization void Start() { stats = GetComponent<UnitStats>(); coll = GetComponent<Collider>(); door = GetComponent<DoorOpen>(); waypointCache = GetComponentsInChildren<BarricadeWaypoint>(); unitCache = null; baseSelfHealCache = selfHealAmount; }
public void SetTarget(PlayerUnitControl player) { // Reset previous target's outline color before setting new target if (targetRend != null && player != setTargetOn) targetRend.material.SetColor("_OutlineColor", colorCache); // Set new target and cache their renderer for future color changes setTargetOn = player; if (touchCountCache > 1) FocusCamera(player.gameObject); Debug.Log("Set Target To: " + player); try { rendCache = player.gameObject.GetComponentsInChildren<Renderer>(); } catch { Debug.Log("Renderer: " + rendCache); } // Create new color from cache, change alpha, and apply if (rendCache != null) { for (int i = 0; i < rendCache.Length; i++) { if (rendCache[i].material.HasProperty("_OutlineColor")) { targetRend = rendCache[i]; if (colorCache != rendCache[i].material.GetColor("_OutlineColor")) { colorCache = rendCache[i].material.GetColor("_OutlineColor"); newColorCache = colorCache; newColorCache.a = (255F); } rendCache[i].material.SetColor("_OutlineColor", newColorCache); } } } }