Пример #1
0
    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);
        var amountRect = getRect(100, position);
        var indent     = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        xOffset = position.x;
        // Calculate rects
        var labelRect = getRect(50, position);
        var unitRect  = getRect(100, position);

        DataSource dataProp = (DataSource)property.FindPropertyRelative("data").objectReferenceValue;

        if (dataProp != null && dataProp.name != currentData)
        {
            allFields   = dataProp.getFieldSimple();
            currentData = dataProp.name;
        }
        else if (dataProp == null)
        {
            allFields   = new List <string>();
            currentData = "mull";
        }

        //dataProp.GetType()

        SerializedProperty userIndexProperty = property.FindPropertyRelative("fieldIdx");
        SerializedProperty fieldSelection    = property.FindPropertyRelative("fieldName");

        GUIutil.doPrefixLabel(ref labelRect, "Label");
        EditorGUI.PropertyField(labelRect, property.FindPropertyRelative("obj"), GUIContent.none);

        EditorGUI.BeginChangeCheck();
        GUIutil.doPrefixLabel(ref unitRect, "FieldName");
        _choiceIndex = EditorGUI.Popup(unitRect, userIndexProperty.intValue, allFields.ToArray());
        if (EditorGUI.EndChangeCheck())
        {
            userIndexProperty.intValue = _choiceIndex;
            fieldSelection.stringValue = allFields[_choiceIndex];
        }


        GUIutil.doPrefixLabel(ref amountRect, "Data Source");
        EditorGUI.PropertyField(amountRect, property.FindPropertyRelative("data"), GUIContent.none);
        // Set indent back to what it was
        EditorGUI.indentLevel = indent;

        EditorGUI.EndProperty();
    }
Пример #2
0
    static void CreatePanel(MenuCommand menuCommand)
    {
        GameObject m = new GameObject("MenuPanel");

        GameObjectUtility.SetParentAndAlign(m, menuCommand.context as GameObject);
        m.AddComponent <Image>();
        GUIutil.matchObjSizeWithParent(m, menuCommand.context as GameObject);

        Animator       anim   = m.AddComponent <Animator>();
        doAnimAndSleep doanim = m.AddComponent <doAnimAndSleep>();

        m.AddComponent <PanelInfo>();

        doanim.anim        = anim;
        doanim.animTrigger = "menuOut";
        doanim.delay       = 0.7f;
    }
Пример #3
0
    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);
        // EditorGUIUtility.labelWidth = 14f;
        // position.width /= 2f;
        // Don't make child fields be indented
        var indent = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        xOffset = position.x;
        // Calculate rects
        var labelRect  = getRect(50, position);
        var amountRect = getRect(100, position);
        var unitRect   = getRect(100, position);
        var colorRect  = getRect(100, position);
        var nameRect   = getRect(100, position);
        var acRect     = getRect(100, position);

        DataSource dataProp = (DataSource)property.FindPropertyRelative("data").objectReferenceValue;

        if (dataProp != null && dataProp.name != currentData)
        {
            allFields   = dataProp.getFieldSimple();
            currentData = dataProp.name;
        }
        else if (dataProp == null)
        {
            allFields   = new List <string>();
            currentData = "mull";
        }

        //dataProp.GetType()

        SerializedProperty userIndexProperty = property.FindPropertyRelative("fieldIdx");
        SerializedProperty fieldSelection    = property.FindPropertyRelative("field");

        GUIutil.doPrefixLabel(ref labelRect, "Label");
        EditorGUI.PropertyField(labelRect, property.FindPropertyRelative("label"), GUIContent.none);

        EditorGUI.BeginChangeCheck();
        GUIutil.doPrefixLabel(ref unitRect, "Field");
        _choiceIndex = EditorGUI.Popup(unitRect, userIndexProperty.intValue, allFields.ToArray());
        if (EditorGUI.EndChangeCheck())
        {
            userIndexProperty.intValue = _choiceIndex;
            fieldSelection.stringValue = allFields[_choiceIndex];
        }



        //when changing fields, field is first set to null.
        //keep a list of choices, when field is null, reset choices. if list is null, get choices.
        SerializedProperty p = property.FindPropertyRelative("onSelect");

        if (p.intValue == 2)//custom prop
        {
            var eventRect = new Rect(position.x, position.y + yHeight, position.width, position.height - yHeight);
            position.height = EditorGUI.GetPropertyHeight(property.FindPropertyRelative("ev1"));


            var lblRect = new Rect(position.x, position.y + yHeight, position.width, position.height - yHeight);
            EditorGUI.PrefixLabel(lblRect, GUIUtility.GetControlID(FocusType.Passive), new GUIContent("OnPress : "));

            eventRect.y += 16;
            EditorGUI.PropertyField(eventRect, property.FindPropertyRelative("ev1"), GUIContent.none);
        }


        if (p.intValue == 0 || p.intValue == 2)
        {
            GUIutil.doPrefixLabel(ref nameRect, "Display Object");
            EditorGUI.PropertyField(nameRect, property.FindPropertyRelative("displayObj"), GUIContent.none);
        }

        GUIutil.doPrefixLabel(ref amountRect, "Data Source");
        EditorGUI.PropertyField(amountRect, property.FindPropertyRelative("data"), GUIContent.none);

        GUIutil.doPrefixLabel(ref colorRect, "DropDown Type");
        EditorGUI.PropertyField(colorRect, property.FindPropertyRelative("onSelect"), GUIContent.none);


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

        EditorGUI.EndProperty();
    }
Пример #4
0
 public void Clear()
 {
     GUIutil.clearChildren(transform);
     props.Clear();
 }
Пример #5
0
 public void Clear()
 {
     GUIutil.clearChildren(layoutGroup.transform);
     //props.Clear();
 }