Nested CUI

Discussion in 'Rust Development' started by Visagalis, Nov 15, 2015.

  1. Today I came across a problem:
    Code:
               var elements = new CuiElementContainer();
                var mainName = elements.Add(new CuiPanel
                {
                    Image =
                    {
                        Color = "0.1 0.1 0.1 0.7"
                    },
                    RectTransform =
                    {
                        AnchorMin = "0 0.9",
                        AnchorMax = "1 1"
                    }
                }, "HUD/Overlay", "StatsUI");            #region woodCutting            elements.Add(new CuiPanel
                {
                    Image =
                    {
                        Color = "1 0.1 0.1 0.5"
                    },
                    RectTransform =
                    {
                        AnchorMin = "0 0",
                        AnchorMax = "0.5 0.5"
                    }
                }, "StatsUI", "WCGUI");            elements.Add(new CuiPanel
                {
                    Image =
                    {
                        Color = "0.1 0.1 1 1"
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.5 0",
                        AnchorMax = "1 0.5"
                    }
                }, "WCGUI");
               CuiHelper.AddUi(player, elements);
    Last element added is not visible in the game. because it's parent is "WCGUI", which already has a parent "StatsUI", which has parent "HUD/Overlay" is there some kind of nesting limitations, or i'm doing something wrong?

    Explanation GIF: Imgur GIF
    If nesting would be allowed, then i would always have same SkillUI Elements positions(Anchors), i would just need to duplicate SkillUI and change its position(Anchors) when creating extra skill.
     
    Last edited by a moderator: Nov 15, 2015
  2. bump! :)

    Example to try:
    Code:
                var elements = new CuiElementContainer();
                var mainPanel = elements.Add(new CuiPanel
                {
                    Image = { Color = "0.1 0.1 0.1 1.0" },
                    RectTransform = { AnchorMin = "0.0 0.0", AnchorMax = "1.0 1.0" }
                });            var innerPanel = new CuiElement
                {
                    Name = CuiHelper.GetGuid(),
                    Parent = mainPanel,
                    Components =
                            {
                                new CuiImageComponent { Color = "0.4 0.4 0.4 1.0" },
                                new CuiRectTransformComponent{ AnchorMin = "0.25 0.25", AnchorMax = $"0.75 0.75" }
                            }
                };
                elements.Add(innerPanel);            var innerInnerPanel = new CuiElement
                {
                    Name = CuiHelper.GetGuid(),
                    Parent = innerPanel.Parent,
                    Components =
                            {
                                new CuiImageComponent { Color = "0.1 0.1 0.1 1.0" },
                                new CuiRectTransformComponent{ AnchorMin = "0.25 0.25", AnchorMax = $"0.75 0.75" }
                            }
                };
                elements.Add(innerInnerPanel);            CuiHelper.AddUi(player, elements);
     
    Last edited by a moderator: Dec 9, 2015