コード例 #1
0
        public override void OnInspectorGUI()
        {
            var referencesObjectBase = target as ReferencesObjectBase;

            string referenceCountLabel = string.Format("{0} references of <{1}>", referencesObjectBase.ReferenceCount, referencesObjectBase.ReferencedType.Name);

            EditorGUILayout.LabelField(referenceCountLabel, EditorStyles.centeredGreyMiniLabel);

            EditorGUILayout.BeginHorizontal();

            EditorHelper.BeginChangeLabelWidth(72.0f);
            SerializedProperty rootFolderProperty = serializedObject.GetMemberProperty <ReferencesBase>(r => r.rootFolder);

            EditorGUILayout.PropertyField(rootFolderProperty);
            EditorHelper.EndChangeLabelWidth();

            if (GUILayout.Button("Update References", EditorStyles.miniButton, GUILayout.Width(108.0f)))
            {
                referencesObjectBase.UpdateReferences();
                serializedObject.ApplyModifiedProperties();
            }

            EditorGUILayout.EndHorizontal();

            if (referencesObjectBase.ContainsNullReference)
            {
                Rect warningRect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.label);

                GUI.Box(warningRect, GUIContent.none);
                var style = new GUIStyle(EditorStyles.centeredGreyMiniLabel);
                style.normal.textColor = Color.red;
                GUI.Label(warningRect, "Null references found! Please, update the references.", style);
            }
        }
コード例 #2
0
        /// <summary>
        /// Internal method. Do not touch it.
        /// </summary>
        /// <param name="host"></param>
        public override void NodeUI(GraphGUI host)
        {
            EditorGUI.BeginChangeCheck();
            EditorHelper.BeginChangeLabelWidth(84.0f);

            OnShowNode(host);

            EditorHelper.EndChangeLabelWidth();
            var editorGraph = graph as EditorGraph;

            if (EditorGUI.EndChangeCheck() && editorGraph != null)
            {
                editorGraph.controller.OnNodeChanged(this);
            }
        }
コード例 #3
0
        private void DrawAnimationListElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            AnimationClip animation = animations[index];

            EditorGUI.BeginChangeCheck();
            EditorHelper.BeginChangeLabelWidth(24.0f);
            animation.name = EditorGUI.DelayedTextField(rect, animationIconGuiContent, animation.name);
            EditorHelper.EndChangeLabelWidth();

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(animation);
                AssetDatabase.SaveAssets();
                LoadAnimationList();
            }
        }
コード例 #4
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            PropertyDrawerHelper.LoadAttributeTooltip(this, label);

            // Bugged Unity... hacks :(
            if (!property.type.EndsWith("Bounds"))
            {
                return;
            }

            Rect labelPosition = new Rect(position);
            Rect minPosition   = new Rect(position);
            Rect maxPosition   = new Rect(position);

            labelPosition.width = EditorGUIUtility.labelWidth;
            minPosition.x       = labelPosition.xMax;
            minPosition.width   = (minPosition.width - labelPosition.width) * 0.5f;
            maxPosition.x       = labelPosition.xMax + minPosition.width;
            maxPosition.width   = minPosition.width;

            EditorGUI.LabelField(labelPosition, label);

            SerializedProperty max = property.GetMemberProperty <IntBounds>(b => b.Max);
            SerializedProperty min = property.GetMemberProperty <IntBounds>(b => b.Min);

            EditorHelper.BeginChangeLabelWidth(32.0f);
            EditorHelper.BeginChangeIndentLevel(0);

            EditorGUI.BeginChangeCheck();
            DelayedPropertyField(minPosition, min);
            DelayedPropertyField(maxPosition, max);
            if (EditorGUI.EndChangeCheck())
            {
                min.serializedObject.ApplyModifiedProperties();
                max.serializedObject.ApplyModifiedProperties();

                var validatable = SerializedPropertyHelper.GetValue(fieldInfo, property) as IValidatable;
                validatable.Validate();

                min.serializedObject.Update();
                max.serializedObject.Update();
            }

            EditorHelper.EndChangeIndentLevel();
            EditorHelper.EndChangeLabelWidth();
        }
コード例 #5
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            PropertyDrawerHelper.LoadAttributeTooltip(this, label);

            // Bugged Unity... hacks :(
            if (!property.type.StartsWith("Modifiable"))
            {
                return;
            }

            Rect labelPosition    = position.Left(EditorGUIUtility.labelWidth);
            Rect fieldsPosition   = position.Right(-EditorGUIUtility.labelWidth);
            Rect originalPosition = fieldsPosition.Left(fieldsPosition.width * 0.5f);
            Rect modifiedPosition = fieldsPosition.Right(-fieldsPosition.width * 0.5f);

            EditorGUI.LabelField(labelPosition, label);

            SerializedProperty originalValue = property.GetMemberProperty <ModifiableInt>(m => m.OriginalValue);
            SerializedProperty modifiedValue = property.GetMemberProperty <ModifiableInt>(m => m.ModifiedValue);

            EditorHelper.BeginChangeLabelWidth(56.0f);
            EditorHelper.BeginChangeIndentLevel(0);

            EditorGUI.BeginChangeCheck();
            EditorGUI.PropertyField(originalPosition, originalValue, new GUIContent("Original"));
            bool modified = EditorGUI.EndChangeCheck();

            EditorGUI.BeginDisabledGroup(true);
            EditorGUI.PropertyField(modifiedPosition, modifiedValue, new GUIContent("Modified"));
            EditorGUI.EndDisabledGroup();

            EditorHelper.EndChangeIndentLevel();
            EditorHelper.EndChangeLabelWidth();

            if (modified)
            {
                originalValue.serializedObject.ApplyModifiedProperties();
                modifiedValue.serializedObject.ApplyModifiedProperties();

                var modifiable = SerializedPropertyHelper.GetValue(fieldInfo, property) as IModifiable;
                modifiable.UpdateModifiedValues();

                originalValue.serializedObject.Update();
                modifiedValue.serializedObject.Update();
            }
        }
コード例 #6
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            PropertyDrawerHelper.LoadAttributeTooltip(this, label);

            var referencesBase = SerializedPropertyHelper.GetValue(fieldInfo, property) as ReferencesBase;

            Rect labelRect;
            Rect referenceCountRect = position.Row(0)
                                      .Left(EditorGUIUtility.labelWidth, out labelRect);

            Rect buttonRect;
            Rect rootFolderRect = position.Row(1).Right(-14.0f)
                                  .Right(108.0f, out buttonRect);

            if (referencesBase.ContainsNullReference)
            {
                Rect warningRect = position.Row(2).Right(-14.0f);
                GUI.Box(warningRect, GUIContent.none);
                var style = new GUIStyle(EditorStyles.centeredGreyMiniLabel);
                style.normal.textColor = Color.red;
                GUI.Label(warningRect, "Null references found! Please, update the references.", style);
            }

            EditorGUI.LabelField(labelRect, label);

            string referenceCountLabel = string.Format("{0} references of <{1}>", referencesBase.ReferenceCount, referencesBase.ReferencedType.Name);

            EditorGUI.LabelField(referenceCountRect, referenceCountLabel, EditorStyles.centeredGreyMiniLabel);

            EditorHelper.BeginChangeLabelWidth(72.0f);
            SerializedProperty rootFolderProperty = property.GetMemberProperty <ReferencesBase>(r => r.rootFolder);

            EditorGUI.PropertyField(rootFolderRect, rootFolderProperty);
            EditorHelper.EndChangeLabelWidth();

            if (GUI.Button(buttonRect, "Update References", EditorStyles.miniButton))
            {
                referencesBase.UpdateReferences();
                property.serializedObject.ApplyModifiedProperties();
            }
        }
コード例 #7
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            PropertyDrawerHelper.LoadAttributeTooltip(this, label);

            var nameProperty  = property.GetMemberProperty <TweenShaderProperty>(p => p.name);
            var typeProperty  = property.GetMemberProperty <TweenShaderProperty>(p => p.type);
            var curveProperty = property.GetMemberProperty <TweenShaderProperty>(p => p.curve);
            var fromProperty  = property.GetMemberProperty <TweenShaderProperty>(p => p.from);
            var toProperty    = property.GetMemberProperty <TweenShaderProperty>(p => p.to);

            var mainRow  = position.Row(0);
            var fromRect = position.Row(1).Right(-FromToPadding);
            var toRect   = position.Row(2).Right(-FromToPadding);

            Rect nameRect, typeRect, curveRect;

            nameRect = mainRow.Right(CurveWidth, out curveRect).Right(TypeWidth, out typeRect);

            var tweenShader    = property.serializedObject.targetObject as TweenShader;
            var targetRenderer = tweenShader.targetRenderer;

            if (targetRenderer == null)
            {
                nameProperty.stringValue    = EditorGUI.TextField(nameRect, nameProperty.stringValue);
                typeProperty.enumValueIndex = EditorGUI.Popup(typeRect, typeProperty.enumValueIndex, typeProperty.enumDisplayNames);
            }
            else
            {
                TweenShaderPropertiesCache cache;
                if (!propertiesCache.TryGetValue(targetRenderer, out cache))
                {
                    cache = new TweenShaderPropertiesCache();
                    propertiesCache.Add(targetRenderer, cache);
                }

                cache.UpdateProperties(tweenShader);

                int index = System.Array.IndexOf(cache.propertyNameOptions, nameProperty.stringValue);
                index = EditorGUI.Popup(nameRect, index, cache.propertyNameOptions);

                nameProperty.stringValue    = cache.properties[index].name;
                typeProperty.enumValueIndex = ( int )cache.properties[index].type;

                EditorGUI.BeginDisabledGroup(true);
                EditorGUI.Popup(typeRect, typeProperty.enumValueIndex, typeProperty.enumDisplayNames);
                EditorGUI.EndDisabledGroup();
            }

            curveProperty.animationCurveValue = EditorGUI.CurveField(curveRect, curveProperty.animationCurveValue);

            EditorHelper.BeginChangeLabelWidth(FromToLabelWidth);

            Vector4 fromVector = fromProperty.vector4Value;
            Vector4 toVector   = toProperty.vector4Value;

            var type = (TweenShaderProperty.Type)typeProperty.enumValueIndex;

            switch (type)
            {
            case TweenShaderProperty.Type.Float:
                fromVector.x = EditorGUI.FloatField(fromRect, fromLabel, fromVector.x);
                fromProperty.vector4Value = fromVector;

                toVector.x = EditorGUI.FloatField(toRect, toLabel, toVector.x);
                toProperty.vector4Value = toVector;

                break;

            case TweenShaderProperty.Type.Vector:
                float labelWidth = EditorGUIUtility.labelWidth;

                EditorGUI.LabelField(fromRect.Left(labelWidth), fromLabel);
                fromVector = EditorGUI.Vector4Field(fromRect.Right(-labelWidth).Row(-1), "", fromVector);
                fromProperty.vector4Value = fromVector;

                EditorGUI.LabelField(toRect.Left(labelWidth), toLabel);
                toVector = EditorGUI.Vector4Field(toRect.Right(-labelWidth).Row(-1), "", toVector);
                toProperty.vector4Value = toVector;

                break;

            case TweenShaderProperty.Type.Color:
                fromVector = EditorGUI.ColorField(fromRect, fromLabel, fromVector, true, true, true, colorPickerConfig);
                fromProperty.vector4Value = fromVector;

                toVector = EditorGUI.ColorField(toRect, toLabel, toVector, true, true, true, colorPickerConfig);
                toProperty.vector4Value = toVector;

                break;
            }

            EditorHelper.EndChangeLabelWidth();

            property.serializedObject.ApplyModifiedProperties();
        }