コード例 #1
0
    public override void OnGUI(GUIContent label)
    {
        var genericVariable = value as GenericVariable;

        EditorGUILayout.BeginVertical();
        if (FieldInspector.DrawFoldout(genericVariable.GetHashCode(), label))
        {
            EditorGUI.indentLevel++;
            if (variableNames == null)
            {
                var variables = VariableInspector.FindAllSharedVariableTypes(true);
                variableNames = new string[variables.Count];
                for (int i = 0; i < variables.Count; ++i)
                {
                    variableNames[i] = variables[i].Name.Remove(0, 6); // Remove "Shared"
                }
            }

            var index        = 0;
            var variableName = genericVariable.type.Remove(0, 6);
            for (int i = 0; i < variableNames.Length; ++i)
            {
                if (variableNames[i].Equals(variableName))
                {
                    index = i;
                    break;
                }
            }

            var newIndex     = EditorGUILayout.Popup("Type", index, variableNames, BehaviorDesignerUtility.SharedVariableToolbarPopup);
            var variableType = VariableInspector.FindAllSharedVariableTypes(true)[newIndex]; // FindAllSharedVariableTypes caches the result so this is quick
            if (newIndex != index)
            {
                index = newIndex;
                genericVariable.value = Activator.CreateInstance(variableType) as SharedVariable;
            }

            GUILayout.Space(3);
            genericVariable.type  = "Shared" + variableNames[index];
            genericVariable.value = FieldInspector.DrawSharedVariable(new GUIContent("Value"), null, variableType, genericVariable.value);

            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndVertical();
    }
コード例 #2
0
    public override void OnGUI(GUIContent label)
    {
        NamedVariable namedVariable = this.value as NamedVariable;

        EditorGUILayout.BeginVertical(new GUILayoutOption[0]);
        if (FieldInspector.DrawFoldout(namedVariable.GetHashCode(), label))
        {
            EditorGUI.indentLevel++;
            if (SharedNamedVariableDrawer.variableNames == null)
            {
                List <Type> list = VariableInspector.FindAllSharedVariableTypes(true);
                SharedNamedVariableDrawer.variableNames = new string[list.Count];
                for (int i = 0; i < list.Count; i++)
                {
                    SharedNamedVariableDrawer.variableNames[i] = list[i].Name.Remove(0, 6);
                }
            }
            int    num   = 0;
            string value = namedVariable.type.Remove(0, 6);
            for (int j = 0; j < SharedNamedVariableDrawer.variableNames.Length; j++)
            {
                if (SharedNamedVariableDrawer.variableNames[j].Equals(value))
                {
                    num = j;
                    break;
                }
            }
            namedVariable.name = EditorGUILayout.TextField("Name", namedVariable.name, new GUILayoutOption[0]);
            int  num2 = EditorGUILayout.Popup("Type", num, SharedNamedVariableDrawer.variableNames, BehaviorDesignerUtility.SharedVariableToolbarPopup, new GUILayoutOption[0]);
            Type type = VariableInspector.FindAllSharedVariableTypes(true)[num2];
            if (num2 != num)
            {
                num = num2;
                namedVariable.value = (Activator.CreateInstance(type) as SharedVariable);
            }
            GUILayout.Space(3f);
            namedVariable.type  = "Shared" + SharedNamedVariableDrawer.variableNames[num];
            namedVariable.value = FieldInspector.DrawSharedVariable(null, new GUIContent("Value"), null, type, namedVariable.value);
            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndVertical();
    }
コード例 #3
0
    public override void OnGUI(GUIContent label)
    {
        GenericVariable genericVariable = this.value as GenericVariable;

        EditorGUILayout.BeginVertical();
        if (FieldInspector.DrawFoldout(genericVariable.GetHashCode(), label))
        {
            EditorGUI.indentLevel = (EditorGUI.indentLevel + 1);
            if (variableNames == null)
            {
                List <Type> list = VariableInspector.FindAllSharedVariableTypes(true);
                variableNames = new string[list.Count];
                for (int i = 0; i < list.Count; i++)
                {
                    variableNames[i] = list[i].Name.Remove(0, 6);
                }
            }
            int    num   = 0;
            string value = genericVariable.type.Remove(0, 6);
            for (int j = 0; j < variableNames.Length; j++)
            {
                if (variableNames[j].Equals(value))
                {
                    num = j;
                    break;
                }
            }
            int  num2 = EditorGUILayout.Popup("Type", num, variableNames, BehaviorDesignerUtility.SharedVariableToolbarPopup);
            Type type = VariableInspector.FindAllSharedVariableTypes(true)[num2];
            if (num2 != num)
            {
                num = num2;
                genericVariable.value = (Activator.CreateInstance(type) as SharedVariable);
            }
            GUILayout.Space(3f);
            genericVariable.type  = "Shared" + variableNames[num];
            genericVariable.value = FieldInspector.DrawSharedVariable(null, new GUIContent("Value"), null, type, genericVariable.value);
            EditorGUI.indentLevel = (EditorGUI.indentLevel - 1);
        }
        EditorGUILayout.EndVertical();
    }