Example #1
0
    public static HCanvas GetData(HGUIRender render)
    {
        string guid = render.GetGuid();

        for (int i = 0; i < CanvasCash.Count; i++)
        {
            if (guid == CanvasCash[i].guid)
            {
                return(CanvasCash[i].Root as HCanvas);
            }
        }
        string dic  = Environment.CurrentDirectory + "/hgui2";
        string path = dic + "/" + render.GetGuid() + ".bytes";

        if (File.Exists(path))
        {
            byte[] dat = File.ReadAllBytes(path);
            huqiang.Core.HGUI.UIElement.DisposeAll();
            if (HGUIManager.GameBuffer == null)
            {
                HGUIManager.Initial();
            }
            if (render.canvas == null)
            {
                render.canvas = new HCanvas();
            }
            CloneAll(new DataBuffer(dat), render.canvas);
            DataContext dc = new DataContext();
            dc.guid = guid;
            dc.Root = render.canvas;
            CanvasCash.Add(dc);
            return(render.canvas);
        }
        return(null);
    }
Example #2
0
        public override void Initial(FakeStruct mod, UIElement script)
        {
            base.Initial(mod, script);
            Main = script.transform;
            int c = Main.childCount;

            if (c > 0)
            {
                var it = Main.Find("Item").gameObject;
                HGUIManager.GameBuffer.RecycleGameObject(it);
                var sli = Main.Find("Slider");
                if (sli != null)
                {
                    var ui = sli.GetComponent <UIElement>();
                    Slider = ui.composite as UISlider;
                }
                ItemMod = HGUIManager.FindChild(mod, "Item");
                unsafe
                {
                    ItemSize = ((TransfromData *)ItemMod.ip)->size;
                    var ex = mod.buffer.GetData(((TransfromData *)mod.ip)->ex) as FakeStruct;
                    if (ex != null)
                    {
                        ScrollInfo *tp = (ScrollInfo *)ex.ip;
                        scrollType = tp->scrollType;
                        MinBox     = tp->minBox;
                    }
                }
            }
        }
Example #3
0
    static void Create(string Assetname, string dicpath, GameObject gameObject)
    {
        if (Assetname == null)
        {
            return;
        }
        if (Assetname == "")
        {
            return;
        }
        LoadBundle();
        Assetname = Assetname.Replace(" ", "");
        var dc = dicpath;

        if (dc == null | dc == "")
        {
            dc = Application.dataPath + "/AssetsBundle/";
            if (!Directory.Exists(dc))
            {
                Directory.CreateDirectory(dc);
            }
        }
        dc += Assetname;
        HGUIManager.Initial(gameObject.transform);
        HGUIManager.SavePrefab(gameObject.transform, dc);
        Debug.Log("create done path:" + dc);
    }
Example #4
0
 static void CloneAll(byte[] ui, Transform root)
 {
     if (ui != null)
     {
         HGUIManager.Initial(root);
         var fake  = HGUIManager.LoadModels(ui, "assTest").models;
         var child = HGUIManager.GetAllChild(fake);
         if (child != null)
         {
             Initializer initializer = new Initializer();
             for (int i = 0; i < child.Length; i++)
             {
                 var go = HGUIManager.Clone(child[i], initializer);
                 if (go != null)
                 {
                     var trans = go.transform;
                     trans.SetParent(root);
                     trans.localPosition = Vector3.zero;
                     trans.localScale    = Vector3.one;
                     trans.localRotation = Quaternion.identity;
                 }
             }
         }
     }
 }
Example #5
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="fake">数据模型</param>
        /// <param name="element">主体元素</param>
        public override void Initial(FakeStruct fake, UIElement element, UIInitializer initializer)
        {
            base.Initial(fake, element, initializer);
            element.SizeChanged   = (o) => { Refresh(); };
            eventCall             = Enity.RegEvent <UserEvent>();
            eventCall.PointerDown = (o, e) => { UpdateVelocity = false; };
            eventCall.Drag        = (o, e, s) => { Scrolling(o, s); };
            eventCall.DragEnd     = OnDragEnd;
            eventCall.MouseWheel  = (o, e) => {
                Point += BounceBack((e.MouseWheelDelta * 100));
                Order();
                UpdateVelocity = true;
            };
            eventCall.ForceEvent = true;
            Size = Enity.SizeDelta;
            eventCall.CutRect = true;
            BodyParent        = element.Find("Bodys");
            TitleParent       = element.Find("Titles");
            HGUIManager.RecycleChild(Enity, new string[] { "Bodys", "Titles" });

            TitleMod  = HGUIManager.FindChild(fake, "Title");
            ItemMod   = HGUIManager.FindChild(fake, "Item");
            TailMod   = HGUIManager.FindChild(fake, "Tail");
            Body      = HGUIManager.FindChild(fake, "Body");
            ItemSize  = UIElementLoader.GetSize(ItemMod);
            TitleSize = UIElementLoader.GetSize(TitleMod);
            if (TailMod != null)
            {
                TailSize = UIElementLoader.GetSize(TailMod);
            }
        }
Example #6
0
        /// <summary>
        /// 创建项目实例,如果缓存中有则从缓存中提前
        /// </summary>
        /// <returns></returns>
        protected TreeViewItem CreateItem()
        {
            TreeViewItem it = queue.Dequeue();

            if (it != null)
            {
                it.target.activeSelf = true;
                return(it);
            }
            if (creator != null)
            {
                var t = creator.Create();
                t.target = HGUIManager.Clone(ItemMod, creator.initializer);
                var trans = t.target;
                trans.SetParent(Enity);
                trans.localScale    = Vector3.one;
                trans.localRotation = Quaternion.identity;
                return(t);
            }
            else
            {
                var go = HGUIManager.Clone(ItemMod);
                go.SetParent(Enity);
                go.localScale    = Vector3.one;
                go.localRotation = Quaternion.identity;
                TreeViewItem a = new TreeViewItem();
                a.target           = go;
                a.Text             = go as HText;
                a.Item             = go.RegEvent <UserEvent>();
                a.Item.Click       = DefultItemClick;
                a.Item.DataContext = a;
                return(a);
            }
        }
Example #7
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="fake">数据模型</param>
        /// <param name="element">主体元素</param>
        public override void Initial(FakeStruct fake, UIElement element, Initializer initializer)
        {
            base.Initial(fake, element, initializer);
            element.SizeChanged  = (o) => { Refresh(); };
            eventCall            = Enity.RegEvent <UserEvent>();
            eventCall.Drag       = (o, e, s) => { Scrolling(o, s); };
            eventCall.DragEnd    = (o, e, s) => { Scrolling(o, s); };
            eventCall.ScrollEndY = OnScrollEnd;
            eventCall.Scrolling  = Scrolling;
            eventCall.ForceEvent = true;
            Size = Enity.SizeDelta;
            eventCall.CutRect = true;
            var trans = element.transform;

            BodyParent  = trans.Find("Bodys");
            TitleParent = trans.Find("Titles");
            HGUIManager.GameBuffer.RecycleChild(Enity.gameObject, new string[] { "Bodys", "Titles" });

            TitleMod = HGUIManager.FindChild(fake, "Title");
            ItemMod  = HGUIManager.FindChild(fake, "Item");
            TailMod  = HGUIManager.FindChild(fake, "Tail");
            Body     = HGUIManager.FindChild(fake, "Body");
            unsafe
            {
                ItemSize  = ((UITransfromData *)ItemMod.ip)->size;
                TitleSize = ((UITransfromData *)TitleMod.ip)->size;
                if (TailMod != null)
                {
                    TailSize = ((UITransfromData *)TailMod.ip)->size;
                }
            }
        }
Example #8
0
        /// <summary>
        /// 创建项目
        /// </summary>
        /// <param name="buffer">项目缓存</param>
        /// <param name="con">构造器</param>
        /// <param name="mod">UI模型数据</param>
        /// <param name="parent">父坐标变换</param>
        /// <returns></returns>
        protected ScrollItem CreateItem(List <ScrollItem> buffer, Constructor con, FakeStruct mod, UIElement parent)
        {
            if (buffer.Count > 0)
            {
                var it = buffer[0];
                it.target.activeSelf = true;
                it.index             = -1;
                buffer.RemoveAt(0);
                return(it);
            }
            ScrollItem a = new ScrollItem();

            if (con == null)
            {
                a.obj = a.target = HGUIManager.Clone(mod);
            }
            else
            {
                a.obj    = con.Create();
                a.target = HGUIManager.Clone(mod, con.initializer);
            }
            a.target.SetParent(parent);
            a.target.localScale    = Vector3.one;
            a.target.localRotation = Quaternion.identity;
            return(a);
        }
Example #9
0
        void MItemCreate(ObjectLinker obj, LinkerMod mod)
        {
            T t = new T();

            initializer.Reset(t);
            mod.main = HGUIManager.Clone(model, initializer);
            mod.UI   = t;
        }
Example #10
0
 /// <summary>
 /// 设置标尾更新函数
 /// </summary>
 /// <param name="constructor">热更新的中间件</param>
 public void SetTailUpdate(HotMiddleware constructor)
 {
     for (int i = 0; i < Tails.Count; i++)
     {
         HGUIManager.RecycleUI(Tails[i].target);
     }
     Tails.Clear();
     TailCreator = constructor;
 }
Example #11
0
 /// <summary>
 /// 设置项目更新函数
 /// </summary>
 /// <param name="constructor">热更新的中间件</param>
 public void SetItemUpdate(HotMiddleware constructor)
 {
     for (int i = 0; i < Items.Count; i++)
     {
         HGUIManager.RecycleUI(Items[i].target);
     }
     Items.Clear();
     ItemCreator = constructor;
 }
Example #12
0
 public HotUILinker(UIContainer container, string mod)
 {
     con                   = container;
     model                 = HGUIManager.FindChild(container.model, mod);
     middle                = new ObjectLinker(container);
     middle.ItemUpdate     = MItemUpdate;
     middle.CalculItemHigh = MCalculItemHigh;
     middle.ItemCreate     = MItemCreate;
     initializer           = new UIInitializer(HotUIBase.ObjectFields(typeof(T)));
 }
Example #13
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="lay">停靠面板主体</param>
 public DockpanelArea(DockPanel lay)
 {
     layout = lay;
     model  = HGUIManager.Clone(layout.AreaMod);
     layout = lay;
     model.SetParent(layout.AreaLevel);
     model.localPosition = Vector3.zero;
     model.localScale    = Vector3.one;
     model.localRotation = Quaternion.identity;
     layout.areas.Add(this);
 }
Example #14
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="container">容器实例</param>
 /// <param name="mod">模型名称</param>
 public UILinker(UIContainer container, string mod)
 {
     if (container.model == null)
     {
         return;
     }
     con   = container;
     model = HGUIManager.FindChild(container.model, mod);
     container.linkers.Add(this);
     initializer = new UIInitializer(TempReflection.ObjectFields(typeof(T)));
 }
Example #15
0
 /// <summary>
 /// 初始化函数
 /// </summary>
 /// <param name="fake">数据模型</param>
 /// <param name="element">UI主体元素</param>
 public override void Initial(FakeStruct fake, UIElement element, UIInitializer initializer)
 {
     contents.Clear();
     base.Initial(fake, element, initializer);
     Auxiliary       = HGUIManager.FindChild(fake, "Auxiliary");
     Drag            = element.Find("Drag");
     Drag.activeSelf = false;
     MainContent     = new DesignedDockAuxiliary(this);
     MainContent.Initial(MainArea, element.Find("Auxiliary"));
     contents.Add(MainContent);
     MainContent.SetParent(MainArea);
 }
Example #16
0
        /// <summary>
        /// 设置标尾更新函数
        /// </summary>
        /// <typeparam name="T">UI模板</typeparam>
        /// <typeparam name="U">数据模板</typeparam>
        /// <param name="action">更新函数回调</param>
        public void SetTailUpdate <T, U>(Action <T, U, int> action) where T : class, new()
        {
            for (int i = 0; i < Tails.Count; i++)
            {
                HGUIManager.RecycleUI(Tails[i].target);
            }
            Tails.Clear();
            var m = new Middleware <T, U>();

            m.Invoke    = action;
            TailCreator = m;
        }
Example #17
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     if (LineStart != null)
     {
         LineStart.AdjacentLines.Remove(this);
     }
     if (LineEnd != null)
     {
         LineEnd.AdjacentLines.Remove(this);
     }
     layout.lines.Remove(this);
     HGUIManager.RecycleUI(Enity);
 }
Example #18
0
        static void CreateUI()
        {
            UIPage.Initial(UIRoot);
            UIMenu.Initial(UIRoot);
            UINotify.Initial(UIRoot);

            var buff = new GameObject("Buffer");

            buff.transform.SetParent(UIRoot);
            buff.SetActive(false);
            buff.transform.localScale = Vector3.one;
            HGUIManager.Initial(buff.transform);
        }
Example #19
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     if (Left.realLine | Right.realLine | Top.realLine | Down.realLine)
     {
         Left.Right.Remove(this);
         Right.Left.Remove(this);
         Top.Down.Remove(this);
         Down.Top.Remove(this);
         MergeArea();
         HGUIManager.RecycleUI(model);
         layout.areas.Remove(this);
     }
 }
Example #20
0
        static void CreateUI()
        {
            UIPage.Initial(UIRoot);
            UIMenu.Initial(UIRoot);
            UINotify.Initial(UIRoot);

            var buff = new UIElement();

            buff.name = "Buffer";
            buff.SetParent(UIRoot);
            buff.activeSelf = false;
            buff.localScale = Vector3.one;
            HGUIManager.Initial();
        }
        public override void Initial(FakeStruct fake, UIElement element)
        {
            contents.Clear();
            base.Initial(fake, element);
            Auxiliary = HGUIManager.FindChild(fake, "Auxiliary");
            var trans = element.transform;

            Drag = trans.Find("Drag").GetComponent <UIElement>();
            Drag.gameObject.SetActive(false);
            MainContent = new DesignedDockAuxiliary(this);
            MainContent.Initial(MainArea, trans.Find("Auxiliary").GetComponent <UIElement>());
            contents.Add(MainContent);
            MainContent.SetParent(MainArea);
        }
Example #22
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public virtual void Dispose()
 {
     if (Main != null)
     {
         HGUIManager.RecycleUI(Main);
     }
     point--;
     if (buff[point] != null)
     {
         buff[point].Index = Index;
     }
     buff[Index] = buff[point];
     buff[point] = null;
 }
Example #23
0
        /// <summary>
        /// 添加可停靠区域
        /// </summary>
        /// <param name="dock">区域停靠方位</param>
        /// <param name="r">占用大小</param>
        /// <returns></returns>
        public DesignedDockAuxiliary AddArea(DockpanelArea.Dock dock, float r = 0.5f)
        {
            var area = dockArea.AddAreaR(dock, r);
            var go   = HGUIManager.Clone(layout.Auxiliary);

            go.SetParent(area.model);
            go.localScale    = Vector3.one;
            go.localRotation = Quaternion.identity;
            var con = new DesignedDockAuxiliary(layout);

            con.Initial(area, go);
            layout.contents.Add(con);
            return(con);
        }
Example #24
0
        /// <summary>
        /// 创建一个实例,如果回收缓存中有就从缓存中提取
        /// </summary>
        /// <returns></returns>
        public DataGridItem CreateEnity()
        {
            DataGridItem it = buf.Dequeue();

            if (it != null)
            {
                it.target.activeSelf = true;
                return(it);
            }
            var t = itemCreator.Create() as DataGridItem;

            t.target = HGUIManager.Clone(mod, itemCreator.initializer);
            return(t);
        }
        public override void Initial(FakeStruct fake, UIElement element)
        {
            base.Initial(fake, element);
            var mod = Enity.transform;

            LineLevel = mod.Find("LineLevel");
            AreaLevel = mod.Find("AreaLevel");
            LineMod   = HGUIManager.FindChild(fake, "Line");
            AreaMod   = HGUIManager.FindChild(fake, "Area");
            HGUIManager.GameBuffer.RecycleGameObject(mod.Find("Line").gameObject);
            HGUIManager.GameBuffer.RecycleGameObject(mod.Find("Area").gameObject);
            InitialFixLine();
            InitialArea();
            Enity.SizeChanged = SizeChanged;
        }
Example #26
0
    public void Initital()
    {
        LoadBundle();
        HGUIManager.Initial();
        var db = HGUIManager.GetPrefab(TargetCanvas);

        HGUIManager.prefabAssets.Clear();
        HGUIManager.LoadModels(db, AssetName);
        var c = transform.childCount;

        for (int i = 0; i < c; i++)
        {
            GameObject.Destroy(transform.GetChild(i).gameObject);
        }
    }
Example #27
0
    public T LoadUI <T>(string asset, string name) where T : class, new()
    {
        model = HGUIManager.FindModel(asset, name);
        T             t            = new T();
        UIInitializer iInitializer = new UIInitializer(TempReflection.ObjectFields(typeof(T)));

        iInitializer.Reset(t);
        Main = HGUIManager.GameBuffer.Clone(model, iInitializer);
        var trans = Main.transform;

        trans.SetParent(Parent);
        trans.localPosition = Vector3.zero;
        trans.localScale    = Vector3.one;
        trans.localRotation = Quaternion.identity;
        return(t);
    }
Example #28
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="fake">数据模型</param>
 /// <param name="script">元素主体</param>
 public override void Initial(FakeStruct fake, UIElement script, UIInitializer initializer)
 {
     base.Initial(fake, script, initializer);
     items                 = new List <Item>();
     eventCall             = Enity.RegEvent <UserEvent>();
     eventCall.AutoColor   = false;
     eventCall.ForceEvent  = true;
     eventCall.PointerDown = (o, e) => { UpdateVelocity = false; };
     eventCall.Drag        = (o, e, s) => { Scrolling(o, s); };
     eventCall.DragEnd     = OnDragEnd;
     //eventCall.Scrolling = Scrolling;
     //eventCall.ScrollEndY = OnScrollEnd;
     eventCall.MouseWheel = (o, e) => { Move(e.MouseWheelDelta * 100); UpdateVelocity = true; };
     model = fake;
     HGUIManager.RecycleChild(Enity);
 }
Example #29
0
    protected override void Start()
    {
        base.Start();
        Instance       = this;
        Scale.DpiScale = true;
        App.Initial(transform);
        DontDestroyOnLoad(gameObject);
        HGUIManager.LoadModels(baseUI.bytes, "baseUI");
#if UNITY_EDITOR
        AssetBundle.UnloadAllAssetBundles(true);
#endif
        //ElementAsset.LoadAssetsAsync("base.unity3d").PlayOver = (o, e) =>
        //{
        UIPage.LoadPage <LoadingPage>("checkOss");
        // };
        KcpDataControll.Instance.Connection("193.112.70.170", 8899);
    }
Example #30
0
    public override void Initial(Transform parent, object dat = null)
    {
        base.Initial(parent, dat);
        string dic  = Application.persistentDataPath + "/";
        string path = dic + "baseUI.bytes";

        if (File.Exists(path))
        {
            byte[] ui = File.ReadAllBytes(dic + "baseUI.bytes");
            HGUIManager.LoadModels(ui, "baseUI");
        }
        string dll = dic + "HotFix.dll";
        string pdb = dic + "HotFix.dll";

        HotFix.Instance.Load(File.ReadAllBytes(dll));
        HotFix.Instance.Start(Parent, "Start", dat);
    }