private void SetupInteraction()
        {
            BoxCollider col    = Button.AddComponent <BoxCollider>();
            var         size   = GetButtonSize();
            var         height = GetButtonHeight();
            var         border = GetButtonBorder();

            col.size   = new Vector3(size, size, border * 2);
            col.center = new Vector3(size / 2f, size / 2f, -border);
            Button.AddComponent <Button>();
            var hand = new CustomEvents.UnityEventHand();

            hand.AddListener(h => { ButtonPress(); });
            Button.AddComponent <UIElement>().onHandClick = hand;
        }
Ejemplo n.º 2
0
        public static GameObject CreateTeleportButtonModel(Vector3 position, Vector3 destination, float size,
                                                           float border)
        {
            var modelData = GenerateButtonModel(size, border, border / 2f);
            var buttonObj = ModelFactory.CreateModel(modelData);
            var tpBtn     = buttonObj.AddComponent <PlayerTeleporter>();

            tpBtn.Destination = destination;
            var col = buttonObj.AddComponent <BoxCollider>();

            col.size   = new Vector3(size, size, border * 2);
            col.center = new Vector3(size / 2f, size / 2f, -border);
            buttonObj.AddComponent <Button>();
            var hand = new CustomEvents.UnityEventHand();

            hand.AddListener(h => { tpBtn.TeleportPlayer(); });
            buttonObj.AddComponent <UIElement>().onHandClick = hand;
            buttonObj.transform.position = position;
            buttonObj.name = "TeleportButton (Instance)";
            return(buttonObj);
        }