Пример #1
0
        public void addData()
        {
            DSDataField newData = new DSDataField();

            newData.name = "DataSet" + _datas.Count;
            _datas.Add(newData);
        }
Пример #2
0
        private void drawDataField(DSDataField data)
        {
            for (int i = 0; i < data.fields.Count; i++)
            {
                try {
                    GUILayout.BeginHorizontal();
                    data.fields [i].name = GUILayout.TextField(data.fields [i].name, GUILayout.Width(80f));
                    DSDataType dataType = data.fields [i].type;
                    dataType = (DSDataType)EditorGUILayout.EnumPopup(dataType, GUILayout.Width(50f));
                    data.updateFieldType(i, dataType);
                    switch (data.fields [i].type)
                    {
                    case DSDataType.Bool:
                        GUILayout.Space(70f);
                        DSBool boolField = (DSBool)data.fields[i];
                        boolField.value = EditorGUILayout.Toggle(boolField.value);
                        break;

                    case DSDataType.Float:
                        DSFloat floatField = (DSFloat)data.fields[i];
                        GUILayout.Label("Random", GUILayout.Width(50f));
                        floatField.isRandom = EditorGUILayout.Toggle(floatField.isRandom, GUILayout.Width(20f));
                        if (floatField.isRandom)
                        {
                            floatField.minValue = EditorGUILayout.FloatField(floatField.minValue, GUILayout.Width(50f));
                            GUILayout.Label(" -", GUILayout.Width(20f));
                            floatField.maxValue = EditorGUILayout.FloatField(floatField.maxValue, GUILayout.Width(50f));
                        }
                        else
                        {
                            floatField.value = EditorGUILayout.FloatField(floatField.value, GUILayout.Width(50f));
                        }
                        break;

                    case DSDataType.Int:
                        DSInt intField = (DSInt)data.fields[i];
                        GUILayout.Label("Random", GUILayout.Width(50f));
                        intField.isRandom = EditorGUILayout.Toggle(intField.isRandom, GUILayout.Width(20f));
                        if (intField.isRandom)
                        {
                            intField.minValue = EditorGUILayout.IntField(intField.minValue, GUILayout.Width(50f));
                            GUILayout.Label(" -", GUILayout.Width(20f));
                            intField.maxValue = EditorGUILayout.IntField(intField.maxValue, GUILayout.Width(50f));
                        }
                        else
                        {
                            intField.value = EditorGUILayout.IntField(intField.value, GUILayout.Width(50f));
                        }
                        break;

                    case DSDataType.String:
                        DSString stringField = (DSString)data.fields[i];
                        if (string.IsNullOrEmpty(stringField.value))
                        {
                            stringField.value = "";
                        }
                        stringField.value = GUILayout.TextField(stringField.value);
                        break;
                    }
                    if (GUILayout.Button("-", GUILayout.Width(20)))
                    {
                        data.removeField(i);
                    }
                    GUILayout.EndHorizontal();
                }
                catch (ArgumentOutOfRangeException ex) {
                    // do nothing
                }
                catch (Exception ex) {
                    Debug.Log(ex.Message);
                }
            }
        }