Пример #1
0
 override public bool HasPreviewGUI()
 {
     if (serializedObject.isEditingMultipleObjects)
     {
         return(false);
     }
     return(ThisSkeletonDataAsset != null && ThisSkeletonDataAsset.GetSkeletonData(true) != null);
 }
Пример #2
0
        public override void OnInspectorGUI()
        {
            animationNameProperty = animationNameProperty ?? serializedObject.FindProperty("animationName");
            string animationName = animationNameProperty.stringValue;

            Animation animation = null;

            if (ThisSkeletonDataAsset != null)
            {
                var skeletonData = ThisSkeletonDataAsset.GetSkeletonData(true);
                if (skeletonData != null)
                {
                    animation = skeletonData.FindAnimation(animationName);
                }
            }
            bool animationNotFound = (animation == null);

            if (changeNextFrame)
            {
                changeNextFrame = false;

                if (ThisSkeletonDataAsset != lastSkeletonDataAsset || ThisSkeletonDataAsset.GetSkeletonData(true) != lastSkeletonData)
                {
                    preview.Clear();
                    preview.Initialize(Repaint, ThisSkeletonDataAsset, LastSkinName);

                    if (animationNotFound)
                    {
                        animationNameProperty.stringValue = "";
                        preview.ClearAnimationSetupPose();
                    }
                }

                preview.ClearAnimationSetupPose();

                if (!string.IsNullOrEmpty(animationNameProperty.stringValue))
                {
                    preview.PlayPauseAnimation(animationNameProperty.stringValue, true);
                }
            }

            //EditorGUILayout.HelpBox(AnimationReferenceAssetEditor.InspectorHelpText, MessageType.Info, true);
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            DrawDefaultInspector();
            if (EditorGUI.EndChangeCheck())
            {
                changeNextFrame = true;
            }

            // Draw extra info below default inspector.
            EditorGUILayout.Space();
            if (ThisSkeletonDataAsset == null)
            {
                EditorGUILayout.HelpBox("SkeletonDataAsset is missing.", MessageType.Error);
            }
            else if (string.IsNullOrEmpty(animationName))
            {
                EditorGUILayout.HelpBox("No animation selected.", MessageType.Warning);
            }
            else if (animationNotFound)
            {
                EditorGUILayout.HelpBox(string.Format("Animation named {0} was not found for this Skeleton.", animationNameProperty.stringValue), MessageType.Warning);
            }
            else
            {
                using (new SpineInspectorUtility.BoxScope()) {
                    if (!string.Equals(AssetUtility.GetPathSafeName(animationName), ThisAnimationReferenceAsset.name, System.StringComparison.OrdinalIgnoreCase))
                    {
                        EditorGUILayout.HelpBox("Animation name value does not match this asset's name. Inspectors using this asset may be misleading.", MessageType.None);
                    }

                    EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(animationName, SpineEditorUtilities.Icons.animation));
                    if (animation != null)
                    {
                        EditorGUILayout.LabelField(string.Format("Timelines: {0}", animation.Timelines.Count));
                        EditorGUILayout.LabelField(string.Format("Duration: {0} sec", animation.Duration));
                    }
                }
            }

            lastSkeletonDataAsset = ThisSkeletonDataAsset;
            lastSkeletonData      = ThisSkeletonDataAsset.GetSkeletonData(true);
        }