TargetsUseSameData() public static method

public static TargetsUseSameData ( SerializedObject so ) : bool
so SerializedObject
return bool
        protected override void DrawInspectorGUI(bool multi)
        {
            base.DrawInspectorGUI(multi);
            if (!TargetIsValid)
            {
                return;
            }
            bool sameData = SpineInspectorUtility.TargetsUseSameData(serializedObject);

            if (multi)
            {
                foreach (var o in targets)
                {
                    TrySetAnimation(o, multi);
                }

                EditorGUILayout.Space();
                if (!sameData)
                {
                    EditorGUILayout.DelayedTextField(animationName);
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(animationName);
                    wasAnimationNameChanged |= EditorGUI.EndChangeCheck();                     // Value used in the next update.
                }
                EditorGUILayout.PropertyField(loop);
                EditorGUILayout.PropertyField(timeScale);
                foreach (var o in targets)
                {
                    var component = o as SkeletonAnimation;
                    component.timeScale = Mathf.Max(component.timeScale, 0);
                }
            }
            else
            {
                TrySetAnimation(target, multi);

                EditorGUILayout.Space();
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(animationName);
                wasAnimationNameChanged |= EditorGUI.EndChangeCheck();                 // Value used in the next update.
                EditorGUILayout.PropertyField(loop, LoopLabel);
                EditorGUILayout.PropertyField(timeScale, TimeScaleLabel);
                var component = (SkeletonAnimation)target;
                component.timeScale = Mathf.Max(component.timeScale, 0);
            }

            if (!isInspectingPrefab)
            {
                if (requireRepaint)
                {
                    SceneView.RepaintAll();
                    requireRepaint = false;
                }

                DrawSkeletonUtilityButton(multi);
            }
        }
        protected override void DrawInspectorGUI(bool multi)
        {
            base.DrawInspectorGUI(multi);
            if (!TargetIsValid)
            {
                return;
            }
            bool sameData = SpineInspectorUtility.TargetsUseSameData(serializedObject);

            foreach (var o in targets)
            {
                TrySetAnimation(o as SkeletonAnimation);
            }

            EditorGUILayout.Space();
            if (!sameData)
            {
                EditorGUILayout.DelayedTextField(animationName);
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(animationName);
                wasAnimationParameterChanged |= EditorGUI.EndChangeCheck();                 // Value used in the next update.
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(loop, LoopLabel);
            wasAnimationParameterChanged |= EditorGUI.EndChangeCheck();             // Value used in the next update.
            EditorGUILayout.PropertyField(timeScale, TimeScaleLabel);
            foreach (var o in targets)
            {
                var component = o as SkeletonAnimation;
                component.timeScale = Mathf.Max(component.timeScale, 0);
            }

            EditorGUILayout.Space();
            SkeletonRootMotionParameter();

            serializedObject.ApplyModifiedProperties();

            if (!isInspectingPrefab)
            {
                if (requireRepaint)
                {
                    UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
                    requireRepaint = false;
                }
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty = property;

            if (property.propertyType != SerializedPropertyType.String)
            {
                EditorGUI.LabelField(position, "ERROR:", "May only apply to type string");
                return;
            }

            // Handle multi-editing when instances don't use the same SkeletonDataAsset.
            if (!SpineInspectorUtility.TargetsUseSameData(property.serializedObject))
            {
                EditorGUI.DelayedTextField(position, property, label);
                return;
            }

            SerializedProperty dataField = property.FindBaseOrSiblingProperty(TargetAttribute.dataField);

            if (dataField != null)
            {
                var objectReferenceValue = dataField.objectReferenceValue;
                if (objectReferenceValue is SkeletonDataAsset)
                {
                    skeletonDataAsset = (SkeletonDataAsset)objectReferenceValue;
                }
                else if (objectReferenceValue is IHasSkeletonDataAsset)
                {
                    var hasSkeletonDataAsset = (IHasSkeletonDataAsset)objectReferenceValue;
                    if (hasSkeletonDataAsset != null)
                    {
                        skeletonDataAsset = hasSkeletonDataAsset.SkeletonDataAsset;
                    }
                }
                else if (objectReferenceValue != null)
                {
                    EditorGUI.LabelField(position, "ERROR:", "Invalid reference type");
                    return;
                }
            }
            else
            {
                var targetObject = property.serializedObject.targetObject;

                IHasSkeletonDataAsset hasSkeletonDataAsset = targetObject as IHasSkeletonDataAsset;
                if (hasSkeletonDataAsset == null)
                {
                    var component = targetObject as Component;
                    if (component != null)
                    {
                        hasSkeletonDataAsset = component.GetComponentInChildren(typeof(IHasSkeletonDataAsset)) as IHasSkeletonDataAsset;
                    }
                }

                if (hasSkeletonDataAsset != null)
                {
                    skeletonDataAsset = hasSkeletonDataAsset.SkeletonDataAsset;
                }
            }

            if (skeletonDataAsset == null)
            {
                if (TargetAttribute.fallbackToTextField)
                {
                    EditorGUI.PropertyField(position, property);                     //EditorGUI.TextField(position, label, property.stringValue);
                }
                else
                {
                    EditorGUI.LabelField(position, "ERROR:", "Must have reference to a SkeletonDataAsset");
                }

                skeletonDataAsset = property.serializedObject.targetObject as SkeletonDataAsset;
                if (skeletonDataAsset == null)
                {
                    return;
                }
            }

            position = EditorGUI.PrefixLabel(position, label);

            Texture2D image = Icon;
            string    propertyStringValue = (property.hasMultipleDifferentValues) ? SpineInspectorUtility.EmDash : property.stringValue;

            if (GUI.Button(position, string.IsNullOrEmpty(propertyStringValue) ? NoneLabel(image) : SpineInspectorUtility.TempContent(propertyStringValue, image), EditorStyles.popup))
            {
                Selector(property);
            }
        }