Example #1
0
    IEnumerator AddShapesButtons()
    {
        yield return(null);

        firstHL = true;

        PdxShape[] ss = FindObjectsOfType <PdxShape>();

        bool selectFirst = false;

        foreach (PdxShape s in ss)
        {
            GameObject ob = Instantiate(objectButtonPrefab);
            ob.transform.SetParent(hierarchyPanel);
            ObjectButton b = ob.GetComponent <ObjectButton>();
            b.SetObject(s);

            if (!selectFirst)
            {
                selectFirst = true;

                b.OnPointerClick(null);
            }
        }
    }
Example #2
0
        public ObjectAdditionPanel(Camera camera)
        {
            this.camera   = camera;
            Add(container = new FillFlowContainer
            {
                RelativeSizeAxes = Axes.Both,
                Spacing          = new Vector2(5),
                Margin           = new MarginPadding
                {
                    Top        = 35,
                    Horizontal = 5
                }
            });

            for (var i = 1; i < 10; i++)
            {
                ObjectButton objectButton;

                container.Add(objectButton = new ObjectButton(i)
                {
                    Size = new Vector2(40)
                });

                objectButton.Action = () =>
                {
                    if (objectButton.ToggleActive())
                    {
                        if (currentlyActiveButton != null)
                        {
                            currentlyActiveButton.Active = false;
                        }

                        currentlyActiveButton = objectButton;
                        AbleToPlace.Value     = true;
                        camera.ShowGhostObject();
                        camera.SetGhostObjectID(SelectedObjectID = objectButton.ObjectID);
                    }
                    else if (currentlyActiveButton == objectButton)
                    {
                        currentlyActiveButton = null;
                        AbleToPlace.Value     = false;
                        camera.HideGhostObject();
                    }
                };
            }
        }