/// <summary> /// Switches to a specific companion camera. Must be initialized/registered with us first. /// </summary> public void SwitchToCamera(CompanionCamera target) { for (int i = 0; i < companions.Count; i++) { if (companions[i] == target) { SwitchToCamera(i); return; } } Debug.LogError("Couldn't find companion camera in our index. Did it initialize properly?", target.gameObject); }
/// <summary> /// Register a companion camera to the list of available items. /// </summary> /// <param name="companion">The camera to add.</param> /// <returns>returns true if the camera was added to the list; false if it already existed on the list.</returns> public bool AddCompanionIfNecessary(CompanionCamera companion) { if (companions == null) { companions = new List <CompanionCamera>(); } if (companions.Contains(companion)) { return(false); } else { companions.Add(companion); companion.SetTargetTransform(targetTransform); companion.SetCamerasEnabled(false); return(true); } }
/// <summary> /// Removes a companion camera from registration, and disables it if it was active. /// </summary> /// <param name="companion">The companion to remove.</param> /// <returns>Returns true if the item was removed; false if it wasn't on the list.</returns> public bool RemoveCompanionIfNecessary(CompanionCamera companion) { companion.SetCamerasEnabled(false); if (companions == null) { return(false); } if (companions.Contains(companion)) { companions.Remove(companion); if (isEnabled && CurrentCompanion == companion) { DisableAll(); } return(true); } return(false); }