private void OnDrawElement(int line, Rect position, SerializedProperty element)
        {
            var rect = new Rect(position)
            {
                width = 0.5f * (position.width - EditorGUIUtility.standardVerticalSpacing)
            };

            _streams.Draw(element.FindPropertyRelative("_stream"), rect);

            var itemParameter = element.FindPropertyRelative("_name");

            rect.x += rect.width + EditorGUIUtility.standardVerticalSpacing;

            int paramIndex    = System.Array.FindIndex(_animParameters, p => p.name == itemParameter.stringValue);
            int newParamIndex = Mathf.Max(
                0,
                EditorGUI.Popup(
                    rect,
                    paramIndex,
                    _animParameterNames)
                );

            if (newParamIndex != paramIndex)
            {
                itemParameter.stringValue = _animParameters[newParamIndex].name;
            }
        }
Ejemplo n.º 2
0
 private void OnDrawElement(int line, Rect position, SerializedProperty element)
 {
     _streams.Draw(element, position);
 }
Ejemplo n.º 3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            using (new EditorGUI.PropertyScope(position, label, property))
            {
                var templateRect = new Rect {
                    y = position.y, height = position.height
                };
                float ident = 0.0f;

                if (!IsEmpty(label))
                {
                    templateRect.y      += EditorGUIUtility.singleLineHeight;
                    templateRect.height -= EditorGUIUtility.singleLineHeight;

                    var labelRect = new Rect(position)
                    {
                        height = EditorGUIUtility.singleLineHeight
                    };
                    EditorGUI.PrefixLabel(labelRect, GUIUtility.GetControlID(FocusType.Passive), label);

                    using (new EditorGUI.IndentLevelScope())
                    {
                        position = EditorGUI.IndentedRect(position);
                    }
                }

                using (new EditorGUI.IndentLevelScope(-EditorGUI.indentLevel))
                {
                    var valueRect = new Rect(templateRect)
                    {
                        x     = position.xMax - EditorGUIUtility.fieldWidth,
                        width = EditorGUIUtility.fieldWidth
                    };

                    var conditionRect = new Rect(templateRect)
                    {
                        x     = valueRect.x - ConditionWidth - EditorGUIUtility.standardVerticalSpacing,
                        width = ConditionWidth
                    };

                    var streamRect = new Rect(templateRect)
                    {
                        x    = position.x,
                        xMax = conditionRect.x - EditorGUIUtility.standardVerticalSpacing
                    };

                    var streams = new StreamsProperty(property.serializedObject.targetObject as Component, typeof(Stream));
                    var stream  = streams.Draw(property.FindPropertyRelative("_stream"), streamRect);

                    var elementInverse   = property.FindPropertyRelative("_inverse");
                    var elementCondition = property.FindPropertyRelative("_condition");

                    if (stream is IValueStream <bool> )
                    {
                        var options = new[] { "True", "False" };
                        var index   = EditorGUI.Popup(conditionRect, elementInverse.boolValue ? 0 : 1, options);
                        elementInverse.boolValue = index == 0;
                    }
                    else if (stream is IValueStream <int> )
                    {
                        var options = new[] { "Equals", "Not Equals", "Greater", "Less" };
                        var index   = (elementCondition.enumValueIndex << 1) + (elementInverse.boolValue ? 1 : 0);

                        var newIndex = EditorGUI.Popup(conditionRect, index, options);
                        if (index != newIndex)
                        {
                            elementCondition.intValue = newIndex >> 1;
                            elementInverse.boolValue  = newIndex % 2 == 1;
                        }

                        var elementValue = property.FindPropertyRelative("_int");
                        EditorGUI.PropertyField(valueRect, elementValue, GUIContent.none);
                    }
                    // TBD...
                }
            }
        }