Example #1
0
    private void DrawTransform(Transform transform)
    {
        using (new GUILayout.VerticalScope())
        {
            if (showGlobal)
            {
                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Label("Global Position", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH));
                    NitroxGUILayout.Separator();
                    VectorDrawer.DrawVector3(transform.position, VECTOR_MAX_WIDTH);
                }

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Label("Global Rotation", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH));
                    NitroxGUILayout.Separator();
                    VectorDrawer.DrawVector3(transform.rotation.eulerAngles, VECTOR_MAX_WIDTH);
                }

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Label("Lossy Scale", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH));
                    NitroxGUILayout.Separator();
                    VectorDrawer.DrawVector3(transform.lossyScale, VECTOR_MAX_WIDTH);
                }
            }
            else
            {
                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Label("Local  Position", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH));
                    NitroxGUILayout.Separator();
                    transform.localPosition = VectorDrawer.DrawVector3(transform.localPosition, VECTOR_MAX_WIDTH);
                }

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Label("Local  Rotation", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH));
                    NitroxGUILayout.Separator();
                    transform.localRotation = Quaternion.Euler(VectorDrawer.DrawVector3(transform.localRotation.eulerAngles, VECTOR_MAX_WIDTH));
                }

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Label("Local  Scale", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH));
                    NitroxGUILayout.Separator();
                    transform.localScale = VectorDrawer.DrawVector3(transform.localScale, VECTOR_MAX_WIDTH);
                }
            }

            GUILayout.Space(5);

            if (GUILayout.Button("Toggle Local/Global", GUILayout.MaxWidth(125)))
            {
                showGlobal = !showGlobal;
            }
        }
    }
Example #2
0
    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);
            }
        }
    }