示例#1
0
        public EditorPrefsValue IdentifiersField(EditorPrefsValue value)
        {
            string[] identifiers;
            identifiers = m_Reference.Identifiers;

            BitArray bitArray;

            bitArray = new BitArray(
                identifiers
                .Select(identifier => System.Array.IndexOf(value.identifiers, identifier) != -1)
                .ToArray()
                );

            int[] intArray;
            intArray = new int[] {
                -1
            };

            bitArray.CopyTo(intArray, 0);
            intArray[0] = EditorGUILayout.MaskField("Identifiers", intArray[0], identifiers);
            bitArray    = new BitArray(intArray);

            value.identifiers = (
                identifiers
                .Select((identifier, index) => { return(bitArray[index] ? identifier : null); })
                .Where(identifier => !string.IsNullOrEmpty(identifier))
                .ToArray()
                );

            return(value);
        }
示例#2
0
        public static EditorPrefsValue GetEditorPrefsValue(LocalizedStringReference reference)
        {
            EditorPrefsValue value = JsonUtility.FromJson <EditorPrefsValue>(
                EditorPrefs.GetString(
                    GetEditorPrefsKey(reference),
                    JsonUtility.ToJson(default(EditorPrefsValue))
                    )
                );

            if (value.identifiers == null)
            {
                value.identifiers = reference.Identifiers;
            }
            return(value);
        }
示例#3
0
        public EditorPrefsValue PathField(EditorPrefsValue value)
        {
            GUIStyle defaultStyle;

            defaultStyle = new GUIStyle(EditorStyles.textField);

            GUIStyle errorStyle;

            errorStyle = new GUIStyle(defaultStyle);
            errorStyle.active.textColor  = Color.red;
            errorStyle.focused.textColor = Color.red;
            errorStyle.hover.textColor   = Color.red;
            errorStyle.normal.textColor  = Color.red;

            EditorGUILayout.BeginHorizontal();
            value.path = EditorGUILayout.TextField("File", value.path, value.HasValidPath ? defaultStyle : errorStyle);
            if (GUILayout.Button("...", EditorStyles.miniButton, GUILayout.Width(30)))
            {
                EditorPrefsValue oldValue;
                oldValue = value;

                EditorPrefsValue newValue;
                newValue      = value;
                newValue.path = EditorUtility.OpenFilePanel(
                    "Choose Path",
                    value.HasValidPath ? Path.GetDirectoryName(value.path) : string.Empty,
                    "csv"
                    );

                ShowAuxWindow();
                value = newValue.HasValidPath ? newValue : oldValue;
            }
            EditorGUILayout.EndHorizontal();

            return(value);
        }
示例#4
0
 public static void SetEditorPrefsValue(LocalizedStringReference reference, EditorPrefsValue value)
 {
     EditorPrefs.SetString(GetEditorPrefsKey(reference), JsonUtility.ToJson(value));
 }