예제 #1
0
        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();
        }
예제 #2
0
 public override void Start()
 {
     Debug.Log(LinkedObject.ObjectName + "\nText:  " + (LinkedObject.HasComponent <Text2DComponent>() ? (LinkedObject.Layer + ((float)LinkedObject.GetComponent <Text2DComponent>().SubLayer / 10000)).ToString() : "null") + "\nImage: " + (LinkedObject.Layer + ((float)LinkedObject.GetComponent <Image2DComponent>().SubLayer / 10000)).ToString() + "\n");
 }