private void Swap(DynamicDecalSettings Settings, int IndexA, int IndexB)
        {
            PoolInstance temp = Settings.pools[IndexA];

            Settings.pools[IndexA] = Settings.pools[IndexB];
            Settings.pools[IndexB] = temp;
        }
Esempio n. 2
0
        internal ProjectionPool PoolFromInstance(PoolInstance Instance)
        {
            //Make sure we are initialized
            if (Pools == null)
            {
                Pools = new Dictionary <int, ProjectionPool>();
            }

            ProjectionPool pool;

            if (!Pools.TryGetValue(Instance.id, out pool))
            {
                pool = new ProjectionPool(Instance);
                Pools.Add(Instance.id, pool);
            }
            return(pool);
        }
        private void PoolItem(Rect Area, DynamicDecalSettings Settings, PoolInstance Instance, int Index)
        {
            float collumnWidth = Area.width / 3;
            float buttonSize   = 16;

            //Background
            EditorGUI.DrawRect(Area, (Index % 2 != 0) ? LlockhamEditorUtility.MidgroundColor : LlockhamEditorUtility.ForegroundColor);
            GUI.BeginGroup(Area);

            //Title
            if (Index == 0)
            {
                GUI.Label(new Rect(4, 2, collumnWidth, 16), "Default", LlockhamEditorUtility.MiniLabel);
                if (Instance.title != "Default")
                {
                    Instance.title = "Default";
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                string title = EditorGUI.TextField(new Rect(4, 2, collumnWidth, 16), Instance.title, LlockhamEditorUtility.MiniLabel);
                if (EditorGUI.EndChangeCheck())
                {
                    //Record state for undo
                    Undo.RecordObject(Settings, "Rename pool");

                    //Rename pool
                    Instance.title = title;
                }
            }

            //Limit
            EditorGUI.BeginChangeCheck();
            int limit = EditorGUI.IntField(new Rect(4 + collumnWidth, 2, collumnWidth, 16), Instance.limits[qualitySetting]);

            if (EditorGUI.EndChangeCheck())
            {
                //Record state for undo
                Undo.RecordObject(Settings, "Resize pool");

                //Adjust pool size
                Instance.limits[qualitySetting] = limit;
            }

            //Utility Buttons
            Rect utilityRect = new Rect(Area.width - (buttonSize * 3 + 16) - 12, 2, (buttonSize * 3 + 16), 16);

            GUI.BeginGroup(utilityRect);

            //Cache GUI.enabled
            bool GUIEnabled = GUI.enabled;

            //Up
            if (Index < 2)
            {
                GUI.enabled = false;
            }
            if (GUI.Button(new Rect(4, (utilityRect.height - buttonSize) / 2, buttonSize, buttonSize), "↑"))
            {
                //Record state for undo
                Undo.RecordObject(Settings, "Pool Up");

                //Move pool up
                Swap(Settings, Index, Index - 1);
            }
            //Restore GUI state
            GUI.enabled = GUIEnabled;

            //Down
            if (Index == 0 || Index == Settings.pools.Length - 1)
            {
                GUI.enabled = false;
            }
            if (GUI.Button(new Rect(buttonSize + 8, (utilityRect.height - buttonSize) / 2, buttonSize, buttonSize), "↓"))
            {
                //Record state for undo
                Undo.RecordObject(Settings, "Pool Down");

                //Move pool down
                Swap(Settings, Index, Index + 1);
            }
            //Restore GUI state
            GUI.enabled = GUIEnabled;

            //Remove
            if (Index == 0)
            {
                GUI.enabled = false;
            }
            if (GUI.Button(new Rect(2 * buttonSize + 12, (utilityRect.height - buttonSize) / 2, buttonSize, buttonSize), "-"))
            {
                //Record state for undo
                Undo.RecordObject(Settings, "Pool Down");

                //Remove pool
                RemoveAt(Settings, Index);
            }
            //Restore GUI state
            GUI.enabled = GUIEnabled;

            GUI.EndGroup();
            GUI.EndGroup();
        }
 //Constructor
 public ProjectionPool(PoolInstance Instance)
 {
     instance = Instance;
 }