public override void Start()
        {
            if (!LinkedObject.HasComponent <Button2DComponent>())
            {
                Debug.LogWarning("The 2DObject \"" + LinkedObject.ObjectName + "\" has a Dropdown 2D Component but no button to interact with it. A button 2D Component has automatically been added.", true);
                LinkedObject.AddComponent(new Button2DComponent());
            }

            DropDownParent = new Object2D("Dropdown_" + LinkedObject.ObjectName, LinkedObject.Position + new Vector2(0, LinkedObject.Size.Y / 2), Size, LinkedObject.Rotation, new Component2D[] { new Image2DComponent(DefaultValues.PixelTexture, DropDownColor), new Spacer2DComponent(SpacerOption.VerticalSpacer, ItemSpacing, Alignment.TopLeft, ItemSpacing) }, Alignment.TopLeft, LinkedObject.Layer, LinkedObject);

            if (MustClick)
            {
                LinkedObject.GetComponent <Button2DComponent>().OnClick        += () => OpenDropdown();
                LinkedObject.GetComponent <Button2DComponent>().OnClickOutside += () => CloseDropdown();
            }
            else
            {
                LinkedObject.GetComponent <Button2DComponent>().OnEnter += () => OpenDropdown();
                LinkedObject.GetComponent <Button2DComponent>().OnExit  += () => CloseDropdown();
            }

            foreach (Object2D obj in DropdownItems.ToArray())
            {
                DropDownParent.AddChild(obj);
            }

            CloseDropdown();
        }
Exemple #2
0
 public override void Start()
 {
     StartPos = LinkedObject.Position;
     LinkedObject.AddComponent(new Button2DComponent(onEnter: () => { LinkedObject.Dispose(); }));
     LinkedObject.Position = StartPos;
 }