/// <summary> /// Called when the component is enabled. /// </summary> protected virtual void OnEnable() { // interface references aren't serialized when unity hot-reloads if (Application.isEditor) { // ReSharper disable SuspiciousTypeConversion.Global if (_updateable == null) { _updateable = this as IUpdateable; } if (_lateUpdateable == null) { _lateUpdateable = this as ILateUpdateable; } if (_fixedUpdateable == null) { _fixedUpdateable = this as IFixedUpdateable; } if (_customUpdateable == null) { _customUpdateable = this as ICustomUpdateable; } // ReSharper restore SuspiciousTypeConversion.Global } // We don't want Update calls before Start has been called. if (_startWasCalled) { StartListening(); } }
/// <summary> /// Start is called on the frame when a script is enabled just before any of the Update methods is called the first time. /// </summary> protected virtual void Start() { // ReSharper disable SuspiciousTypeConversion.Global _updateable = this as IUpdateable; _lateUpdateable = this as ILateUpdateable; _fixedUpdateable = this as IFixedUpdateable; _customUpdateable = this as ICustomUpdateable; // ReSharper restore SuspiciousTypeConversion.Global if (_updateable == null && _lateUpdateable == null && _fixedUpdateable == null && _customUpdateable == null) { Debug.LogWarning("This component doesn't implement any update interfaces.", this); } _startWasCalled = true; StartListening(); }