Exemplo n.º 1
0
    public void SetContext(Object target)
    {
        GameObj = ((Transform)target).gameObject;

        if (null == GameObjectSetting)
        {
            GameObjectSetting = GetStoredGameObjectSetting();
        }
    }
Exemplo n.º 2
0
    public void SetContext(Object target)
    {
        GameObj = ((Transform)target).gameObject;

        if (null == GameObjectSetting)
        {
            GameObjectSetting = GetStoredGameObjectSetting();
        }
    }
Exemplo n.º 3
0
    private PPGOSetting GetStoredGameObjectSetting()
    {
        PPGOSetting setting = null;

        if (persistentSettings.ContainsKey(GameObj))
        {
            setting = persistentSettings[GameObj];
        }
        else
        {
            setting = new PPGOSetting(GameObj);
            persistentSettings.Add(GameObj, setting);
        }

        return setting;
    }
Exemplo n.º 4
0
    private PPGOSetting GetStoredGameObjectSetting()
    {
        PPGOSetting setting = null;

        if (persistentSettings.ContainsKey(GameObj))
        {
            setting = persistentSettings[GameObj];
        }
        else
        {
            setting = new PPGOSetting(GameObj);
            persistentSettings.Add(GameObj, setting);
        }

        return(setting);
    }
Exemplo n.º 5
0
    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();
    }