private void Start() { // Search for the correct environment. AIMEnvironment[] envs = gameObject.GetComponents <AIMEnvironment>(); for (int i = 0; i < envs.Length; i++) { if (envs[i].Label == EnvLabel) { env = envs[i]; } } // If no environment was found disable this component. if (env == null) { enabled = false; } // If StaticEnv is true, fill the given gameobjects into the list and disable this component. if (StaticEnv) { for (int i = 0; i < env.GameObjects.Count; i++) { if (i >= TargetObject.transform.childCount) { break; } env.GameObjects[i] = TargetObject.transform.GetChild(i).gameObject; } env.Static = true; enabled = false; } }
/// <summary> /// Adds the player reference to the environment given by the <see cref="EnvironmentName"/>. /// </summary> public override void OnStartLocalPlayer() { GameObject obj = GameObject.Find(EnvironmentName); if (obj != null) { AIMEnvironment env = obj.GetComponent <AIMEnvironment>(); if (env != null) { env.GameObjects.Add(gameObject); } else { Debug.LogWarning(gameObject.name + " " + "EnvironmentAdapter: Environment does not exist."); } } }