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); }
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); }
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); }
public static void SetEditorPrefsValue(LocalizedStringReference reference, EditorPrefsValue value) { EditorPrefs.SetString(GetEditorPrefsKey(reference), JsonUtility.ToJson(value)); }