Example #1
0
        public static void RemoveButton()
        {
            Logger.LogDebug($"{nameof(NodeMarkupButton)}.{nameof(RemoveButton)}");

            if (Instance != null)
            {
                GetContainingPanel().RemoveUIComponent(Instance);
                Destroy(Instance);
                Instance = null;
            }
        }
Example #2
0
        public override void Start()
        {
            Logger.LogDebug($"{nameof(NodeMarkupButton)}.{nameof(Start)}");

            base.Start();
            name            = nameof(NodeMarkupButton);
            playAudioEvents = true;

            if (!(UIUtils.FindComponent <UITabstrip>("ToolMode", GetContainingPanel(), UIUtils.FindOptions.None) is UITabstrip builtinTabstrip))
            {
                return;
            }

            string[] spriteNames = new string[]
            {
                ButtonBg,
                ButtonBgActive,
                ButtonBgHovered,
                Icon,
                IconActive,
                IconHovered
            };

            atlas = TextureUtil.GetAtlas(AtlasName);
            if (atlas == UIView.GetAView().defaultAtlas)
            {
                atlas = TextureUtil.CreateTextureAtlas("sprites.png", AtlasName, buttonSize, buttonSize, spriteNames);
            }

            Deactivate();
            hoveredBgSprite = ButtonBgHovered;
            hoveredFgSprite = IconHovered;

            relativePosition = buttonPosition;
            size             = new Vector2(buttonSize, buttonSize);
            Show();
            Unfocus();
            Invalidate();

            Instance = this;
        }
Example #3
0
 public static void CreateButton()
 {
     Logger.LogDebug($"{nameof(NodeMarkupButton)}.{nameof(CreateButton)}");
     Instance = GetContainingPanel().AddUIComponent <NodeMarkupButton>();
     Logger.LogDebug($"Button created");
 }