/// <summary> /// Called right before the first frame update /// </summary> public void Start() { // Object that will provide access to the keyboard, mouse, etc if (_InputSourceOwner == null) { IInputSource[] lInputSources = InterfaceHelper.GetComponents <IInputSource>(); if (lInputSources != null && lInputSources.Length > 0) { mInputSource = lInputSources[0]; _InputSourceOwner = ((MonoBehaviour)lInputSources[0]).gameObject; } else { UnityInputSource lInputSource = Component.FindObjectOfType <UnityInputSource>(); if (lInputSource != null) { mInputSource = lInputSource; _InputSourceOwner = lInputSource.gameObject; } } } else { mInputSource = InterfaceHelper.GetComponent <IInputSource>(_InputSourceOwner); } // If the input source is still null, see if we can grab a local input source if (mInputSource == null) { mInputSource = InterfaceHelper.GetComponent <IInputSource>(gameObject); } // Grab the character controller we are tied to mCharController = GetComponent <CharacterController>(); // Grab the camera rig if (_CameraRig == null) { Camera lCamera = Component.FindObjectOfType <Camera>(); if (lCamera != null) { _CameraRig = lCamera.transform; } } mCameraRig = ExtractCameraRig(_CameraRig); // Load the animator and grab all the state info mAnimator = GetComponent <Animator>(); LoadAnimatorData(); }
/// <summary> /// Called when the object is selected in the editor /// </summary> private void OnEnable() { // Grab the serialized objects mTarget = (UnityInputSource)target; mTargetSO = new SerializedObject(target); }