Esempio n. 1
0
        /************************************************************************************************************************/

        private void DoPlayableNotInitialisedGUI()
        {
            if (!EditorApplication.isPlaying)
            {
                return;
            }

            var target = _Targets[0];

            if (EditorUtility.IsPersistent(target.gameObject))
            {
                return;
            }

            EditorGUILayout.HelpBox("Playable is not initialised." +
                                    " It will be initialised automatically when something needs it, such as playing an animation.",
                                    MessageType.Info);

            var area = GUILayoutUtility.GetLastRect();

            AnimancerLayerDrawer.HandleDragAndDropAnimations(area, target, 0);

            if (!AnimancerEditorUtilities.TryUseContextClick(area))
            {
                return;
            }

            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("Initialise"), false, () => target.Playable.GetLayer(0));

            AnimancerEditorUtilities.AddDocumentationLink(menu, "Layer Documentation", "/docs/manual/animation-layers");

            menu.ShowAsContext();
        }
        /************************************************************************************************************************/

        /// <summary>
        /// Called by the Unity editor to draw the custom Inspector GUI elements.
        /// </summary>
        public override void OnInspectorGUI()
        {
            // Normally the targets wouldn't change after OnEnable, but the trick AnimancerComponent.Reset uses to
            // swap the type of an existing component when a new one is added causes the old target to be destroyed.
            GatherTargets();

            serializedObject.Update();

            var area = GUILayoutUtility.GetRect(0, 0);

            _AnimatorEditor.DoInspectorGUI();
            DoOtherFieldsGUI();
            PlayableDrawer.DoGUI(_Targets);

            area.yMax = GUILayoutUtility.GetLastRect().yMax;
            AnimancerLayerDrawer.HandleDragAndDropAnimations(area, _Targets[0], 0);

            serializedObject.ApplyModifiedProperties();
        }