예제 #1
0
        private void draw(int id)
        {
            GUI.DragWindow(new Rect(0, 0, 298, 21));
            if (GUIUtils.CloseHelpButtons(window, "Measurements"))
            {
                CloseWindow(); return;
            }
            GUI.Label(new Rect(5, 21, 340, 21), LocalizationManager.instance.current["measurmt_desc"]);

            if (GUI.Button(new Rect(5, 42, 167, 24), LocalizationManager.instance.current["measurmt_dist"]))
            {
                ProceduralObjectsLogic.PlaySound();
                UnityEngine.Object.Destroy(lineRenderer);
                UnityEngine.Object.Destroy(gameObject);
                measureMode = 1;
                Result      = -1f;
                pos0        = Vector3.down;
                pos1        = Vector3.down;
                pos2        = Vector3.down;
            }
            if (GUI.Button(new Rect(178, 42, 167, 24), LocalizationManager.instance.current["measurmt_ang"]))
            {
                ProceduralObjectsLogic.PlaySound();
                UnityEngine.Object.Destroy(lineRenderer);
                UnityEngine.Object.Destroy(gameObject);
                measureMode = 2;
                Result      = -1f;
                pos0        = Vector3.down;
                pos1        = Vector3.down;
                pos2        = Vector3.down;
            }
            bool anythingSelectable = AnythingSelectable();

            switch (measureMode)
            {
            case 1:
                GUI.DrawTexture(new Rect(25, 70, 300, 20), ProceduralObjectsMod.Icons[13]);
                SelectAsPoint(new Rect(4, 90, 120, 20), 0, anythingSelectable);
                SelectAsPoint(new Rect(226, 90, 120, 20), 1, anythingSelectable);
                if (Result != -1f)
                {
                    GUI.Label(new Rect(5, 114, 200, 23), "<size=14>" + Gizmos.ConvertToDistanceUnit(Result).ToString("n2") + ProceduralObjectsMod.distanceUnit + "</size>");
                }
                break;

            case 2:
                GUI.DrawTexture(new Rect(25, 70, 300, 150), ProceduralObjectsMod.Icons[14]);
                SelectAsPoint(new Rect(4, 90, 120, 20), 0, anythingSelectable);
                SelectAsPoint(new Rect(105, 218, 120, 20), 2, anythingSelectable);
                SelectAsPoint(new Rect(226, 90, 120, 20), 1, anythingSelectable);
                if (Result != -1f)
                {
                    GUI.Label(new Rect(5, 240, 200, 23), "<size=14>" + (Result * (ProceduralObjectsMod.AngleUnits.value == 1 ? Mathf.Deg2Rad : 1f)).ToString("n2") + ProceduralObjectsMod.angleUnit + "</size>");
                }
                break;
            }
        }
        protected override void OnToolUpdate()
        {
            base.OnToolUpdate();
            string toolInfo = "";

            switch (ProceduralObjectsLogic.toolAction)
            {
            case ToolAction.none:
                bool clicking = false;
                switch (ProceduralObjectsLogic.axisState)
                {
                case AxisEditionState.none:
                    if (TextCustomizationManager.instance.showWindow && TextCustomizationManager.instance.cursorIsInsideTextureArea)
                    {
                        if (TextCustomizationManager.instance.placingText)
                        {
                            ToolCursor = textCursor;
                        }
                        else if (TextCustomizationManager.instance.placingRect)
                        {
                            ToolCursor = rectCursor;
                        }
                        else
                        {
                            ToolCursor = (CursorInfo)null;
                        }
                    }
                    else
                    {
                        ToolCursor = (CursorInfo)null;
                    }
                    break;

                case AxisEditionState.X:
                case AxisEditionState.Z:
                    ToolCursor = terrainLevel;
                    clicking   = true;
                    break;

                case AxisEditionState.Y:
                    ToolCursor = terrainShift;
                    clicking   = true;
                    break;
                }
                if (Gizmos.registeredString != "")
                {
                    switch (ProceduralObjectsLogic.actionMode)
                    {
                    case 0:
                        toolInfo = Gizmos.registeredString + ProceduralObjectsMod.distanceUnit;
                        break;

                    case 1:
                        toolInfo = "x" + Gizmos.registeredString;
                        break;

                    case 2:
                        toolInfo = Gizmos.registeredString + ProceduralObjectsMod.angleUnit;
                        break;
                    }
                    base.ShowToolInfo(true, toolInfo, toolInfoPos);
                }
                else if (Gizmos.useLineTool)
                {
                    base.ShowToolInfo(true, LocalizationManager.instance.current["line_copy_locked"], toolInfoPos);
                }
                else if (Gizmos.isSnappingPrevMove)
                {
                    base.ShowToolInfo(true, LocalizationManager.instance.current["repeatPrevMov"], toolInfoPos);
                }
                else if (clicking)
                {
                    switch (ProceduralObjectsLogic.actionMode)
                    {
                    case 0:
                        var distance = Vector3.Distance(ProceduralObjectsLogic.instance.currentlyEditingObject.historyEditionBuffer.prevTempPos,
                                                        ProceduralObjectsLogic.instance.currentlyEditingObject.m_position);
                        toolInfo = Gizmos.ConvertToDistanceUnit(distance).ToString("n3") + ProceduralObjectsMod.distanceUnit;
                        break;

                    case 1:
                        toolInfo = "x" + Gizmos.recordingStretch.ToString("n5");
                        break;

                    case 2:
                        toolInfo = (Gizmos.recordingAngle * (ProceduralObjectsMod.AngleUnits.value == 1 ? Mathf.Deg2Rad : 1f)).ToString("n3") + ProceduralObjectsMod.angleUnit;
                        break;
                    }
                    base.ShowToolInfo(true, toolInfo, toolInfoPos);
                }
                else
                {
                    base.ShowToolInfo(false, "", Vector3.zero);
                }
                break;

            case ToolAction.vertices:
                if (TextCustomizationManager.instance.showWindow && TextCustomizationManager.instance.cursorIsInsideTextureArea)
                {
                    if (TextCustomizationManager.instance.placingText)
                    {
                        ToolCursor = textCursor;
                    }
                    else if (TextCustomizationManager.instance.placingRect)
                    {
                        ToolCursor = rectCursor;
                    }
                    else
                    {
                        goto verticesCursorSetup;
                    }
                }
                else
                {
                    goto verticesCursorSetup;
                }
                goto skipVerticesCursorSetup;
verticesCursorSetup:
                switch (ProceduralObjectsLogic.verticesToolType)
                {
                case 0:
                    ToolCursor = moveVertices;
                    break;

                case 1:
                    ToolCursor = rotateVertices;
                    break;

                case 2:
                    ToolCursor = scaleVertices;
                    break;

                case 3:
                    ToolCursor = draw;
                    break;
                }
skipVerticesCursorSetup:
                if (ProceduralObjectsLogic.instance.drawWizardData != null && ProceduralObjectsLogic.verticesToolType == 3)
                {
                    if (ProceduralObjectsLogic.instance.drawWizardData.points == null)
                    {
                        toolInfo = LocalizationManager.instance.current["drawTool_start"];
                    }
                    else
                    {
                        toolInfo = LocalizationManager.instance.current["drawTool_tooltip"];
                    }
                    base.ShowToolInfo(true, toolInfo, toolInfoPos);
                }
                else if (ProceduralObjectsLogic.tabSwitchTimer != 0f)
                {
                    switch (ProceduralObjectsLogic.verticesToolType)
                    {
                    case 0:
                        toolInfo = LocalizationManager.instance.current["position"];
                        break;

                    case 1:
                        toolInfo = LocalizationManager.instance.current["rotation"];
                        break;

                    case 2:
                        toolInfo = LocalizationManager.instance.current["scale_obj"];
                        break;
                    }
                    base.ShowToolInfo(true, toolInfo, toolInfoPos);
                }
                else if (Gizmos.registeredString != "")
                {
                    switch (ProceduralObjectsLogic.verticesToolType)
                    {
                    case 0:
                        toolInfo = Gizmos.registeredString + ProceduralObjectsMod.distanceUnit;
                        break;

                    case 1:
                        toolInfo = Gizmos.registeredString + ProceduralObjectsMod.angleUnit;
                        break;

                    case 2:
                        toolInfo = "x" + Gizmos.registeredString;
                        break;
                    }
                    base.ShowToolInfo(true, toolInfo, toolInfoPos);
                }
                else
                {
                    base.ShowToolInfo(false, "", Vector3.zero);
                }
                break;

            case ToolAction.build:
                ToolCursor = buildCursor;
                base.ShowToolInfo(true, LocalizationManager.instance.current["click_to_place"], ProceduralObjectsLogic.movingWholeRaycast);
                break;
            }
        }
예제 #3
0
        public override void OnActionGUI(Vector2 uiPos)
        {
            var rect = CollisionUI(uiPos);

            if (!ProceduralObjectsMod.UseUINightMode.value)
            {
                GUI.DrawTexture(rect, GUIUtils.bckgTex, ScaleMode.StretchToFill);
            }
            GUI.Box(rect, string.Empty);
            // proj force
            GUI.Label(new Rect(uiPos + new Vector2(2, 2), new Vector2(260, 21)), LocalizationManager.instance.current["project_force"] + " : " + (projectionForce * 100f).ToString() + "%");
            var newProjForce = Mathf.Round(GUI.HorizontalSlider(new Rect(uiPos + new Vector2(5, 22), new Vector2(265, 8)), projectionForce * 40f, 0, 40)) / 40f;

            if (newProjForce != projectionForce)
            {
                projectionForce = newProjForce;
                CalculateProjection();
                ApplyProjection(projectionForce);
            }
            // proj offset
            GUI.Label(new Rect(uiPos + new Vector2(2, 32), new Vector2(260, 21)), LocalizationManager.instance.current["project_offset"] + " : " + (Mathf.Round(Gizmos.ConvertToDistanceUnit(offset * 100f)) / 100f).ToString() + ProceduralObjectsMod.distanceUnit);
            var newOffset = Mathf.Round(GUI.HorizontalSlider(new Rect(uiPos + new Vector2(5, 52), new Vector2(265, 8)), offset * 10f, -30f, 30f)) / 10f;

            if (newOffset != offset)
            {
                offset = newOffset;
                CalculateProjection();
                ApplyProjection(projectionForce);
            }

            // absolute directions
            DrawDirButton(uiPos + new Vector2(2, 64), "X+", Vector3.right);
            DrawDirButton(uiPos + new Vector2(44, 64), "X-", Vector3.left);
            DrawDirButton(uiPos + new Vector2(88, 64), "Y+", Vector3.up);
            DrawDirButton(uiPos + new Vector2(132, 64), "Y-", Vector3.down);
            DrawDirButton(uiPos + new Vector2(176, 64), "Z+", Vector3.forward);
            DrawDirButton(uiPos + new Vector2(220, 64), "Z-", Vector3.back);

            var newCollideNB = GUI.Toggle(new Rect(uiPos + new Vector2(2, 87), new Vector2(250, 20)), collideNetworksBuildings, LocalizationManager.instance.current["project_collideNB"]);

            if (newCollideNB != collideNetworksBuildings)
            {
                collideNetworksBuildings = newCollideNB;
                CalculateProjection();
                ApplyProjection(projectionForce);
            }

            if (GUI.Button(new Rect(uiPos.x + 2, uiPos.y + 109, 64, 22), LocalizationManager.instance.current["ok"]))
            {
                ProceduralObjectsLogic.PlaySound();
                confirmedDone = true;
                ExitAction();
                return;
            }
            if (GUI.Button(new Rect(uiPos.x + 68, uiPos.y + 109, 110, 22), LocalizationManager.instance.current["cancel"]))
            {
                ProceduralObjectsLogic.PlaySound();
                ExitAction();
                return;
            }
        }