Beispiel #1
0
        public static void AddButton(DebugButtonPanel btnPanel, string btnLabel, Action onClickFunction, out GameObject debugBtnObj)
        {
            debugBtnObj = null;
            if (LC_Utils.IsBuildForProduction())
            {
                return;
            }

            Vector3 btnPos = btnPanel.transform.position;

            btnPos += btnPanel.transform.up * (btnPanel.ButtonQuantity * LC_Utils.GetDefaultButtonSize().y);

            if (btnPanel.ButtonQuantity != 0)
            {
                btnPos += btnPanel.transform.up * btnPanel.ButtonQuantity * LC_Utils.GetDefaultButtonPanelOffset();
            }

            GameObject newBtn = LC_Debug.CreateDebugButton(btnLabel, btnPos, onClickFunction, false);

            newBtn.transform.rotation = btnPanel.transform.rotation;
            newBtn.transform.parent   = btnPanel.transform;

            btnPanel.ButtonQuantity++;
            debugBtnObj = newBtn;
        }
 public static GameObject CreateButtonPanel(Transform parent, Vector3 position)
 {
     if (LC_Utils.IsBuildForProduction())
     {
         return(LC_Utils.GetDeafultEmptyObject()); // Do nothing
     }
     return(LC_GraphicsDebugUtils.CreateButtonPanel(parent, position));
 }
 public static GameObject CreateDebugButton(Transform parent, string btnLabel, Vector3 position, Action onClickFunction, bool rotateToCamera = true)
 {
     if (LC_Utils.IsBuildForProduction())
     {
         return(LC_Utils.GetDeafultEmptyObject()); // Do nothing
     }
     return(LC_GraphicsDebugUtils.CreateDebugButton(parent, btnLabel, position, onClickFunction, rotateToCamera));
 }
 public static GameObject CreateWorldText(Transform parent, string text, Vector3 localPosition, int fontSize, Color color, TextAnchor textAnchor, TextAlignment textAlignment, int sortingOrder)
 {
     if (LC_Utils.IsBuildForProduction())
     {
         return(LC_Utils.GetDeafultEmptyObject()); // Do nothing
     }
     return(LC_GraphicsDebugUtils.CreateWorldText(parent, text, localPosition, fontSize, color, textAnchor, textAlignment, sortingOrder).gameObject);
 }
        // Creates a Text pop up at the world position
        public static void TextPopup(string text, Vector3 position)
        {
            if (LC_Utils.IsBuildForProduction())
            {
                return;
            }

            LC_GraphicsDebugUtils.CreateWorldTextPopup(text, position);
        }
        // World text pop up at mouse position
        public static void WorldTextPopupMouse(string text)
        {
            if (LC_Utils.IsBuildForProduction())
            {
                return;
            }

            LC_GraphicsDebugUtils.CreateWorldTextPopup(text, Utils.LC_Utils.GetMouseWorldPosition());
        }
 public static GameObject CreateWorldText(string text, Transform parent = null, Vector3 localPosition = default(Vector3), int fontSize = 40, Color?color = null, TextAnchor textAnchor = TextAnchor.UpperLeft, TextAlignment textAlignment = TextAlignment.Left, int sortingOrder = LC_Utils.sortingOrderDefault)
 {
     if (LC_Utils.IsBuildForProduction())
     {
         return(LC_Utils.GetDeafultEmptyObject()); // Do nothing
     }
     if (color == null)
     {
         color = Color.white;
     }
     return(LC_GraphicsDebugUtils.CreateWorldText(parent, text, localPosition, fontSize, color, textAnchor, textAlignment, sortingOrder).gameObject);
 }
    private void Start()
    {
        GameObject btnPanel = LC_Debug.CreateButtonPanel(Vector3.up);

        DebugButtonPanel.AddButton(btnPanel.GetComponent <DebugButtonPanel>(), "Test 1", () => LC_Debug.TextPopup("Test1", Vector3.up));
        DebugButtonPanel.AddButton(btnPanel.GetComponent <DebugButtonPanel>(), "Test 2", () => LC_Debug.TextPopup("Test2", Vector3.up));
        DebugButtonPanel.AddButton(btnPanel.GetComponent <DebugButtonPanel>(), "Test 3", () => LC_Debug.TextPopup("Test3", Vector3.up), out GameObject debugBtn);

        if (debugBtn != null)
        {
            debugBtn.GetComponent <DebugButton>().OnClickAction = () => { LC_Debug.TextPopup("Action replace test", debugBtn.transform.position + debugBtn.transform.right * (LC_Utils.GetDefaultButtonSize().x / 2 + LC_Utils.GetDefaultButtonPanelOffset())); }
        }
        ;

        CameraSwitcher.SetupReturnAction(() => Debug.Log("Returning to original camera"));


        LC_Utils.CreateKeyCodeAction(KeyCode.F1,
                                     () => {
            if (LC_Utils.IsBuildForProduction())
            {
                return;
            }
            LC_Debug.UseFreeLookCamera();
        });

        LC_Utils.CreateKeyCodeAction(KeyCode.F2,
                                     () => {
            if (LC_Utils.IsBuildForProduction())
            {
                return;
            }
            LC_Debug.UseFreeLookCamera();
        });


        LC_Utils.CreateKeyCodeAction(KeyCode.E,
                                     () => {
            if (LC_Utils.IsBuildForProduction())
            {
                return;
            }
            LC_Debug.RuntimeDebugObjectsManager.DisableDebugObjects();
        });

        LC_Utils.CreateKeyCodeAction(KeyCode.R,
                                     () => {
            if (LC_Utils.IsBuildForProduction())
            {
                return;
            }
            LC_Debug.RuntimeDebugObjectsManager.EnableDebugObjects();
        });

        LC_Utils.CreateKeyCodeAction(KeyCode.Backspace,
                                     () => {
            if (LC_Utils.IsBuildForProduction())
            {
                return;
            }
            CameraSwitcher.ReturnToOriginalCamera();
        });
    }
}