private static void DrawRectTransform(RectTransform rectTransform) { using (new GUILayout.VerticalScope()) { //TODO: Implement position display like the Unity editor using (new GUILayout.HorizontalScope()) { GUILayout.Label("Local Position", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); NitroxGUILayout.Separator(); rectTransform.localPosition = VectorDrawer.DrawVector3(rectTransform.localPosition, VECTOR_MAX_WIDTH); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Local Rotation", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); NitroxGUILayout.Separator(); rectTransform.localRotation = Quaternion.Euler(VectorDrawer.DrawVector3(rectTransform.localRotation.eulerAngles, VECTOR_MAX_WIDTH)); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Local Scale", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); NitroxGUILayout.Separator(); rectTransform.localScale = VectorDrawer.DrawVector3(rectTransform.localScale, VECTOR_MAX_WIDTH); } GUILayout.Space(20); using (new GUILayout.HorizontalScope()) { GUILayout.Label("Size", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); NitroxGUILayout.Separator(); rectTransform.sizeDelta = VectorDrawer.DrawVector2(rectTransform.sizeDelta, VECTOR_MAX_WIDTH); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Anchor", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); NitroxGUILayout.Separator(); AnchorMode anchorMode = VectorToAnchorMode(rectTransform.anchorMin, rectTransform.anchorMax); if (anchorMode == AnchorMode.NONE) { VectorDrawer.DrawVector2(rectTransform.anchorMin, VECTOR_MAX_WIDTH * 0.5f); VectorDrawer.DrawVector2(rectTransform.anchorMax, VECTOR_MAX_WIDTH * 0.5f); } else { anchorMode = NitroxGUILayout.EnumPopup(anchorMode, VECTOR_MAX_WIDTH); // Vector2[] anchorVectors = AnchorModeToVector(anchorMode); // rectTransform.anchorMin = anchorVectors[0]; // rectTransform.anchorMax = anchorVectors[1]; } } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Pivot", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); NitroxGUILayout.Separator(); rectTransform.pivot = VectorDrawer.DrawVector2(rectTransform.pivot, VECTOR_MAX_WIDTH); } } }
private static void DrawCanvasScaler(CanvasScaler canvasScaler) { if (canvasScaler.GetComponent <Canvas>().renderMode == RenderMode.WorldSpace) { using (new GUILayout.HorizontalScope()) { GUILayout.Label("Dynamic Pixels Per Unit", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); canvasScaler.dynamicPixelsPerUnit = NitroxGUILayout.FloatField(canvasScaler.dynamicPixelsPerUnit); } } else { using (new GUILayout.HorizontalScope()) { GUILayout.Label("UI Scale Mode", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); canvasScaler.uiScaleMode = NitroxGUILayout.EnumPopup(canvasScaler.uiScaleMode); } if (canvasScaler.uiScaleMode == CanvasScaler.ScaleMode.ConstantPixelSize) { using (new GUILayout.HorizontalScope()) { GUILayout.Label("Scale Factor", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); canvasScaler.scaleFactor = NitroxGUILayout.FloatField(canvasScaler.scaleFactor); } } else if (canvasScaler.uiScaleMode == CanvasScaler.ScaleMode.ScaleWithScreenSize) { using (new GUILayout.HorizontalScope()) { GUILayout.Label("Reference Resolution", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); canvasScaler.referenceResolution = VectorDrawer.DrawVector2(canvasScaler.referenceResolution); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Screen Match Mode", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); canvasScaler.screenMatchMode = NitroxGUILayout.EnumPopup(canvasScaler.screenMatchMode); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Match", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); float newMatchValue = NitroxGUILayout.FloatField(canvasScaler.matchWidthOrHeight); canvasScaler.matchWidthOrHeight = Mathf.Max(0, Mathf.Min(newMatchValue, 1)); } } else { using (new GUILayout.HorizontalScope()) { GUILayout.Label("Physical Unit", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); canvasScaler.physicalUnit = NitroxGUILayout.EnumPopup(canvasScaler.physicalUnit); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Fallback Screen DPI", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); canvasScaler.matchWidthOrHeight = NitroxGUILayout.FloatField(canvasScaler.fallbackScreenDPI); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Default Sprite DPI", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); float newDefaultSpriteDPI = NitroxGUILayout.FloatField(canvasScaler.defaultSpriteDPI); canvasScaler.defaultSpriteDPI = Mathf.Max(1, newDefaultSpriteDPI); } } } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Reference Pixels Per Unit", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); canvasScaler.referencePixelsPerUnit = NitroxGUILayout.FloatField(canvasScaler.referencePixelsPerUnit); } }
private static void DrawGridLayoutGroup(GridLayoutGroup gridLayoutGroup) { using (new GUILayout.HorizontalScope()) { GUILayout.Label("Padding", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); Tuple <int, int, int, int> padding = VectorDrawer.DrawInt4(gridLayoutGroup.padding.left, gridLayoutGroup.padding.right, gridLayoutGroup.padding.top, gridLayoutGroup.padding.bottom); gridLayoutGroup.padding.left = padding.Item1; gridLayoutGroup.padding.right = padding.Item2; gridLayoutGroup.padding.top = padding.Item3; gridLayoutGroup.padding.bottom = padding.Item4; } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Cell Size", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); gridLayoutGroup.cellSize = VectorDrawer.DrawVector2(gridLayoutGroup.cellSize); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Spacing", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); gridLayoutGroup.spacing = VectorDrawer.DrawVector2(gridLayoutGroup.spacing); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Start Corner", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); gridLayoutGroup.startCorner = NitroxGUILayout.EnumPopup(gridLayoutGroup.startCorner); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Start Axis", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); gridLayoutGroup.startAxis = NitroxGUILayout.EnumPopup(gridLayoutGroup.startAxis); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Child Alignment", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); gridLayoutGroup.childAlignment = NitroxGUILayout.EnumPopup(gridLayoutGroup.childAlignment); } using (new GUILayout.HorizontalScope()) { GUILayout.Label("Constraint", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); gridLayoutGroup.constraint = NitroxGUILayout.EnumPopup(gridLayoutGroup.constraint); } if (gridLayoutGroup.constraint != GridLayoutGroup.Constraint.Flexible) { using (new GUILayout.HorizontalScope()) { GUILayout.Label("Constraint Count", NitroxGUILayout.DrawerLabel, GUILayout.Width(NitroxGUILayout.DEFAULT_LABEL_WIDTH)); NitroxGUILayout.Separator(); gridLayoutGroup.constraintCount = Math.Max(1, NitroxGUILayout.IntField(gridLayoutGroup.constraintCount)); } } }