Пример #1
0
    static GameObject CreateGameObject(huqiang.Core.HGUI.UIElement ui, Initializer ini)
    {
        GameObject go = new GameObject();

        go.name = ui.name;
        switch (ui.TypeName)
        {
        case huqiang.Core.HGUI.UIType.UIElement:
            var tar = go.AddComponent <UIElement>();
            tar.Content = ui;
            break;

        case huqiang.Core.HGUI.UIType.HImage:
            var img = go.AddComponent <HImage>();
            img.Content = ui as huqiang.Core.HGUI.HImage;
            break;

        case huqiang.Core.HGUI.UIType.HText:
            var txt = go.AddComponent <HText>();
            txt.Content = ui as huqiang.Core.HGUI.HText;
            break;

        case huqiang.Core.HGUI.UIType.TextBox:
            var tb = go.AddComponent <TextBox>();
            tb.Content = ui as huqiang.Core.HGUI.TextBox;
            break;

        case huqiang.Core.HGUI.UIType.HLine:
            var line = go.AddComponent <HLine>();
            line.Content = ui as huqiang.Core.HGUI.HLine;
            break;

        case huqiang.Core.HGUI.UIType.HGraphics:
            var gra = go.AddComponent <HGraphics>();
            gra.Content = ui as huqiang.Core.HGUI.HGraphics;
            break;

        case huqiang.Core.HGUI.UIType.HCanvas:
            var can = go.AddComponent <HCanvas>();
            can.Content = ui as huqiang.Core.HGUI.HCanvas;
            break;
        }
        ui.Context = go.transform;
        unsafe
        {
            var src = (huqiang.Core.UIData.UIElementData *)ui.mod.ip;
            ini.AddContext(ui.Context, src->insID);
            LoadHelper(go, ui.mod.buffer, src->ex, ini);
            LoadHelper(go, ui.mod.buffer, src->composite, ini);
            LoadHelper(go, ui.mod.buffer, src->ex, ini);
        }

        if (ui.parent != null)
        {
            ui.Context.SetParent(ui.parent.Context);
            ui.Context.localPosition = ui.localPosition;
            ui.Context.localRotation = ui.localRotation;
            ui.Context.localScale    = ui.localScale;
        }
        var c = ui.child.Count;

        for (int i = 0; i < c; i++)
        {
            CreateGameObject(ui.child[i], ini);
        }
        return(go);
    }