예제 #1
0
        /// <summary>
        /// 加载window
        /// </summary>
        /// <param name="name"></param>
        public void preLoadWindow(GameConfiger game, string name)
        {
            GameObject windowPrefab = AssetManager.Instance.loadWindowAsset(game, name);

            windowPrefab = Instantiate(windowPrefab, CanvasTrans.Root);
            windowPrefab.SetActive(false);
            windowsDic.Add(name, windowPrefab.GetComponent <WindowBase>());
        }
예제 #2
0
        /// <summary>
        /// 获取window引用
        /// </summary>
        /// <param name="name">window名字</param>
        public WindowBase getWindow(GameConfiger game, string name)
        {
            if (!windowsDic.ContainsKey(name))
            {
                preLoadWindow(game, name);
            }

            WindowBase window = windowsDic[name];

            return(window);
        }
예제 #3
0
        public GameObject loadWindowAsset(GameConfiger game, string name)
        {
            string gameName   = game.ToString().ToLower();
            string prefabName = name.ToLower();

            string filePath = gameName + "/" + prefabName;

            AssetBundle windowAB     = loadAsset(gameName, filePath, prefabName);
            GameObject  windowPrefab = windowAB.LoadAsset <GameObject>(prefabName);

            return(windowPrefab);
        }
예제 #4
0
 /// <summary>
 /// 加载widget
 /// </summary>
 /// <param name="name"></param>
 public void preLoadWidget(GameConfiger game, string name)
 {
     if (!widgetsDic.ContainsKey(name))
     {
         GameObject widgetPrefab = AssetManager.Instance.loadWindowAsset(game, name);
         widgetPrefab = Instantiate(widgetPrefab, CanvasTrans.Root);
         widgetPrefab.SetActive(false);
         widgetsDic.Add(name, widgetPrefab.GetComponent <WidgetBase>());
         if (!widgetsPool.ContainsKey(name))
         {
             widgetsPool.Add(name, new Queue <GameObject>());
         }
         widgetsPool[name].Enqueue(widgetPrefab);
     }
 }
예제 #5
0
        /// <summary>
        /// 打开widget
        /// </summary>
        /// <param name="name">widget名字</param>
        public WidgetBase newWidget(GameConfiger game, string name, params object[] parameters)
        {
            if (!widgetsDic.ContainsKey(name))
            {
                preLoadWidget(game, name);
            }

            if (widgetsPool[name].Count <= 1)
            {
                GameObject widgetPrefab = widgetsPool[name].Dequeue();
                GameObject widgetClone  = Instantiate(widgetPrefab);
                widgetsPool[name].Enqueue(widgetPrefab);
                widgetsPool[name].Enqueue(widgetClone);
            }

            WidgetBase widget = widgetsPool[name].Dequeue().GetComponent <WidgetBase>();

            //widget.rename(name);
            widget.show(parameters);
            return(widget);
        }
예제 #6
0
        public Sprite loadSpriteAsset(GameConfiger game, string name)
        {
            if (assetsRef.ContainsKey(name))
            {
                return(assetsRef[name] as Sprite);
            }

            string gameName   = game.ToString().ToLower();
            string prefabName = name.ToLower();

            string filePath = gameName + "/" + prefabName;

            AssetBundle spriteAB = loadAsset(gameName, filePath, prefabName);

            string[] str = prefabName.Split('/');
            prefabName = str[str.Length - 1];
            Texture2D texture2D = spriteAB.LoadAsset <Texture2D>(prefabName);
            Sprite    sprite    = Sprite.Create(texture2D, new Rect(0.0f, 0.0f, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f), 100.0f);

            assetsRef.Add(name, sprite);
            return(sprite);
        }