Пример #1
0
    public static IEnumerator GetStories()
    {
        WWW wWW = new WWW("http://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid=252490&count=8&format=json&feeds=steam_community_announcements");

        yield return(wWW);

        JSON.Object objs = JSON.Object.Parse(wWW.text);
        wWW.Dispose();
        if (objs == null)
        {
            yield break;
        }
        JSON.Array array = objs.GetObject("appnews").GetArray("newsitems");
        List <SteamNewsSource.Story> stories = new List <SteamNewsSource.Story>();

        foreach (Value value in array)
        {
            string str = value.Obj.GetString("contents", "Missing URL");
            SteamNewsSource.Story story = new SteamNewsSource.Story()
            {
                name   = value.Obj.GetString("title", "Missing Title"),
                url    = value.Obj.GetString("url", "Missing URL"),
                date   = value.Obj.GetInt("date", 0),
                text   = str,
                author = value.Obj.GetString("author", "Missing Author")
            };
            stories.Add(story);
        }
        SteamNewsSource.Stories = stories.ToArray();
    }
Пример #2
0
 private void LoadFrom(string strData)
 {
     JSON.Object obj2 = null;
     try
     {
         obj2 = JSON.Object.Parse(strData);
     }
     catch (Exception)
     {
         return;
     }
     if (obj2 != null)
     {
         try
         {
             PlayerPrefs.SetString(this.storeKey, strData);
         }
         catch (Exception)
         {
         }
         this.json     = obj2;
         this.isLoaded = true;
         if (this.onUpdated != null)
         {
             this.onUpdated(this.json);
         }
     }
 }
Пример #3
0
 private void GraphicComponentCreated(UnityEngine.UI.Graphic c, JSON.Object obj)
 {
     if (obj.ContainsKey("fadeIn"))
     {
         c.canvasRenderer.SetAlpha(0f);
         c.CrossFadeAlpha(1f, obj.GetFloat("fadeIn", 0), true);
     }
 }
Пример #4
0
    private void generateElement(GameObject go, JSON.Object json)
    {
        var rt = go.GetComponent <RectTransform>();

        if (rt)
        {
            rt.anchorMin = new Vector2(0, 0);
            rt.anchorMax = new Vector2(1, 1);
            rt.offsetMin = new Vector2(0, 0);
            rt.offsetMax = new Vector2(1, 1);
        }

        foreach (var component in json.GetArray("components"))
        {
            CreateComponents(go, component.Obj);
        }

        if (json.ContainsKey("fadeOut"))
        {
            go.AddComponent <FadeOut>().duration = json.GetFloat("fadeOut", 0);
        }
    }
Пример #5
0
    private void recursiveAddUI(JSON.Object json, GameObject parent)
    {
        var go = new GameObject(json.GetString("name", "AddUI CreatedPanel"));

        if (parent == null)
        {
            var parentName = json.GetString("parent", "Overlay");

            parent = findServerCreatedPanel(parentName); //Find parent in serverCreatedUI

            if (parent == null)
            {
                parent = findClientPanel(parentName);//Find parent in the client UI

                if (parent == null)
                {
                    return; //Parent doesn't exists
                }
                //Add the GameObject to serverCreatedUI since it's a new UI and destroy old one if it exists
                if (go != null)
                {
                    DestroyPanel(go.name, true);
                }
                serverCreatedUI.Add(go);
            }
        }

        generateElement(go, json);

        go.transform.SetParent(parent.transform, false);

        if (json.ContainsKey("childs"))
        {
            foreach (var child in json.GetArray("childs"))
            {
                recursiveAddUI(child.Obj, go);
            }
        }
    }
Пример #6
0
    private void CreateComponents(GameObject go, JSON.Object obj)
    {
        //
        // This is the 'stupid' but 'safe & predictable way of doing this.
        //
        switch (obj.GetString("type", "UnityEngine.UI.Text"))
        {
        case "UnityEngine.UI.Text":
        {
            var c = go.AddComponent <UnityEngine.UI.Text>();
            c.text      = obj.GetString("text", "Text");
            c.fontSize  = obj.GetInt("fontSize", 14);
            c.font      = FileSystem.Load <Font>("Assets/Content/UI/Fonts/" + obj.GetString("font", "RobotoCondensed-Bold.ttf"));
            c.alignment = (TextAnchor)System.Enum.Parse(typeof(TextAnchor), obj.GetString("align", "UpperLeft"));
            c.color     = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));
            GraphicComponentCreated(c, obj);
            break;
        }

        case "UnityEngine.UI.Image":
        {
            var c = go.AddComponent <UnityEngine.UI.Image>();
            c.sprite   = FileSystem.Load <Sprite>(obj.GetString("sprite", "Assets/Content/UI/UI.Background.Tile.psd"));
            c.material = FileSystem.Load <Material>(obj.GetString("material", "Assets/Icons/IconMaterial.mat"));
            c.color    = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));
            c.type     = (UnityEngine.UI.Image.Type)System.Enum.Parse(typeof(UnityEngine.UI.Image.Type), obj.GetString("imagetype", "Simple"));

            if (obj.ContainsKey("png"))
            {
                SetImageFromServer(c, uint.Parse(obj.GetString("png")));
            }

            GraphicComponentCreated(c, obj);

            break;
        }

        case "UnityEngine.UI.RawImage":
        {
            var c = go.AddComponent <UnityEngine.UI.RawImage>();
            c.texture = FileSystem.Load <Texture>(obj.GetString("sprite", "Assets/Icons/rust.png"));
            c.color   = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));

            if (obj.ContainsKey("material"))
            {
                c.material = FileSystem.Load <Material>(obj.GetString("material"));
            }

            if (obj.ContainsKey("url"))
            {
                Rust.Global.Runner.StartCoroutine(LoadTextureFromWWW(c, obj.GetString("url")));
            }

            if (obj.ContainsKey("png"))
            {
                SetImageFromServer(c, uint.Parse(obj.GetString("png")));
            }

            GraphicComponentCreated(c, obj);

            break;
        }

        case "UnityEngine.UI.Button":
        {
            var c = go.AddComponent <UnityEngine.UI.Button>();

            if (obj.ContainsKey("command"))
            {
                var cmd = obj.GetString("command");
                c.onClick.AddListener(() => { ConsoleNetwork.ClientRunOnServer(cmd); });
            }

            if (obj.ContainsKey("close"))
            {
                var pnlName = obj.GetString("close");
                c.onClick.AddListener(() => { DestroyPanel(pnlName); });
            }

            // bg image
            var img = go.AddComponent <UnityEngine.UI.Image>();
            img.sprite   = FileSystem.Load <Sprite>(obj.GetString("sprite", "Assets/Content/UI/UI.Background.Tile.psd"));
            img.material = FileSystem.Load <Material>(obj.GetString("material", "Assets/Icons/IconMaterial.mat"));
            img.color    = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));
            img.type     = (UnityEngine.UI.Image.Type)System.Enum.Parse(typeof(UnityEngine.UI.Image.Type), obj.GetString("imagetype", "Simple"));

            c.image = img;

            GraphicComponentCreated(img, obj);

            break;
        }

        case "UnityEngine.UI.Outline":
        {
            var c = go.AddComponent <UnityEngine.UI.Outline>();
            c.effectColor     = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));
            c.effectDistance  = Vector2Ex.Parse(obj.GetString("distance", "1.0 -1.0"));
            c.useGraphicAlpha = obj.ContainsKey("useGraphicAlpha");
            break;
        }

        case "UnityEngine.UI.InputField":
        {
            var t = go.AddComponent <UnityEngine.UI.Text>();
            t.text      = obj.GetString("text", "Text");
            t.fontSize  = obj.GetInt("fontSize", 14);
            t.font      = FileSystem.Load <Font>("Assets/Content/UI/Fonts/" + obj.GetString("font", "RobotoCondensed-Bold.ttf"));
            t.alignment = (TextAnchor)System.Enum.Parse(typeof(TextAnchor), obj.GetString("align", "UpperLeft"));
            t.color     = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));

            var c = go.AddComponent <UnityEngine.UI.InputField>();
            c.textComponent  = t;
            c.characterLimit = obj.GetInt("characterLimit", 0);

            if (obj.ContainsKey("command"))
            {
                var cmd = obj.GetString("command");
                c.onEndEdit.AddListener((value) => { ConsoleNetwork.ClientRunOnServer(cmd + " " + value); });
            }

            if (obj.ContainsKey("password"))
            {
                c.inputType = UnityEngine.UI.InputField.InputType.Password;
            }

            GraphicComponentCreated(t, obj);

            break;
        }

        case "NeedsCursor":
        {
            go.AddComponent <NeedsCursor>();
            break;
        }

        case "RectTransform":
        {
            var rt = go.GetComponent <RectTransform>();
            if (rt)
            {
                rt.anchorMin = Vector2Ex.Parse(obj.GetString("anchormin", "0.0 0.0"));
                rt.anchorMax = Vector2Ex.Parse(obj.GetString("anchormax", "1.0 1.0"));
                rt.offsetMin = Vector2Ex.Parse(obj.GetString("offsetmin", "0.0 0.0"));
                rt.offsetMax = Vector2Ex.Parse(obj.GetString("offsetmax", "1.0 1.0"));
            }
            break;
        }

        case "Countdown":
        {
            var c = go.AddComponent <Countdown>();
            c.endTime   = obj.GetInt("endTime", 0);
            c.startTime = obj.GetInt("startTime", 0);
            c.step      = obj.GetInt("step", 1);

            if (obj.ContainsKey("command"))
            {
                c.command = obj.GetString("command");
            }

            break;
        }
        }
    }
        public void On_PluginInit()
        {
            Author = "Pluton Team";
            About = "Control who can run which commands";
            Version = "0.4";
            IniParser settings = Plugin.CreateIni("Settings");
            if (settings != null)
            {
                settings["Settings"]["Debug"] = "false";
            }
            Commands.Register("permissions").setCallback(Permission).setDescription("Add or Remove people in permissions").setCommand(example);
            if (!Plugin.JsonFileExists("permissions"))
            {
                //{"players":{"734583538534583":["godmode","teleport"],"734582394234223":["jail","pizza","yolo"]},"groups":{"Default":{"name":"default","tag":"[Default]","permissions":["players","help","whois","whatis","whereami","howto","commands"],"players":["*"]},"Admins":{"name":"Admins","tag":"[Admins]","permissions":["godmode","pikachu","squirdle"],"players":["734583538534583","73423422334583"]}}}
                JSON.Object perms = new JSON.Object();

                //Top level
                JSON.Object players = new JSON.Object();
                JSON.Object groups = new JSON.Object();

                // Groups 2nd level (Players is default empty)
                JSON.Object groupsdefault = new JSON.Object();
                JSON.Object groupsadmin = new JSON.Object();
                JSON.Object groupsmod = new JSON.Object();
                JSON.Object groupsdon = new JSON.Object();

                // Groups 3 level - Default
                JSON.Array groupsdefperms = new JSON.Array();
                JSON.Array groupsdefplayers = new JSON.Array();
                groupsdefault["name"] = new JSON.Value("default");
                groupsdefault["tag"] = new JSON.Value("[Default]");
                foreach (string command in dcommands)
                    groupsdefperms.Add(new JSON.Value(command));
                groupsdefault["permissions"] = new JSON.Value(groupsdefperms);
                groupsdefplayers.Add(new JSON.Value("*"));
                groupsdefault["players"] = new JSON.Value(groupsdefplayers);

                // Groups 3 level - Admin
                JSON.Array groupsadmperms = new JSON.Array() { "ban", "kick", "mute" };
                JSON.Array groupsadmplayers = new JSON.Array();
                groupsadmin["name"] = new JSON.Value("admin");
                groupsadmin["tag"] = new JSON.Value("[Admin]");
                //groupsadmperms.Add(new JSON.Value(groupsadmperms));
                groupsadmin["permissions"] = new JSON.Value(groupsadmperms);
                groupsadmplayers.Add(new JSON.Value(""));
                groupsadmin["players"] = new JSON.Value(groupsadmplayers);

                // Groups 3 level - Moderator
                JSON.Array groupsmodperms = new JSON.Array() { "kick", "mute" };
                JSON.Array groupsmodplayers = new JSON.Array();
                groupsmod["name"] = new JSON.Value("moderator");
                groupsmod["tag"] = new JSON.Value("[Mod]");
                //groupsadmperms.Add(new JSON.Value(groupsmodperms));
                groupsmod["permissions"] = new JSON.Value(groupsmodperms);
                groupsmodplayers.Add(new JSON.Value(""));
                groupsmod["players"] = new JSON.Value(groupsmodplayers);

                // Groups 3 level - Donator
                JSON.Array groupsdonperms = new JSON.Array() { "funstuff", "extrakits" };
                JSON.Array groupsdonplayers = new JSON.Array();
                groupsdon["name"] = new JSON.Value("donator");
                groupsdon["tag"] = new JSON.Value("[Donator]");
                //groupsdonperms.Add(new JSON.Value(groupsdonperms));
                groupsdon["permissions"] = new JSON.Value(groupsdonperms);
                groupsdonplayers.Add(new JSON.Value(""));
                groupsdon["players"] = new JSON.Value(groupsdonplayers);

                //Combine all groups into main
                groups["Default"] = new JSON.Value(groupsdefault);
                groups["Admin"] = new JSON.Value(groupsadmin);
                groups["Moderator"] = new JSON.Value(groupsmod);
                groups["Donator"] = new JSON.Value(groupsmod);

                //Finish up by combining players and groups into 1 and stringify
                perms["players"] = new JSON.Value(players);
                perms["groups"] = new JSON.Value(groups);
                string json = perms.ToString();
                Plugin.ToJsonFile("permissions", json);
            }
            IniParser getsettings = Plugin.GetIni("Settings");
            debug = getsettings["Settings"]["Debug"].ToLower() == "true";
            json_perms = Plugin.FromJsonFile("permissions");
        }
        public void On_PluginInit()
        {
            Author  = "Pluton Team";
            About   = "Control who can run which commands";
            Version = "0.4";
            IniParser settings = Plugin.CreateIni("Settings");

            if (settings != null)
            {
                settings["Settings"]["Debug"] = "false";
            }
            Commands.Register("permissions").setCallback(Permission).setDescription("Add or Remove people in permissions").setCommand(example);
            if (!Plugin.JsonFileExists("permissions"))
            {
                //{"players":{"734583538534583":["godmode","teleport"],"734582394234223":["jail","pizza","yolo"]},"groups":{"Default":{"name":"default","tag":"[Default]","permissions":["players","help","whois","whatis","whereami","howto","commands"],"players":["*"]},"Admins":{"name":"Admins","tag":"[Admins]","permissions":["godmode","pikachu","squirdle"],"players":["734583538534583","73423422334583"]}}}
                JSON.Object perms = new JSON.Object();

                //Top level
                JSON.Object players = new JSON.Object();
                JSON.Object groups  = new JSON.Object();

                // Groups 2nd level (Players is default empty)
                JSON.Object groupsdefault = new JSON.Object();
                JSON.Object groupsadmin   = new JSON.Object();
                JSON.Object groupsmod     = new JSON.Object();
                JSON.Object groupsdon     = new JSON.Object();

                // Groups 3 level - Default
                JSON.Array groupsdefperms   = new JSON.Array();
                JSON.Array groupsdefplayers = new JSON.Array();
                groupsdefault["name"] = new JSON.Value("default");
                groupsdefault["tag"]  = new JSON.Value("[Default]");
                foreach (string command in dcommands)
                {
                    groupsdefperms.Add(new JSON.Value(command));
                }
                groupsdefault["permissions"] = new JSON.Value(groupsdefperms);
                groupsdefplayers.Add(new JSON.Value("*"));
                groupsdefault["players"] = new JSON.Value(groupsdefplayers);

                // Groups 3 level - Admin
                JSON.Array groupsadmperms = new JSON.Array()
                {
                    "ban", "kick", "mute"
                };
                JSON.Array groupsadmplayers = new JSON.Array();
                groupsadmin["name"] = new JSON.Value("admin");
                groupsadmin["tag"]  = new JSON.Value("[Admin]");
                //groupsadmperms.Add(new JSON.Value(groupsadmperms));
                groupsadmin["permissions"] = new JSON.Value(groupsadmperms);
                groupsadmplayers.Add(new JSON.Value(""));
                groupsadmin["players"] = new JSON.Value(groupsadmplayers);

                // Groups 3 level - Moderator
                JSON.Array groupsmodperms = new JSON.Array()
                {
                    "kick", "mute"
                };
                JSON.Array groupsmodplayers = new JSON.Array();
                groupsmod["name"] = new JSON.Value("moderator");
                groupsmod["tag"]  = new JSON.Value("[Mod]");
                //groupsadmperms.Add(new JSON.Value(groupsmodperms));
                groupsmod["permissions"] = new JSON.Value(groupsmodperms);
                groupsmodplayers.Add(new JSON.Value(""));
                groupsmod["players"] = new JSON.Value(groupsmodplayers);

                // Groups 3 level - Donator
                JSON.Array groupsdonperms = new JSON.Array()
                {
                    "funstuff", "extrakits"
                };
                JSON.Array groupsdonplayers = new JSON.Array();
                groupsdon["name"] = new JSON.Value("donator");
                groupsdon["tag"]  = new JSON.Value("[Donator]");
                //groupsdonperms.Add(new JSON.Value(groupsdonperms));
                groupsdon["permissions"] = new JSON.Value(groupsdonperms);
                groupsdonplayers.Add(new JSON.Value(""));
                groupsdon["players"] = new JSON.Value(groupsdonplayers);

                //Combine all groups into main
                groups["Default"]   = new JSON.Value(groupsdefault);
                groups["Admin"]     = new JSON.Value(groupsadmin);
                groups["Moderator"] = new JSON.Value(groupsmod);
                groups["Donator"]   = new JSON.Value(groupsmod);

                //Finish up by combining players and groups into 1 and stringify
                perms["players"] = new JSON.Value(players);
                perms["groups"]  = new JSON.Value(groups);
                string json = perms.ToString();
                Plugin.ToJsonFile("permissions", json);
            }
            IniParser getsettings = Plugin.GetIni("Settings");

            debug      = getsettings["Settings"]["Debug"].ToLower() == "true";
            json_perms = Plugin.FromJsonFile("permissions");
        }
    private void CreateComponents(GameObject go, JSON.Object obj)
    {
        //
        // This is the 'stupid' but 'safe & predictable way of doing this.
        //
        switch (obj.GetString("type", "UnityEngine.UI.Text"))
        {
        case "UnityEngine.UI.Text":
        {
            var c = go.AddComponent <UnityEngine.UI.Text>();
            c.text      = obj.GetString("text", "Text");
            c.fontSize  = obj.GetInt("fontSize", 14);
            c.font      = FileSystem.Load <Font>("Assets/Content/UI/Fonts/" + obj.GetString("font", "RobotoCondensed-Bold.ttf"));
            c.alignment = ParseEnum(obj.GetString("align"), TextAnchor.UpperLeft);
            c.color     = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));
            GraphicComponentCreated(c, obj);
            break;
        }

        case "UnityEngine.UI.Image":
        {
            var c = go.AddComponent <UnityEngine.UI.Image>();
            c.sprite   = FileSystem.Load <Sprite>(obj.GetString("sprite", "Assets/Content/UI/UI.Background.Tile.psd"));
            c.material = FileSystem.Load <Material>(obj.GetString("material", "Assets/Icons/IconMaterial.mat"));
            c.color    = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));
            c.type     = ParseEnum(obj.GetString("imagetype", "Simple"), UnityEngine.UI.Image.Type.Simple);

            if (obj.ContainsKey("png") && uint.TryParse(obj.GetString("png"), out var id))
            {
                SetImageFromServer(c, id);
            }

            if (obj.ContainsKey("itemid"))
            {
                var itemdef = ItemManager.FindItemDefinition(obj.GetInt("itemid"));
                if (itemdef != null)
                {
                    c.material = null;
                    c.sprite   = itemdef.iconSprite;

                    if (obj.ContainsKey("skinid"))
                    {
                        var requestedSkin = obj.GetInt("skinid");
                        var skin          = itemdef.skins.FirstOrDefault(x => x.id == requestedSkin);
                        if (skin.id == requestedSkin)
                        {
                            c.sprite = skin.invItem.icon;
                        }
                        else
                        {
                            var workshopSprite = WorkshopIconLoader.Find((ulong)requestedSkin);
                            if (workshopSprite != null)
                            {
                                c.sprite = workshopSprite;
                            }
                        }
                    }
                }
            }

            GraphicComponentCreated(c, obj);

            break;
        }

        case "UnityEngine.UI.RawImage":
        {
            var c = go.AddComponent <UnityEngine.UI.RawImage>();
            c.texture = FileSystem.Load <Texture>(obj.GetString("sprite", "Assets/Icons/rust.png"));
            c.color   = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));

            if (obj.ContainsKey("material"))
            {
                c.material = FileSystem.Load <Material>(obj.GetString("material"));
            }

            if (obj.ContainsKey("url"))
            {
                Rust.Global.Runner.StartCoroutine(LoadTextureFromWWW(c, obj.GetString("url")));
            }

            if (obj.ContainsKey("png") && uint.TryParse(obj.GetString("png"), out var id))
            {
                SetImageFromServer(c, id);
            }

            GraphicComponentCreated(c, obj);

            break;
        }

        case "UnityEngine.UI.Button":
        {
            var c = go.AddComponent <UnityEngine.UI.Button>();

            if (obj.ContainsKey("command"))
            {
                var cmd = obj.GetString("command");
                c.onClick.AddListener(() => { ConsoleNetwork.ClientRunOnServer(cmd); });
            }

            if (obj.ContainsKey("close"))
            {
                var pnlName = obj.GetString("close");
                c.onClick.AddListener(() => { DestroyPanel(pnlName); });
            }

            // bg image
            var img = go.AddComponent <UnityEngine.UI.Image>();
            img.sprite   = FileSystem.Load <Sprite>(obj.GetString("sprite", "Assets/Content/UI/UI.Background.Tile.psd"));
            img.material = FileSystem.Load <Material>(obj.GetString("material", "Assets/Icons/IconMaterial.mat"));
            img.color    = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));
            img.type     = ParseEnum(obj.GetString("imagetype", "Simple"), UnityEngine.UI.Image.Type.Simple);

            c.image = img;

            GraphicComponentCreated(img, obj);

            break;
        }

        case "UnityEngine.UI.Outline":
        {
            var c = go.AddComponent <UnityEngine.UI.Outline>();
            c.effectColor     = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));
            c.effectDistance  = Vector2Ex.Parse(obj.GetString("distance", "1.0 -1.0"));
            c.useGraphicAlpha = obj.ContainsKey("useGraphicAlpha");
            break;
        }

        case "UnityEngine.UI.InputField":
        {
            var t = go.AddComponent <UnityEngine.UI.Text>();
            t.fontSize  = obj.GetInt("fontSize", 14);
            t.font      = FileSystem.Load <Font>("Assets/Content/UI/Fonts/" + obj.GetString("font", "RobotoCondensed-Bold.ttf"));
            t.alignment = ParseEnum(obj.GetString("align"), TextAnchor.UpperLeft);
            t.color     = ColorEx.Parse(obj.GetString("color", "1.0 1.0 1.0 1.0"));

            var c = go.AddComponent <UnityEngine.UI.InputField>();
            c.textComponent  = t;
            c.characterLimit = obj.GetInt("characterLimit", 0);

            if (obj.ContainsKey("command"))
            {
                var cmd = obj.GetString("command");
                c.onEndEdit.AddListener((value) => { ConsoleNetwork.ClientRunOnServer(cmd + " " + value); });
            }
            c.text     = obj.GetString("text", "Text");
            c.readOnly = obj.GetBoolean("readOnly", false);
            c.lineType = ParseEnum(obj.GetString("lineType", "SingleLine"), InputField.LineType.SingleLine);
            if (obj.ContainsKey("password"))
            {
                c.inputType = UnityEngine.UI.InputField.InputType.Password;
            }

            GraphicComponentCreated(t, obj);

            break;
        }

        case "NeedsCursor":
        {
            go.AddComponent <NeedsCursor>();
            break;
        }

        case "RectTransform":
        {
            var rt = go.GetComponent <RectTransform>();
            if (rt)
            {
                rt.anchorMin = Vector2Ex.Parse(obj.GetString("anchormin", "0.0 0.0"));
                rt.anchorMax = Vector2Ex.Parse(obj.GetString("anchormax", "1.0 1.0"));
                rt.offsetMin = Vector2Ex.Parse(obj.GetString("offsetmin", "0.0 0.0"));
                rt.offsetMax = Vector2Ex.Parse(obj.GetString("offsetmax", "1.0 1.0"));
            }
            break;
        }

        case "Countdown":
        {
            var c = go.AddComponent <Countdown>();
            c.endTime   = obj.GetInt("endTime", 0);
            c.startTime = obj.GetInt("startTime", 0);
            c.step      = obj.GetInt("step", 1);

            if (obj.ContainsKey("command"))
            {
                c.command = obj.GetString("command");
            }

            break;
        }

        case "UnityEngine.UI.VerticalLayoutGroup":
        {
            var        vlg          = go.AddComponent <VerticalLayoutGroup>();
            var        paddingArray = obj.GetString("padding", "0").Split(' ');
            RectOffset padding      = null;
            if (paddingArray.Length > 0)
            {
                padding      = new RectOffset();
                padding.left = int.Parse(paddingArray[0]);

                if (paddingArray.Length > 1)
                {
                    padding.right = int.Parse(paddingArray[1]);

                    if (paddingArray.Length > 2)
                    {
                        padding.top = int.Parse(paddingArray[2]);

                        if (paddingArray.Length > 3)
                        {
                            padding.bottom = int.Parse(paddingArray[3]);
                        }
                    }
                }
            }

            if (padding != null)
            {
                vlg.padding = padding;
            }

            vlg.spacing        = obj.GetInt("spacing", 0);
            vlg.childAlignment = (TextAnchor)System.Enum.Parse(typeof(TextAnchor), obj.GetString("childAlignment", "UpperLeft"));

            if (obj.ContainsKey("childControlWidth"))
            {
                vlg.childControlWidth = true;
            }

            if (obj.ContainsKey("childControlHeight"))
            {
                vlg.childControlHeight = true;
            }

            if (obj.ContainsKey("childForceExpandWidth"))
            {
                vlg.childForceExpandWidth = true;
            }

            if (obj.ContainsKey("childForceExpandHeight"))
            {
                vlg.childForceExpandHeight = true;
            }
            break;
        }

        case "UnityEngine.UI.HorizontalLayoutGroup":
        {
            var        hlg          = go.AddComponent <HorizontalLayoutGroup>();
            var        paddingArray = obj.GetString("padding", "0").Split(' ');
            RectOffset padding      = null;
            if (paddingArray.Length > 0)
            {
                padding      = new RectOffset();
                padding.left = int.Parse(paddingArray[0]);

                if (paddingArray.Length > 1)
                {
                    padding.right = int.Parse(paddingArray[1]);

                    if (paddingArray.Length > 2)
                    {
                        padding.top = int.Parse(paddingArray[2]);

                        if (paddingArray.Length > 3)
                        {
                            padding.bottom = int.Parse(paddingArray[3]);
                        }
                    }
                }
            }

            if (padding != null)
            {
                hlg.padding = padding;
            }

            hlg.spacing        = obj.GetInt("spacing", 0);
            hlg.childAlignment = (TextAnchor)System.Enum.Parse(typeof(TextAnchor), obj.GetString("childAlignment", "UpperLeft"));

            if (obj.ContainsKey("childControlWidth"))
            {
                hlg.childControlWidth = true;
            }

            if (obj.ContainsKey("childControlHeight"))
            {
                hlg.childControlHeight = true;
            }

            if (obj.ContainsKey("childForceExpandWidth"))
            {
                hlg.childForceExpandWidth = true;
            }

            if (obj.ContainsKey("childForceExpandHeight"))
            {
                hlg.childForceExpandHeight = true;
            }
            break;
        }

        case "UnityEngine.UI.LayoutElement":
        {
            var le = go.AddComponent <LayoutElement>();

            if (obj.ContainsKey("ignoreLayout"))
            {
                le.ignoreLayout = true;
                break;
            }

            if (obj.ContainsKey("minWidth"))
            {
                le.minWidth = obj.GetFloat("minWidth", 0);
            }

            if (obj.ContainsKey("minHeight"))
            {
                le.minHeight = obj.GetFloat("minHeight", 0);
            }

            if (obj.ContainsKey("preferredWidth"))
            {
                le.preferredWidth = obj.GetFloat("preferredWidth", 0);
            }

            if (obj.ContainsKey("preferredHeight"))
            {
                le.preferredHeight = obj.GetFloat("preferredHeight", 0);
            }

            if (obj.ContainsKey("flexibleWidth"))
            {
                le.flexibleWidth = obj.GetFloat("flexibleWidth", 0);
            }

            if (obj.ContainsKey("flexibleHeight"))
            {
                le.flexibleHeight = obj.GetFloat("flexibleHeight", 0);
            }

            if (obj.ContainsKey("layoutPriority"))
            {
                le.layoutPriority = obj.GetInt("layoutPriority", 1);
            }

            break;
        }

        case "NeedsKeyboard":
        {
            go.AddComponent <NeedsKeyboard>();
            break;
        }
        }
    }