1. I'll give exaple code later, the problem is not with how many buttons ui have, problem is if button has parent and button have tezt children, then text makes button unclickable.
     
  2. How would that work in LUA? I tried it but it does not seem to work.
    Code:
        json = "[\"\"name\"\": \"\"TicketGUI\"\",\"\"parent\"\": \"\"Overlay\"\",\"\"components\"\":[{\"\"type\"\":\"\"UnityEngine.UI.Text\"\",\"\"text\"\":\"\"{text}\"\",\"\"fontSize\"\":20,\"\"align\"\": \"\"MiddleCenter\"\",},{\"\"type\"\":\"\"RectTransform\"\",\"\"anchormin\"\": \"\"0 0.20\"\",\"\"anchormax\"\": \"\"1 0.9\"\"}]}]"
        text = "There currently are <color=aqua>" .. #TicketsData.Tickets .. "</color> active tickets!"
        local players = global.BasePlayer.activePlayerList:GetEnumerator()
        while players:MoveNext() do
            local currId = rust.UserIDFromPlayer(players.Current)
            if permission.UserHasPermission(currId, "isTicketsAdmin") then
                CommunityEntity.ServerInstance:ClientRPCEx( Network:SendInfo() { connection = players.Current.net.connection }, nil, "AddUI", string.gsub(json, "{text}", text));
            end
        end
    [DOUBLEPOST=1437870618][/DOUBLEPOST]
    It didnt make my buttons unclickable
     
  3. Oh you are right, i found my mistake. While creating test code i realized that it works, so i started review other code of my menu and got why, its simple - some text was placed inside another transparent field what overlaps the button, LOL.
     
  4. You know the failure of my problem?
     
  5. With lua? not really, as for buttons and text - i just make everytime random name and problem solved.
     
  6. whats with the problem about disappearing buttons?
     
  7. Buttons or text on buttons? If text, then I already answered - create every time random name for button and problem "solved", there is no other choice for now.
    [DOUBLEPOST=1438010487][/DOUBLEPOST]Hey i have another question. I'm displaying item icons using rawimage and texture from
    Code:
     ""sprite"": ""assets/icons/items/"+itemdef.iconSprite.name+@".png""
    it works fine but with two problems:
    1. Icon can scaled like all others, and it looks wrong if use on non-wide resolutions. Is there way to render rawimage with set size always same to x and y?
    2. Whats wrong with new clothes icons? All new clothes have something like "tshirt.long.yellow.icon", "tshirt.blue.icon" etc and don't displaying with same path like all other items. Is there is different path or they just have different format that RawImage don't take? Also tried just image and same result. Can't understand whats wrong...
    [DOUBLEPOST=1438088069,1438007360][/DOUBLEPOST]So do anyone know whats wrong at least for second question?
     
  8. lol whats wrong with this?
    Code:
    {
                                ""name"": ""AKicon"",
                                ""parent"": ""IconsWindow"",
                                ""components"":
                                [
                                    {
                                        ""type"":""UnityEngine.UI.RawImage"",
                                        ""imagetype"": ""Tiled"",
                                        ""sprite"": ""assets/icons/items/rifle_ak.png""
                                    {
                                ]
                            },
    it just forces my whole UI not to show
     
  9. Try add RectTransform, i'm not sure if it works without.

    Also i'm third day trying to find solution to clothes icons, but still nothing, tried many formats, paths etc idk whats wrong.
     
  10. I also tried it with, was the same issue, you could instead pick clothes icons from here:
    http://rust.wikia.com/wiki/Category:Experimental_Icons
     
  11. Yea, i already thought about it, but by some unknown reason icons exactly from new clothes displaying big wrong, also idk why.

    Look this image 2015-07-29_00001.jpg and now compare with http://vignette1.wikia.nocookie.net...est/scale-to-width-down/120?cb=20150721023224

    left one is from game, second is from url.

    Maybe ask garry about add some component to display rust icons from items or so? Or to someone who can write this...
     
  12. Calytic

    Calytic Community Admin Community Mod

    There should be a way to extract icon images programmatically. In-fact I'm pretty sure there was a method that did work until the assets were read-protected. The only way to get those images is to extract them directly from the assets file.
     
  13. hey guys, does anyone know how to get when a button is pressed in the GUI?
    i remember someone making that it counts how many time the button was pressed, but i cant find it anywhere.
     
  14. Calytic

    Calytic Community Admin Community Mod

    AFAIK you have to add a "command" to the button and use a console command as the listener for button click events.
     
  15. ohhh hmmm ok, not perfect but i guess it works :)
    do you have an exemple by any means :) plz?
     
  16. Example(Hope that it will help)
    Code:
                                ""name"": ""Button"",
                                ""parent"": ""ButtonUI"",
                                ""components"":
                                [
                                    {
                                        ""type"":""UnityEngine.UI.Button""
                                        ""command"":""open.help"",
                                        ""color"": ""0.9 0.1 0.1 0.8"",
                                        ""imagetype"": ""Tiled""
                                    },
                                    {
                                        ""type"":""RectTransform"",
                                        ""anchormin"": ""0.08 0.15"",
                                        ""anchormax"": ""0.3 0.19""
                                    }
                                ]
                            },      [ConsoleCommand("open.help")]
            void OpenHelp(ConsoleSystem.Arg arg)
            {
                BasePlayer player = (BasePlayer) arg.connection.player;
                SendReply(player, "You pressed the button");
            }
    
     
  17. Code:
    using System;
    using UnityEngine;namespace Oxide.Plugins
    {
        [Info("GUI Button Example", "LaserHydra", "1.0.0", ResourceId = 0)]
        [Description("a GUI Button Example")]
        class ButtonExample : RustPlugin
        {
            #region GUI
            string json = @"[ 
                            {
                                ""name"": ""TestButton"",
                                ""parent"": ""Overlay"",
                                ""components"":
                                [
                                    {
                                        ""type"":""UnityEngine.UI.Button"",
                                        ""close"":""TestButton"",
                                        ""command"":""chat.say 'Button was pressed!'"",
                                        ""color"": ""0.3 0.6 0.4 0.8"",
                                        ""imagetype"": ""Tiled""
                                    },
                                    {
                                        ""type"":""RectTransform"",
                                        ""anchormin"": ""0.2 0.15"",
                                        ""anchormax"": ""0.8 0.25""
                                    }
                                ]
                            }
                        ]
                        ";
            #endregion
     
            [ChatCommand("button")]
            void cmdButton(BasePlayer player)
            {
                CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "AddUI", json);     
         
            }
        }
    }
           
    [DOUBLEPOST=1438197957][/DOUBLEPOST]
    How do you generate your random name string?
    I need to change the length of the string for every name, because its the same string, it just cuts it off.
    Code:
    //    Send Shop UI to a player
            void SendShopUI(BasePlayer player)
            {
                string UI = Shop.Replace("ShopWindow", GetRandomString(5));
                UI = UI.Replace("CloseShop", GetRandomString(6));
                UI = UI.Replace("AKicon", GetRandomString(7));
                UI = UI.Replace("AKwindow", GetRandomString(8));
                UI = UI.Replace("CloseX", GetRandomString(9));
               
                Puts(UI);
               
                CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "AddUI", UI);
            }
    //    Generate a Random String
            string GetRandomString(int length)
            {
                var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
                var random = new System.Random();
                var result = new string(
                Enumerable.Repeat(chars, length)
                  .Select(s => s[random.Next(s.Length)])
                  .ToArray());
                return result;
            }
    And what my console shows me when I am not using different lengths is the following:
    Code:
    [
        {
            "name": "IHIiT2XH",
            "parent": "Overlay",
            "components": [
                {
                    "type": "UnityEngine.UI.Image",
                    "color": "0.1 0.1 0.1 0.9"
                },
                {
                    "type": "RectTransform",
                    "anchormin": "0.1 0.1",
                    "anchormax": "0.9 0.9"
                },
                {
                    "type": "NeedsCursor"
                }
            ]
        },
        {
            "parent": "IHIiT2XH",
            "components": [
                {
                    "type": "UnityEngine.UI.Text",
                    "text": "Shop",
                    "fontSize": 40,
                    "align": "MiddleCenter"
                },
                {
                    "type": "RectTransform",
                    "anchormin": "0 0.86",
                    "anchormax": "1 0.99"
                }
            ]
        },
        {
            "name": "IHIiT2XH",
            "parent": "IHIiT2XH",
            "components": [
                {
                    "type": "UnityEngine.UI.Button",
                    "close": "IHIiT2XH",
                    "color": "1.0 0.1 0.1 0.8",
                    "imagetype": "Tiled"
                },
                {
                    "type": "RectTransform",
                    "anchormin": "0.975 0.978",
                    "anchormax": "0.999 0.998"
                }
            ]
        },
        {
            "name": "IHIiT2XH",
            "parent": "IHIiT2XH",
            "components": [
                {
                    "type": "UnityEngine.UI.Text",
                    "text": "x",
                    "color": "0.0 0.0 0.0 1.0",
                    "fontSize": 15,
                    "align": "MiddleCenter"
                }
            ]
        },
        {
            "name": "IHIiT2XH",
            "parent": "IHIiT2XH",
            "components": [
                {
                    "type": "UnityEngine.UI.Image",
                    "color": "0.2 0.2 0.2 0.9"
                },
                {
                    "type": "RectTransform",
                    "anchormin": "0.1 0.75",
                    "anchormax": "0.2 0.9"
                }
            ]
        },
        {
            "name": "IHIiT2XH",
            "parent": "IHIiT2XH",
            "components": [
                {
                    "type": "UnityEngine.UI.RawImage",
                    "imagetype": "Tiled",
                    "color": "1.0 1.0 1.0 1.0",
                    "url": "http://vignette3.wikia.nocookie.net/play-rust/images/d/d1/Assault_Rifle_icon.png/revision/latest/scale-to-width-down/480?cb=20150405105940"
                },
                {
                    "type": "RectTransform",
                    "anchormin": "0 0",
                    "anchormax": "1 1"
                }
            ]
        }
    ]
    You see what I mean?

    with different lengths it was like this:
    Code:
    [
        {
            "name": "vy9w8",
            "parent": "Overlay",
            "components": [
                {
                    "type": "UnityEngine.UI.Image",
                    "color": "0.1 0.1 0.1 0.9"
                },
                {
                    "type": "RectTransform",
                    "anchormin": "0.1 0.1",
                    "anchormax": "0.9 0.9"
                },
                {
                    "type": "NeedsCursor"
                }
            ]
        },
        {
            "parent": "vy9w8",
            "components": [
                {
                    "type": "UnityEngine.UI.Text",
                    "text": "Shop",
                    "fontSize": 40,
                    "align": "MiddleCenter"
                },
                {
                    "type": "RectTransform",
                    "anchormin": "0 0.86",
                    "anchormax": "1 0.99"
                }
            ]
        },
        {
            "name": "vy9w8s",
            "parent": "vy9w8",
            "components": [
                {
                    "type": "UnityEngine.UI.Button",
                    "close": "vy9w8",
                    "color": "1.0 0.1 0.1 0.8",
                    "imagetype": "Tiled"
                },
                {
                    "type": "RectTransform",
                    "anchormin": "0.975 0.978",
                    "anchormax": "0.999 0.998"
                }
            ]
        },
        {
            "name": "vy9w8s2SV",
            "parent": "vy9w8s",
            "components": [
                {
                    "type": "UnityEngine.UI.Text",
                    "text": "x",
                    "color": "0.0 0.0 0.0 1.0",
                    "fontSize": 15,
                    "align": "MiddleCenter"
                }
            ]
        },
        {
            "name": "vy9w8s2S",
            "parent": "vy9w8",
            "components": [
                {
                    "type": "UnityEngine.UI.Image",
                    "color": "0.2 0.2 0.2 0.9"
                },
                {
                    "type": "RectTransform",
                    "anchormin": "0.1 0.75",
                    "anchormax": "0.2 0.9"
                }
            ]
        },
        {
            "name": "vy9w8s2",
            "parent": "vy9w8s2S",
            "components": [
                {
                    "type": "UnityEngine.UI.RawImage",
                    "imagetype": "Tiled",
                    "color": "1.0 1.0 1.0 1.0",
                    "url": "http://vignette3.wikia.nocookie.net/play-rust/images/d/d1/Assault_Rifle_icon.png/revision/latest/scale-to-width-down/480?cb=20150405105940"
                },
                {
                    "type": "RectTransform",
                    "anchormin": "0 0",
                    "anchormax": "1 1"
                }
            ]
        }
    ]
     
  18. @LaserHydra
    There is enough to generate only one random string/number and add (append) it to each name/parent (example: Test{RND}, then TitlePanelBase{RND} with parent Test{RND} and so on). Anyway i'm doing it not often so... Also don't name parent exactly like name.
     
  19. I did not name parents same like name. but that idea is good. Just adding the randomstring to it. Good idea. thanks
     
  20. thx a lot pain :)