Ejemplo n.º 1
0
        void SyncToggleList(PrefsGUISync sync, List <PrefsParam> prefsList)
        {
            if (sync != null)
            {
                var keys          = prefsList.Select(p => p.key).ToList();
                var syncKeys      = keys.Except(sync._ignoreKeys);
                var syncKeysCount = syncKeys.Count();
                var isSync        = syncKeys.Any();
                var mixed         = syncKeysCount != 0 && syncKeysCount != prefsList.Count;

                if (isSync != GUILayout.Toggle(isSync, "", mixed ? "ToggleMixed" : GUI.skin.toggle))
                {
                    isSync = !isSync;
                    Undo.RecordObject(sync, "Change PrefsGUIs sync flag");
                    EditorUtility.SetDirty(sync);

                    if (!isSync)
                    {
                        sync._ignoreKeys.AddRange(syncKeys);
                    }
                    else
                    {
                        keys.ForEach(k => sync._ignoreKeys.Remove(k));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void LabelWithEditPrefix(PrefsGUISync sync, string label, Object target, List <PrefsParam> prefsList)
        {
            using (var h = new GUILayout.HorizontalScope())
            {
                SyncToggleList(sync, prefsList);
                GUILayout.Label(label);

                const char separator = '.';
                var        prefix    = prefsList.Select(p => p.key.Split(separator)).Where(sepKeys => sepKeys.Length > 1).FirstOrDefault()?.First();

                GUILayout.Label("KeyPrefix:");

                var prefixNew = GUILayout.TextField(prefix, GUILayout.MinWidth(100f));
                if (prefix != prefixNew)
                {
                    Undo.RecordObject(target, "Change PrefsGUI Prefix");
                    EditorUtility.SetDirty(target);

                    var prefixWithSeparator = string.IsNullOrEmpty(prefixNew) ? "" : prefixNew + separator;
                    prefsList.ForEach(p =>
                    {
                        p.key = prefixWithSeparator + p.key.Split(separator).Last();
                    });
                }

                GUILayout.FlexibleSpace();
            }
        }
Ejemplo n.º 3
0
        void SyncToggle(PrefsGUISync sync, PrefsParam prefs)
        {
            if (sync != null)
            {
                var key    = prefs.key;
                var isSync = !sync._ignoreKeys.Contains(key);

                if (isSync != GUILayout.Toggle(isSync, "", GUILayout.Width(16f)))
                {
                    Undo.RecordObject(sync, "Change PrefsGUI sync flag");
                    EditorUtility.SetDirty(sync);

                    if (isSync)
                    {
                        sync._ignoreKeys.Add(key);
                    }
                    else
                    {
                        sync._ignoreKeys.Remove(key);
                    }
                }
            }
        }