public void CreateComponentSettings() { componentSettings = new List<PPComponentSetting>(); Component[] components = GameObj.GetComponents(typeof(Component)); foreach (Component c in components) { PPComponentSetting setting = new PPComponentSetting(c); if (PPLocalStorageManager.IsTypeDefaulted(c.GetType())) { setting.IsSavingSettings = true; } componentSettings.Add(setting); } }
public static void SetPersistanceForAllExistingContextObjects(string typeName, bool isSaveSetting) { foreach (PPCurrentContext context in allContexts.Where(c => c.GameObj != null)) { PPComponentSetting componentSetting = context.GameObjectSetting.ComponentSettings.FirstOrDefault(cs => cs.ComponentName == typeName); if (componentSetting != null) { componentSetting.IsSavingSettings = isSaveSetting; PPCurrentContext currentContext = currentContexts.FirstOrDefault(c => c.GameObj == context.GameObj); // If current context is changed and the PlayModePersist panel is open, update the checkboxes if (currentContext != null && currentContext.GameObjectSetting.Expanded) { EditorUtility.SetDirty(context.GameObj); } } } }
public void CreateComponentSettings() { componentSettings = new List <PPComponentSetting>(); Component[] components = GameObj.GetComponents(typeof(Component)); foreach (Component c in components) { PPComponentSetting setting = new PPComponentSetting(c); if (c != null) { if (PPLocalStorageManager.IsTypeDefaulted(c.GetType())) { setting.IsSavingSettings = true; } } componentSettings.Add(setting); } }
private void DrawControls() { PPGOSetting firstSetting = currentContexts.First().GameObjectSetting; EditorGUILayout.BeginVertical("box", GUILayout.ExpandWidth(true)); GUILayout.Label("PlayModePersist"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("", GUILayout.Width(150f)); if (firstSetting.ComponentSettings.Any(s => !s.IsSavingSettings)) { currentContexts.ForEach(c => c.GameObjectSetting.SaveAll = false); } bool wasSaveAll = firstSetting.SaveAll; bool saveAll = GUILayout.Toggle(wasSaveAll, "Save All"); currentContexts.ForEach(c => c.GameObjectSetting.SaveAll = saveAll); EditorGUILayout.EndHorizontal(); GUILayout.Box("", GUILayout.Height(1f), GUILayout.ExpandWidth(true)); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); if (firstSetting.SaveAll && !wasSaveAll) { currentContexts.ForEach(c => c.GameObjectSetting.ComponentSettings.ForEach(cs => cs.IsSavingSettings = true)); } else if (!firstSetting.SaveAll && wasSaveAll) { currentContexts.ForEach(c => c.GameObjectSetting.ComponentSettings.ForEach(cs => cs.IsSavingSettings = false)); } IEnumerable <IGrouping <string, PPComponentSetting> > componentGroups = currentContexts .SelectMany(c => c.GameObjectSetting.ComponentSettings) .GroupBy(cs => cs.ComponentName); foreach (IGrouping <string, PPComponentSetting> componentGroup in componentGroups) { PPComponentSetting firstComponentSetting = componentGroup.FirstOrDefault(c => !c.IsSavingSettings) ?? componentGroup.First(); EditorGUILayout.BeginHorizontal(); int count = componentGroup.Count(); if (count > 1) { GUILayout.Label(componentGroup.Key + " (" + count + ")", GUILayout.Width(150f)); } else { GUILayout.Label(componentGroup.Key, GUILayout.Width(150f)); } #if (UNITY_2_6 || UNITY_2_6_1 || UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4) #else EditorGUI.showMixedValue = !componentGroup.All(c => c.IsSavingSettings == firstComponentSetting.IsSavingSettings); #endif bool isSavingSettings = GUILayout.Toggle(firstComponentSetting.IsSavingSettings, "Save"); if (isSavingSettings != firstComponentSetting.IsSavingSettings) { foreach (PPComponentSetting setting in componentGroup) { setting.IsSavingSettings = isSavingSettings; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }