/// <summary> /// Destroys the controller instance. /// </summary> /// <remarks> /// The default implementation destroys the prefabs GameObject. /// </remarks> protected virtual void DestroyController() { if (controller != null) { Destroy(controller.gameObject); controller = null; } }
/// <summary> /// Creates the controller instance. /// </summary> protected virtual void CreateController() { if (controller != null) { Debug.LogWarning($"{nameof(CreateController)} called but controller is already created."); return; } if (controllerPrefab == null) { Debug.LogWarning($"{nameof(CreateController)} called but {nameof(ControllerPrefab)} is not defined."); return; } // Instantiate controller = Instantiate(controllerPrefab); }