예제 #1
0
    // Draw the property inside the given rects
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        // Using BeginProperty / EndProperty on the parent property means that
        // prefab override logic works on the entire property.
        EditorGUI.BeginProperty(position, label, property);

        // Draw label
        position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

        // Don't make child fields be indented
        var indent = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        // Propiedades
        SerializedProperty objProp   = property.FindPropertyRelative("objeto");
        SerializedProperty compProp  = property.FindPropertyRelative("componente");
        SerializedProperty varProp   = property.FindPropertyRelative("variable");
        SerializedProperty minProp   = property.FindPropertyRelative("min");
        SerializedProperty maxProp   = property.FindPropertyRelative("max");
        SerializedProperty indexProp = property.FindPropertyRelative("index");

        // Rectángulos donde se pintan
        var objRect   = new Rect(position.x, position.y, 100, 16);
        var compRect  = new Rect(position.x, position.y + 18, 150, 16);
        var varRect   = new Rect(position.x, position.y + 36, 120, 20);
        var indexRect = new Rect(position.x + 130, position.y + 36, 35, 16);
        var minRect   = new Rect(position.x + 125, position.y + 36, 35, 16);
        var maxRect   = new Rect(position.x + 165, position.y + 36, 35, 16);


        // Objetos (es un field normal y corriente) NOTA: todos los objetos tienen al menos un componente (el Transform)
        EditorGUI.PropertyField(objRect, objProp, GUIContent.none);

        if (objProp.objectReferenceValue == null)
        {
            return;
        }
        // Componente
        DisplayComponents(property, compRect);

        // Variables
        DisplayVariables(property, varRect);

        // Para los floats
        MM.MusicInput input    = new MM.MusicInput((Component)compProp.objectReferenceValue, varProp.stringValue);
        object        variable = input.GetValue();

        if (variable != null || input.IsAnArray())
        {
            if (input.IsAnArray())
            {
                EditorGUI.PropertyField(indexRect, indexProp, GUIContent.none);
            }
            else if (input.GetType().Name != "Boolean")
            {
                EditorGUI.PropertyField(minRect, minProp, GUIContent.none);
                EditorGUI.PropertyField(maxRect, maxProp, GUIContent.none);
            }
            //else -> es boolean
        }

        // Set indent back to what it was
        EditorGUI.indentLevel = indent;

        EditorGUI.EndProperty();
    }
예제 #2
0
 public MusicTuple(MusicInput input, MusicEffect effect, MusicOutput output)
 {
     this.input  = input;
     this.effect = effect;
     this.output = output;
 }