Beispiel #1
0
 public void GenerateList(FieldInspector fieldInspector)
 {
     List = new UReorderableList(fieldInspector.Property.serializedObject, fieldInspector.Property, true, true, true, true);
     List.drawHeaderCallback = (Rect rect) =>
     {
         EditorGUI.LabelField(rect, string.Format("{0}: {1}", fieldInspector.Label, fieldInspector.Property.arraySize), EditorStyles.boldLabel);
     };
     List.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
     {
         SerializedProperty element = fieldInspector.Property.GetArrayElementAtIndex(index);
         rect.x     += 10;
         rect.y     += 2;
         rect.width -= 10;
         EditorGUI.PropertyField(rect, element, true);
     };
     List.drawElementBackgroundCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
     {
         if (Event.current.type == EventType.Repaint)
         {
             GUIStyle gUIStyle = (index % 2 != 0) ? "CN EntryBackEven" : "CN EntryBackodd";
             gUIStyle    = (!isActive && !isFocused) ? gUIStyle : "RL Element";
             rect.x     += 2;
             rect.width -= 6;
             gUIStyle.Draw(rect, false, isActive, isActive, isFocused);
         }
     };
     List.elementHeightCallback = (int index) =>
     {
         return(EditorGUI.GetPropertyHeight(fieldInspector.Property.GetArrayElementAtIndex(index)) + 6);
     };
 }
Beispiel #2
0
            public override void Draw(ObjectInspector inspector, FieldInspector fieldInspector)
            {
                if (fieldInspector.Field.FieldType == typeof(string))
                {
                    string value = (string)fieldInspector.Field.GetValue(inspector.target);
                    if (value == null)
                    {
                        value = "";
                    }

                    GUILayout.BeginHorizontal();
                    EditorGUI.BeginChangeCheck();
                    string newValue = EditorGUILayout.PasswordField(fieldInspector.Label, value);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(inspector.target, "Password");
                        fieldInspector.Field.SetValue(inspector.target, newValue);
                        inspector.HasChanged();
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] can't used Password! because the types don't match!", MessageType.Error);
                    GUILayout.EndHorizontal();
                }
            }
Beispiel #3
0
            public override void SceneHandle(ObjectInspector inspector, FieldInspector fieldInspector)
            {
                if (fieldInspector.Field.FieldType == typeof(Bounds))
                {
                    Bounds value = (Bounds)fieldInspector.Field.GetValue(inspector.target);
                    BoundsHandle.center = value.center;
                    BoundsHandle.size   = value.size;

                    using (new Handles.DrawingScope(fieldInspector.UseColor))
                    {
                        EditorGUI.BeginChangeCheck();
                        BoundsHandle.DrawHandle();
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(inspector.target, "Bounds Handler");
                            value.center = BoundsHandle.center;
                            value.size   = BoundsHandle.size;
                            fieldInspector.Field.SetValue(inspector.target, value);
                            inspector.HasChanged();
                        }
                        if (BAttribute.Display != null)
                        {
                            Handles.Label(BoundsHandle.center, BAttribute.Display);
                        }
                    }
                }
            }
Beispiel #4
0
            public override void Draw(ObjectInspector inspector, FieldInspector fieldInspector)
            {
                if (DAttribute.ValueType == fieldInspector.Field.FieldType)
                {
                    object value       = fieldInspector.Field.GetValue(inspector.target);
                    int    selectIndex = Array.IndexOf(DAttribute.Values, value);
                    if (selectIndex < 0)
                    {
                        selectIndex = 0;
                    }

                    GUILayout.BeginHorizontal();
                    EditorGUI.BeginChangeCheck();
                    int newIndex = EditorGUILayout.Popup(fieldInspector.Label, selectIndex, DAttribute.DisplayOptions);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(inspector.target, "Dropdown");
                        fieldInspector.Field.SetValue(inspector.target, DAttribute.Values[newIndex]);
                        inspector.HasChanged();
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] used a mismatched Dropdown!", MessageType.Error);
                    GUILayout.EndHorizontal();
                }
            }
        public void TestIssue001A()
        {
            var file = Path.GetTempFileName().Replace(".tmp", ".csv");

            File.WriteAllText(file, @"t1,t2,t3,t4
Monday,10,1.1,1/1/2014
Tuesday,11,2.2,2/1/2014
Wednesday,12,3.3,3/1/2014
Thursday,13,4.4,4/1/2014
Friday,14,5.5,5/1/2014
Saturday,15,6.6,6/1/2014");


            var request = new FileInspectionRequest(file)
            {
                DataTypes = new List <string> {
                    "int32", "double", "datetime"
                }
            };
            var information = FileInformationFactory.Create(request, new TestLogger());
            var fields      = new FieldInspector(new TestLogger()).Inspect(information, request).ToArray();

            Assert.AreEqual("string", fields[0].Type);
            Assert.AreEqual("int32", fields[1].Type);
            Assert.AreEqual("double", fields[2].Type);
            Assert.AreEqual("datetime", fields[3].Type);

            //really do it
            //new FileImporter().Import(new FileInfo(file), request);
        }
        public void TestFieldQuotedCsv2()
        {
            var file = Path.GetTempFileName().Replace(".tmp", ".csv");

            File.WriteAllText(file, @"Field 1,Field 2,Field 3,Field 4,Field 5,Field 6
""0007282100"",""O721"",20,""1111 COUNTY RD 1 SOUTH POINT OH 11111"",,""1""
""0007382201"",""O722"",25,""2222 COUNTY RD 1 SOUTH POINT OH 22222"",,""1""
""0007482302"",""O723"",30,""3333 COUNTY RD 1 SOUTH POINT OH 33333"",,""1""
");
            var info   = FileInformationFactory.Create(file, new TestLogger());
            var actual = new FieldInspector(new TestLogger()).Inspect(info);

            Assert.AreEqual(6, actual.Count);

            Assert.AreEqual("Field 1", actual[0].Name);
            Assert.AreEqual("Field 2", actual[1].Name);
            Assert.AreEqual("Field 3", actual[2].Name);
            Assert.AreEqual("Field 4", actual[3].Name);
            Assert.AreEqual("Field 5", actual[4].Name);
            Assert.AreEqual("Field 6", actual[5].Name);

            Assert.AreEqual("int", actual[0].Type);
            Assert.AreEqual("string", actual[1].Type);
            Assert.AreEqual("int", actual[2].Type);
            Assert.AreEqual("string", actual[3].Type);
            Assert.AreEqual("string", actual[4].Type);
            Assert.AreEqual("int", actual[5].Type);
        }
        public void TestFalseBoolean()
        {
            var          file     = Path.GetTempFileName();
            const string contents = @"34149771
34150506
34148432
39844261
34149561
65313203
76674170
83513345
85501135
55975869
89604649
72561004
94461202
71436264
39905508
29692312
a
b
c";

            File.WriteAllText(file, contents);

            var fields = new FieldInspector(new TestLogger()).Inspect(file).ToArray();

            Assert.AreEqual("string", fields[0].Type);
        }
        public void TestCsvBlanks()
        {
            var file = Path.GetTempFileName().Replace(".tmp", ".csv");

            File.WriteAllText(file, @"t1,t2,t3,t4,t5
""Monday"",10,""1.1"",1/1/2014,
""Tuesday"",11,""2.2"",2/1/2014,
""Wednesday"",12,""3.3"",3/1/2014,
""Thursday"",13,""4.4"",4/1/2014,
""Friday"",14,,5/1/2014,
""Saturday"",15,,6/1/2014,");

            var request = new FileInspectionRequest(file)
            {
                DataTypes = new List <string> {
                    "int32", "double", "datetime"
                },
                IgnoreEmpty = true
            };
            var information = FileInformationFactory.Create(request, new TestLogger());
            var fields      = new FieldInspector(new TestLogger()).Inspect(information, request).ToArray();

            Assert.AreEqual('"', fields[0].QuotedWith);
            Assert.AreEqual("string", fields[0].Type);
            Assert.AreEqual("int32", fields[1].Type);
            Assert.AreEqual('"', fields[2].QuotedWith);
            Assert.AreEqual("double", fields[2].Type);
            Assert.AreEqual("datetime", fields[3].Type);
            Assert.AreEqual("string", fields[4].Type);
            Assert.AreEqual("1", fields[4].Length);
        }
Beispiel #9
0
            public override void SceneHandle(ObjectInspector inspector, FieldInspector fieldInspector)
            {
                if (fieldInspector.Field.FieldType == typeof(Vector3))
                {
                    Vector3 value = (Vector3)fieldInspector.Field.GetValue(inspector.target);

                    if (value != Vector3.zero)
                    {
                        using (new Handles.DrawingScope(fieldInspector.UseColor))
                        {
                            ExternalSize = GetExternalSize(inspector.target);
                            InternalSize = GetInternalSize(inspector.target);
                            Handles.CircleHandleCap(0, Position, Quaternion.FromToRotation(Vector3.forward, value), ExternalSize, EventType.Repaint);
                            Handles.CircleHandleCap(0, Position, Quaternion.FromToRotation(Vector3.forward, value), InternalSize, EventType.Repaint);
                            Handles.Slider(Position, value);
                        }
                    }
                }
                else if (fieldInspector.Field.FieldType == typeof(Vector2))
                {
                    Vector2 value = (Vector2)fieldInspector.Field.GetValue(inspector.target);

                    if (value != Vector2.zero)
                    {
                        using (new Handles.DrawingScope(fieldInspector.UseColor))
                        {
                            ExternalSize = GetExternalSize(inspector.target);
                            InternalSize = GetInternalSize(inspector.target);
                            Handles.CircleHandleCap(0, Position, Quaternion.FromToRotation(Vector3.forward, value), ExternalSize, EventType.Repaint);
                            Handles.CircleHandleCap(0, Position, Quaternion.FromToRotation(Vector3.forward, value), InternalSize, EventType.Repaint);
                            Handles.Slider(Position, value);
                        }
                    }
                }
            }
Beispiel #10
0
            public override void Draw(ObjectInspector inspector, FieldInspector fieldInspector)
            {
                if (fieldInspector.Field.FieldType == typeof(string))
                {
                    string value = (string)fieldInspector.Field.GetValue(inspector.target);
                    int    layer = LayerMask.NameToLayer(value);
                    if (layer < 0)
                    {
                        layer = 0;
                    }
                    if (layer > 31)
                    {
                        layer = 31;
                    }

                    GUILayout.BeginHorizontal();
                    EditorGUI.BeginChangeCheck();
                    int newLayer = EditorGUILayout.LayerField(fieldInspector.Label, layer);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(inspector.target, "Layer");
                        fieldInspector.Field.SetValue(inspector.target, LayerMask.LayerToName(newLayer));
                        inspector.HasChanged();
                    }
                    GUILayout.EndHorizontal();
                }
                else if (fieldInspector.Field.FieldType == typeof(int))
                {
                    int layer = (int)fieldInspector.Field.GetValue(inspector.target);
                    if (layer < 0)
                    {
                        layer = 0;
                    }
                    if (layer > 31)
                    {
                        layer = 31;
                    }

                    GUILayout.BeginHorizontal();
                    EditorGUI.BeginChangeCheck();
                    int newLayer = EditorGUILayout.LayerField(fieldInspector.Label, layer);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(inspector.target, "Layer");
                        fieldInspector.Field.SetValue(inspector.target, newLayer);
                        inspector.HasChanged();
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] can't used Layer! because the types don't match!", MessageType.Error);
                    GUILayout.EndHorizontal();
                }
            }
        public override void OnGUI(GUIContent label)
        {
            var stackedConditional = task as StackedConditional;

            stackedConditional.comparisonType = (StackedConditional.ComparisonType)FieldInspector.DrawField(stackedConditional,
                                                                                                            new GUIContent("Comparison Type", "Specifies if the tasks should be traversed with an AND (Sequence) or an OR (Selector)."),
                                                                                                            stackedConditional.GetType().GetField("comparisonType", BindingFlags.Instance | BindingFlags.Public),
                                                                                                            stackedConditional.comparisonType);

            stackedConditional.graphLabel = (bool)FieldInspector.DrawField(stackedConditional,
                                                                           new GUIContent("Graph Label", "Should the tasks be labeled within te graph?"),
                                                                           stackedConditional.GetType().GetField("graphLabel", BindingFlags.Instance | BindingFlags.Public),
                                                                           stackedConditional.graphLabel);

            if (stackedConditional.conditionals == null)
            {
                stackedConditional.conditionals = new Conditional[0];
            }

            if (reorderableList == null)
            {
                reorderableList = new ReorderableList(stackedConditional.conditionals, typeof(Conditional), true, true, true, true);
                reorderableList.drawHeaderCallback += (Rect rect) =>
                {
                    EditorGUI.LabelField(rect, "Conditionals");
                };
                reorderableList.onAddDropdownCallback += OnAddDropdownCallback;
                reorderableList.drawElementCallback   += OnDrawElementCallback;
                reorderableList.onReorderCallback     += OnReorderCallback;
                reorderableList.onSelectCallback      += OnSelectCallback;
                reorderableList.onCanRemoveCallback   += OnCanRemoveCallback;
                reorderableList.onRemoveCallback      += OnRemoveCallback;
            }
            if (stackedConditional != lastStackedConditional)
            {
                lastStackedConditional = stackedConditional;
                var index = EditorPrefs.GetInt("BehaviorDesigner.StackedConditional." + stackedConditional.ID, -1);
                if (index < stackedConditional.conditionals.Length)
                {
                    reorderableList.index = index;
                }
            }
            if (reorderableList.index == -1 && stackedConditional.conditionals.Length > 0)
            {
                reorderableList.index = 0;
            }
            reorderableList.DoLayoutList();

            if (reorderableList.index >= 0 && stackedConditional.conditionals != null && reorderableList.index < stackedConditional.conditionals.Length)
            {
                var selectedConditional = stackedConditional.conditionals[reorderableList.index];
                EditorGUILayout.LabelField(selectedConditional.GetType().Name, BehaviorDesignerUtility.BoldLabelGUIStyle);
                FieldInspector.DrawFields(selectedConditional, selectedConditional);
            }
        }
Beispiel #12
0
            public override void SceneHandle(ObjectInspector inspector, FieldInspector fieldInspector)
            {
                if (fieldInspector.Field.FieldType == typeof(float))
                {
                    Component component = inspector.target as Component;
                    Vector3   center    = component != null ? component.transform.position : Vector3.zero;
                    float     value     = (float)fieldInspector.Field.GetValue(inspector.target);

                    using (new Handles.DrawingScope(fieldInspector.UseColor))
                    {
                        EditorGUI.BeginChangeCheck();
                        float newValue = Handles.RadiusHandle(Quaternion.identity, center, value);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(inspector.target, "Radius Handler");
                            fieldInspector.Field.SetValue(inspector.target, newValue);
                            inspector.HasChanged();
                        }
                        if (RAttribute.Display != null)
                        {
                            Handles.Label(center, RAttribute.Display);
                        }
                    }
                }
                else if (fieldInspector.Field.FieldType == typeof(int))
                {
                    Component component = inspector.target as Component;
                    Vector3   center    = component != null ? component.transform.position : Vector3.zero;
                    int       value     = (int)fieldInspector.Field.GetValue(inspector.target);

                    using (new Handles.DrawingScope(fieldInspector.UseColor))
                    {
                        EditorGUI.BeginChangeCheck();
                        int newValue = (int)Handles.RadiusHandle(Quaternion.identity, center, value);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(inspector.target, "Radius Handler");
                            fieldInspector.Field.SetValue(inspector.target, newValue);
                            inspector.HasChanged();
                        }
                        if (RAttribute.Display != null)
                        {
                            Handles.Label(center, RAttribute.Display);
                        }
                    }
                }
            }
    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();
    }
        public void TestIssue002B()
        {
            const string file = @"TestFiles\Headers\Issue002.xlsx";

            var request = new FileInspectionRequest(file)
            {
                DataTypes = new List <string> {
                    "int32", "datetime"
                }
            };
            var information = FileInformationFactory.Create(request, new TestLogger());
            var fields      = new FieldInspector(new TestLogger()).Inspect(information, request).ToArray();

            Assert.AreEqual("string", fields[0].Type);
            Assert.AreEqual("int32", fields[1].Type);
            Assert.AreEqual("string", fields[2].Type);
            Assert.AreEqual("datetime", fields[3].Type);
        }
Beispiel #15
0
            public override void SceneHandle(ObjectInspector inspector, FieldInspector fieldInspector)
            {
                if (fieldInspector.Field.FieldType == typeof(float))
                {
                    float value = (float)fieldInspector.Field.GetValue(inspector.target);

                    using (new Handles.DrawingScope(fieldInspector.UseColor))
                    {
                        Position = GetPosition(inspector.target);
                        Size     = GetSize(inspector.target, value);
                        Handles.CircleHandleCap(0, Position, Rotation, Size, EventType.Repaint);
                        if (Target)
                        {
                            Handles.Slider(Position, Target.forward);
                        }
                    }
                }
            }
Beispiel #16
0
            public override void Draw(ObjectInspector inspector, FieldInspector fieldInspector)
            {
                if (fieldInspector.Property.isArray)
                {
                    if (List == null)
                    {
                        GenerateList(fieldInspector);
                    }

                    List.DoLayoutList();
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] can't use the ReorderableList!", MessageType.Error);
                    GUILayout.EndHorizontal();
                }
            }
Beispiel #17
0
            public override void SceneHandle(ObjectInspector inspector, FieldInspector fieldInspector)
            {
                if (fieldInspector.Field.FieldType == typeof(Vector3))
                {
                    Vector3 value = (Vector3)fieldInspector.Field.GetValue(inspector.target);

                    using (new Handles.DrawingScope(fieldInspector.UseColor))
                    {
                        EditorGUI.BeginChangeCheck();
                        Vector3 newValue = Handles.PositionHandle(value, Quaternion.identity);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(inspector.target, "Move Handler");
                            fieldInspector.Field.SetValue(inspector.target, newValue);
                            inspector.HasChanged();
                        }
                        if (MAttribute.Display != null)
                        {
                            Handles.Label(newValue, MAttribute.Display);
                        }
                    }
                }
                else if (fieldInspector.Field.FieldType == typeof(Vector2))
                {
                    Vector2 value = (Vector2)fieldInspector.Field.GetValue(inspector.target);

                    using (new Handles.DrawingScope(fieldInspector.UseColor))
                    {
                        EditorGUI.BeginChangeCheck();
                        Vector2 newValue = Handles.PositionHandle(value, Quaternion.identity);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(inspector.target, "Move Handler");
                            fieldInspector.Field.SetValue(inspector.target, newValue);
                            inspector.HasChanged();
                        }
                        if (MAttribute.Display != null)
                        {
                            Handles.Label(newValue, MAttribute.Display);
                        }
                    }
                }
            }
Beispiel #18
0
 public override void Draw(ObjectInspector inspector, FieldInspector fieldInspector)
 {
     if (fieldInspector.Field.FieldType == typeof(string))
     {
         GUILayout.BeginHorizontal();
         bool isClick = (bool)LinkLabel.Invoke(null, Parameter);
         if (isClick)
         {
             Application.OpenURL((string)fieldInspector.Field.GetValue(inspector.target));
         }
         GUILayout.EndHorizontal();
     }
     else
     {
         GUILayout.BeginHorizontal();
         EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] can't used Hyperlink! because the types don't match!", MessageType.Error);
         GUILayout.EndHorizontal();
     }
 }
    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();
    }
Beispiel #20
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();
    }
Beispiel #21
0
            public override void Draw(ObjectInspector inspector, FieldInspector fieldInspector)
            {
                if (fieldInspector.Field.FieldType == typeof(string))
                {
                    string value = (string)fieldInspector.Field.GetValue(inspector.target);
                    if (value == null)
                    {
                        value = "";
                    }

                    GUILayout.BeginHorizontal();
                    EditorGUI.BeginChangeCheck();
                    string newValue = EditorGUILayout.TextField(fieldInspector.Label, value);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(inspector.target, "FolderPath");
                        fieldInspector.Field.SetValue(inspector.target, newValue);
                        inspector.HasChanged();
                    }
                    if (GUILayout.Button(OpenGC, EditorGlobalTools.Styles.IconButton, GUILayout.Width(20), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
                    {
                        string path = EditorUtility.OpenFolderPanel("Select Folder", Application.dataPath, "");
                        if (path.Length != 0)
                        {
                            Undo.RecordObject(inspector.target, "FolderPath");
                            fieldInspector.Field.SetValue(inspector.target, "Assets" + path.Replace(Application.dataPath, ""));
                            inspector.HasChanged();
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] can't used FolderPath! because the types don't match!", MessageType.Error);
                    GUILayout.EndHorizontal();
                }
            }
        public void TestFieldQuotedCsv()
        {
            var file = Path.GetTempFileName().Replace(".tmp", ".csv");

            File.WriteAllText(file, @"""State"",""Population"",""Shape""
MI,""10,000,000"",Mitten
CA,""20,000,000"",Sock
KS,""9,000,000"",Rectangle");

            var request = new FileInspectionRequest(file)
            {
                DataTypes = new List <string> {
                    "decimal"
                },
                MinLength = 3
            };
            var fileInformation = FileInformationFactory.Create(request, new TestLogger());
            var actual          = new FieldInspector(new TestLogger()).Inspect(fileInformation, request);

            Assert.AreEqual(3, actual.Count);

            Assert.AreEqual("State", actual[0].Name);
            Assert.AreEqual("Population", actual[1].Name);
            Assert.AreEqual("Shape", actual[2].Name);

            Assert.AreEqual("string", actual[0].Type);
            Assert.AreEqual("decimal", actual[1].Type);
            Assert.AreEqual("string", actual[2].Type);

            Assert.AreEqual('\"', actual[0].QuotedWith);
            Assert.AreEqual('\"', actual[1].QuotedWith);
            Assert.AreEqual('\"', actual[2].QuotedWith);

            Assert.AreEqual("3", actual[0].Length);
            Assert.AreEqual("3", actual[1].Length);
            Assert.AreEqual("10", actual[2].Length);
        }
Beispiel #23
0
 public abstract void Painting(ObjectInspector inspector, FieldInspector fieldInspector);
Beispiel #24
0
 public abstract void Draw(ObjectInspector inspector, FieldInspector fieldInspector);
Beispiel #25
0
 public abstract void SceneHandle(ObjectInspector inspector, FieldInspector fieldInspector);