Exemplo n.º 1
0
    public int Play(int id, Transform parent = null)
    {
        try
        {
            if (!this.effectPools.ContainsKey(id))
            {
                var prefab = EffectAssets.LoadEffect(id);
                this.effectPools[id] = GameObjectPoolUtil.Create(prefab);
            }

            var pool      = this.effectPools[id];
            var instance  = pool.Get();
            var behaviour = instance.GetComponent <EffectBehaviour>();
            behaviour.effectId = id;

            if (!behaviour.gameObject.activeInHierarchy)
            {
                behaviour.SetActive(true);
            }

            playInstanceId++;
            playingEffect[playInstanceId] = behaviour;
            behaviour.OnPlay(playInstanceId, parent);
            return(playInstanceId);
        }
        catch (System.Exception ex)
        {
            DebugEx.Log(ex);
            return(0);
        }
    }
Exemplo n.º 2
0
    public static void CreatePoolDebugWindow()
    {
        GameObjectPoolUtil.CreatePoolDebugWindow();
        var window = GetWindow(typeof(UIPoolDebugWindow), false, "对象池Debug") as UIPoolDebugWindow;

        window.Show();
        window.pools = EditorHelper.gameObjectPools;
        window.autoRepaintOnSceneChange = true;
    }
Exemplo n.º 3
0
    public static HeadUpGuild Get()
    {
        if (pool == null)
        {
            pool = GameObjectPoolUtil.Create(UIAssets.LoadPrefab("HeadUpGuild"));
        }

        var gameObject = pool.Get();

        return(gameObject.GetComponent <HeadUpGuild>());
    }
Exemplo n.º 4
0
    public static GameObject GetBody(int id)
    {
        if (!pools.ContainsKey(id))
        {
            var prefab = MobAssets.LoadPrefab(id);
            pools[id] = GameObjectPoolUtil.Create(prefab);
        }

        var pool = pools[id];

        return(pool.Get());
    }
Exemplo n.º 5
0
    public static DamageNum Get(DamageNum.Pattern pattern)
    {
        var intPattern = (int)pattern;

        if (pools.ContainsKey(intPattern))
        {
            pools[intPattern] = GameObjectPoolUtil.Create(UIAssets.LoadPrefab("DamageNum_" + intPattern));
        }

        var pool       = pools[intPattern];
        var gameObject = pool.Get();

        return(gameObject.GetComponent <DamageNum>());
    }