예제 #1
0
        public float ResizeHandle(Rect windowPosition, float minSize, float minRemainingSize, float resizerHeight, Rect dragRect)
        {
            if (Mathf.Abs(this.m_CachedPref) < minSize)
            {
                this.m_CachedPref = minSize * Mathf.Sign(this.m_CachedPref);
            }
            float num      = windowPosition.height - minRemainingSize;
            bool  flag     = GUIUtility.hotControl == this.id;
            float num2     = (!flag) ? Mathf.Max(0f, this.m_CachedPref) : PreviewResizer.s_DraggedPreviewSize;
            bool  flag2    = this.m_CachedPref > 0f;
            float num3     = Mathf.Abs(this.m_CachedPref);
            Rect  position = new Rect(0f, windowPosition.height - num2 - resizerHeight, windowPosition.width, resizerHeight);

            if (dragRect.width != 0f)
            {
                position.x     = dragRect.x;
                position.width = dragRect.width;
            }
            bool flag3 = flag2;

            num2 = -PreviewResizer.PixelPreciseCollapsibleSlider(this.id, position, -num2, -num, 0f, ref flag2);
            num2 = Mathf.Min(num2, num);
            flag = (GUIUtility.hotControl == this.id);
            if (flag)
            {
                PreviewResizer.s_DraggedPreviewSize = num2;
            }
            if (num2 < minSize)
            {
                num2 = ((num2 >= minSize * 0.5f) ? minSize : 0f);
            }
            if (flag2 != flag3)
            {
                num2 = ((!flag2) ? 0f : num3);
            }
            flag2 = (num2 >= minSize / 2f);
            if (GUIUtility.hotControl == 0)
            {
                if (num2 > 0f)
                {
                    num3 = num2;
                }
                float num4 = num3 * (float)((!flag2) ? -1 : 1);
                if (num4 != this.m_CachedPref)
                {
                    this.m_CachedPref = num4;
                    EditorPrefs.SetFloat(this.m_PrefName, this.m_CachedPref);
                }
            }
            PreviewResizer.s_CachedPreviewSizeWhileDragging = num2;
            return(num2);
        }
예제 #2
0
        public float ResizeHandle(Rect windowPosition, float minSize, float minRemainingSize, float resizerHeight, Rect dragRect)
        {
            if ((double)Mathf.Abs(this.m_CachedPref) < (double)minSize)
            {
                this.m_CachedPref = minSize * Mathf.Sign(this.m_CachedPref);
            }
            float b        = windowPosition.height - minRemainingSize;
            float num1     = GUIUtility.hotControl != this.id ? Mathf.Max(0.0f, this.m_CachedPref) : PreviewResizer.s_DraggedPreviewSize;
            bool  expanded = (double)this.m_CachedPref > 0.0;
            float num2     = Mathf.Abs(this.m_CachedPref);
            Rect  position = new Rect(0.0f, windowPosition.height - num1 - resizerHeight, windowPosition.width, resizerHeight);

            if ((double)dragRect.width != 0.0)
            {
                position.x     = dragRect.x;
                position.width = dragRect.width;
            }
            bool  flag1 = expanded;
            float num3  = Mathf.Min(-PreviewResizer.PixelPreciseCollapsibleSlider(this.id, position, -num1, -b, 0.0f, ref expanded), b);

            if (GUIUtility.hotControl == this.id)
            {
                PreviewResizer.s_DraggedPreviewSize = num3;
            }
            if ((double)num3 < (double)minSize)
            {
                num3 = (double)num3 >= (double)minSize * 0.5 ? minSize : 0.0f;
            }
            if (expanded != flag1)
            {
                num3 = !expanded ? 0.0f : num2;
            }
            bool flag2 = (double)num3 >= (double)minSize / 2.0;

            if (GUIUtility.hotControl == 0)
            {
                if ((double)num3 > 0.0)
                {
                    num2 = num3;
                }
                float num4 = num2 * (!flag2 ? -1f : 1f);
                if ((double)num4 != (double)this.m_CachedPref)
                {
                    this.m_CachedPref = num4;
                    EditorPrefs.SetFloat(this.m_PrefName, this.m_CachedPref);
                }
            }
            PreviewResizer.s_CachedPreviewSizeWhileDragging = num3;
            return(num3);
        }
예제 #3
0
        public void OnEnable()
        {
            instances.Add(this);
            if (clipboardView == null)
            {
                clipboardView           = CreateInstance <GridPaintPaletteClipboard>();
                clipboardView.owner     = this;
                clipboardView.hideFlags = HideFlags.HideAndDontSave;
                clipboardView.unlocked  = false;
            }

            if (m_PaintableSceneViewGrid == null)
            {
                m_PaintableSceneViewGrid           = CreateInstance <PaintableSceneViewGrid>();
                m_PaintableSceneViewGrid.hideFlags = HideFlags.HideAndDontSave;
            }

            GridPaletteBrushes.FlushCache();
            EditMode.editModeStarted           += OnEditModeStart;
            EditMode.editModeEnded             += OnEditModeEnd;
            GridSelection.gridSelectionChanged += OnGridSelectionChanged;
            GridPaintingState.RegisterPainterInterest(this);
            GridPaintingState.scenePaintTargetChanged += OnScenePaintTargetChanged;
            GridPaintingState.brushChanged            += OnBrushChanged;
            SceneView.onSceneGUIDelegate        += OnSceneViewGUI;
            PrefabUtility.prefabInstanceUpdated += PrefabInstanceUpdated;

            AssetPreview.SetPreviewTextureCacheSize(256, GetInstanceID());
            wantsMouseMove             = true;
            wantsMouseEnterLeaveWindow = true;

            if (m_PreviewResizer == null)
            {
                m_PreviewResizer = new PreviewResizer();
                m_PreviewResizer.Init("TilemapBrushInspector");
            }

            minSize = new Vector2(240f, 200f);

            if (palette == null && TilemapEditorUserSettings.lastUsedPalette != null && GridPalettes.palettes.Contains(TilemapEditorUserSettings.lastUsedPalette))
            {
                palette = TilemapEditorUserSettings.lastUsedPalette;
            }

            Tools.onToolChanged += ToolChanged;

            ShortcutIntegration.instance.contextManager.RegisterToolContext(m_ShortcutContext);
        }
예제 #4
0
 public LightingWindow()
 {
     int[] numArray1 = new int[3];
     numArray1[1] = 1;
     numArray1[2] = 2;
     this.kConcurrentJobsTypeValues = numArray1;
     this.kButtonWidth = 120f;
     this.kModeStrings = new GUIContent[] { new GUIContent("Non-Directional"), new GUIContent("Directional"), new GUIContent("Directional Specular") };
     int[] numArray2 = new int[3];
     numArray2[1]              = 1;
     numArray2[2]              = 2;
     this.kModeValues          = numArray2;
     this.kMaxAtlasSizeStrings = new GUIContent[] { new GUIContent("32"), new GUIContent("64"), new GUIContent("128"), new GUIContent("256"), new GUIContent("512"), new GUIContent("1024"), new GUIContent("2048"), new GUIContent("4096") };
     this.kMaxAtlasSizeValues  = new int[] { 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000 };
     this.m_Mode                   = Mode.BakeSettings;
     this.m_ScrollPosition         = Vector2.zero;
     this.m_ShowIndirectResolution = new AnimBool();
     this.m_PreviewResizer         = new PreviewResizer();
 }
예제 #5
0
 public LightingWindow()
 {
     int[] numArray1 = new int[3];
     numArray1[1] = 1;
     numArray1[2] = 2;
     this.kConcurrentJobsTypeValues = numArray1;
     this.kButtonWidth = 120f;
     this.kModeStrings = new GUIContent[] { new GUIContent("Non-Directional"), new GUIContent("Directional"), new GUIContent("Directional Specular (deprecated)") };
     int[] numArray2 = new int[3];
     numArray2[1] = 1;
     numArray2[2] = 2;
     this.kModeValues = numArray2;
     this.kMaxAtlasSizeStrings = new GUIContent[] { new GUIContent("32"), new GUIContent("64"), new GUIContent("128"), new GUIContent("256"), new GUIContent("512"), new GUIContent("1024"), new GUIContent("2048"), new GUIContent("4096") };
     this.kMaxAtlasSizeValues = new int[] { 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000 };
     this.m_Mode = Mode.BakeSettings;
     this.m_ScrollPosition = Vector2.zero;
     this.m_ShowIndirectResolution = new AnimBool();
     this.m_ShowDevOptions = false;
     this.m_PreviewResizer = new PreviewResizer();
     this.m_ToolbarPadding = -1f;
 }
예제 #6
0
 public void OnEnable()
 {
     GridPaintPaletteWindow.instances.Add(this);
     if (this.clipboardView == null)
     {
         this.clipboardView           = ScriptableObject.CreateInstance <GridPaintPaletteClipboard>();
         this.clipboardView.owner     = this;
         this.clipboardView.hideFlags = HideFlags.HideAndDontSave;
         this.clipboardView.unlocked  = false;
     }
     if (this.m_PaintableSceneViewGrid == null)
     {
         this.m_PaintableSceneViewGrid           = ScriptableObject.CreateInstance <PaintableSceneViewGrid>();
         this.m_PaintableSceneViewGrid.hideFlags = HideFlags.HideAndDontSave;
     }
     GridPaletteBrushes.FlushCache();
     EditorApplication.globalEventHandler = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.globalEventHandler, new EditorApplication.CallbackFunction(this.HotkeyHandler));
     EditMode.editModeStarted            += new Action <IToolModeOwner, EditMode.SceneViewEditMode>(this.OnEditModeStart);
     EditMode.editModeEnded             += new Action <IToolModeOwner>(this.OnEditModeEnd);
     GridSelection.gridSelectionChanged += new Action(this.OnGridSelectionChanged);
     GridPaintingState.RegisterPainterInterest(this);
     GridPaintingState.scenePaintTargetChanged += new Action <GameObject>(this.OnScenePaintTargetChanged);
     GridPaintingState.brushChanged            += new Action <GridBrushBase>(this.OnBrushChanged);
     SceneView.onSceneGUIDelegate        = (SceneView.OnSceneFunc)Delegate.Combine(SceneView.onSceneGUIDelegate, new SceneView.OnSceneFunc(this.OnSceneViewGUI));
     PrefabUtility.prefabInstanceUpdated = (PrefabUtility.PrefabInstanceUpdated)Delegate.Combine(PrefabUtility.prefabInstanceUpdated, new PrefabUtility.PrefabInstanceUpdated(this.PrefabInstanceUpdated));
     AssetPreview.SetPreviewTextureCacheSize(256, base.GetInstanceID());
     base.wantsMouseMove             = true;
     base.wantsMouseEnterLeaveWindow = true;
     if (this.m_PreviewResizer == null)
     {
         this.m_PreviewResizer = new PreviewResizer();
         this.m_PreviewResizer.Init("TilemapBrushInspector");
     }
     base.minSize = new Vector2(240f, 200f);
     if (this.palette == null && TilemapEditorUserSettings.lastUsedPalette != null && GridPalettes.palettes.Contains(TilemapEditorUserSettings.lastUsedPalette))
     {
         this.palette = TilemapEditorUserSettings.lastUsedPalette;
     }
     Tools.onToolChanged = (Tools.OnToolChangedFunc)Delegate.Combine(Tools.onToolChanged, new Tools.OnToolChangedFunc(this.ToolChanged));
 }