コード例 #1
0
        public override void OnInspectorGUI()
        {
            animationNameProperty = animationNameProperty ?? serializedObject.FindProperty("animationName");
            string    animationName     = animationNameProperty.stringValue;
            Animation animation         = ThisSkeletonDataAsset.GetSkeletonData(true).FindAnimation(animationName);
            bool      animationNotFound = animation == null;

            if (changeNextFrame)
            {
                changeNextFrame = false;

                if (ThisSkeletonDataAsset != lastSkeletonDataAsset)
                {
                    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);
                }
            }
            lastSkeletonDataAsset = ThisSkeletonDataAsset;

            //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(SpineEditorUtilities.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));
                    }
                }
            }
        }