void BuildTexture()
        {
            if(Application.isPlaying)
            {
                if (resolutionType == Type.CustomResolution)
                {
                    customResolution.x = Mathf.Max(1, customResolution.x);
                    customResolution.x = Mathf.Min(Screen.width * 4, customResolution.x);
                    customResolution.y = Mathf.Max(1, customResolution.y);
                    customResolution.y = Mathf.Min(Screen.height * 4, customResolution.y);
                    customTexture = new RenderTexture(customResolution.x, customResolution.y, 32);
                }
                else if (resolutionType == Type.ScreenResolutionMultiplier)
                {
                    screenResolutionMultiplier = Mathf.Max(0, screenResolutionMultiplier);
                    screenResolutionMultiplier = Mathf.Min(4, screenResolutionMultiplier);
                    int width = Mathf.Max(1, Mathf.FloorToInt(screenResolutionMultiplier * Screen.width));
                    int height = Mathf.Max(1, Mathf.FloorToInt(screenResolutionMultiplier * Screen.height));
                    customTexture = new RenderTexture(width, height, 32);
                }
                customTexture.filterMode = filterMode;
                customTexture.name = "Custom Render Resolution Texture";
                customTexture.Create();
                targetCamera.targetTexture = customTexture;
                subScript.customTexture = customTexture;

                customResolutionLast = customResolution;
                filterModeLast = filterMode;
                screenResolutionMultiplierLast = screenResolutionMultiplier;
            }
        }
示例#2
0
文件: Int2.cs 项目: Evellex/Eldrinth
        public bool Equals(Int2 p)
        {
            if ((object)p == null)
                return false;

            return (x == p.x) && (y == p.y);
        }
        private void UpdatePickerCoordinates()
        {
            Int2 mousePosition = new Int2();

            if (Event.current.type == EventType.mouseDown)
            {
                if (pickerRect.Contains(Event.current.mousePosition))
                {
                    sliderOutOfDate = true;
                    selectionMode = SelectionMode.Picker;
                }
                if (sliderRect.Contains(Event.current.mousePosition))
                {
                    pickerOutOfDate = true;
                    selectionMode = SelectionMode.Slider;
                }
                if (sliderRect.Contains(Event.current.mousePosition))
                {
                    pickerOutOfDate = true;
                    selectionMode = SelectionMode.Slider;
                }
                for (int i = 0; i < altSliders; ++i)
                {
                    if (sliderGroupRect[i].Contains(Event.current.mousePosition))
                    {
                        if (i < 3)
                        {
                            sliderOutOfDate = true;
                            if (i == (int)sliderAxis)
                                pickerOutOfDate = true;
                        }
                        selectionMode = (SelectionMode)i;
                    }
                }
            }

            if ((Event.current.type == EventType.mouseDown || Event.current.type == EventType.mouseDrag) && selectionMode != SelectionMode.None)
            {
                mousePosition = (Int2)Event.current.mousePosition;
                if (selectionMode == SelectionMode.Picker)
                {
                    mousePosition -= new Int2((int)pickerRect.xMin, (int)pickerRect.yMin);
                    pickerCoords.x = mousePosition.x;
                    pickerCoords.y = (textureSize - 1) - mousePosition.y;
                    sliderOutOfDate = true;
                }
                else if (selectionMode == SelectionMode.Slider)
                {
                    mousePosition -= new Int2((int)sliderRect.xMin, (int)sliderRect.yMin);
                    pickerCoords.z = textureSize - mousePosition.y;
                    pickerOutOfDate = true;
                }
                else
                {
                    int sliderIndex = ((int)selectionMode);
                    mousePosition -= new Int2((int)sliderGroupRect[sliderIndex].xMin, (int)sliderGroupRect[sliderIndex].yMin);
                    pickerCoords[sliderIndex] = mousePosition.x;
                    if (sliderIndex < 3)
                    {
                        sliderOutOfDate = true;
                        if (sliderIndex == (int)sliderAxis)
                            pickerOutOfDate = true;
                    }
                }
                pickerCoords = MathfExt.Clamp(pickerCoords, 0, textureSize - 1);
            }

            if (Event.current.type == EventType.mouseUp)
                selectionMode = SelectionMode.None;
        }