public void FindEnemies() { enemies = GetComponentsInChildren <Enemy>(); #if UNITY_EDITOR EditorSceneManagement.MarkSceneDirty(SceneManagement.Active); EditorUtility.SetDirty(this); #endif }
// • • • • • • • • • • • • • • • • • • • • // // // U s e r // public void SetEnemies() { #if UNITY_EDITOR if (!player) { player = FindObjectOfType <FPSPlayer>(); } if (!player) { Debug.LogError("Could not find the player in this level"); return; } #else // Get the player from the service locator if (!player) { player = Locator.Get <FPSPlayer>(); } #endif // E x i t if (null == enemies || 0 == enemies.Length) { return; } // Get the player collider Collider playerCollider = player ? player.GetComponent <Collider>() : null; foreach (Enemy enemy in enemies) { // C o n t i n u e if (enemy.set) { continue; } // Set the manager enemy.manager = this; // Set the target enemy.target = player.transform; // Set the target bounds enemy.targetBounds = (null != playerCollider) ? playerCollider.bounds : default(Bounds); // Debug DebugEnemy(enemy); #if UNITY_EDITOR EditorSceneManagement.MarkSceneDirty(SceneManagement.Active); EditorUtility.SetDirty(enemy); #endif } }
public void FindCubeManager() { #if UNITY_EDITOR if (!EditorApplication.isPlaying) { cubeManager = FindObjectOfType <CubePickupManager>(); } else { #endif cubeManager = Locator.Get <CubePickupManager>(); #if UNITY_EDITOR } EditorSceneManagement.MarkSceneDirty(SceneManagement.Active); EditorUtility.SetDirty(this); #endif }