Beispiel #1
0
    public void PlayUIEffect(GameObject rootUI, string name, float elapsedTime, LuaFunction callback, bool isAbove, bool isForever, UIEffectAddType addType = UIEffectAddType.Keep)
    {
        switch (addType)
        {
        case UIEffectAddType.Keep:
        {
            Transform child = this.transform.FindChild(name + "(Clone)");
            if (child != null)
            {
                return;
            }
        } break;

        case UIEffectAddType.Replace:
        {
            StopUIEffect(name);
        } break;

        case UIEffectAddType.Overlying:
        {
        } break;

        default:
            return;
        }

        AssetLoader loader = AssetBundleManager.CreateLoader();

        loader.LoadAsync(GameResType.Effect, name, (asset) =>
        {
            GameObject effect = GameObject.Instantiate(asset) as GameObject;
            effect.transform.SetParent(this.transform);
            effect.transform.localPosition    = Vector3.zero;
            effect.transform.localEulerAngles = Vector3.zero;
            effect.transform.localScale       = Vector3.one;
            EffectController ec = effect.AddComponent <EffectController>();
            ec.elapsedTime      = elapsedTime;
            ec.forever          = isForever;
            UILayer layer       = effect.gameObject.AddComponent <UILayer>();
            layer.type          = UILayerType.UIEffect;
            layer.canvas        = rootUI.GetComponent <Canvas>();
            layer.AssetLoader   = loader;
            if (layer.canvas != null)
            {
                layer.sortingOrder = layer.canvas.sortingOrder + (isAbove ? 1 : -1);
                layer.AdjustCanvasSortingOrder();
            }

            if (callback != null)
            {
                callback.Call(effect);
                callback.Dispose();
            }
        });
    }
Beispiel #2
0
    public GameObject LoadUIEffect(GameObject rootUI, string name, bool isAbove, bool dontDestory)
    {
        AssetLoader loader = dontDestory ? AssetBundleManager.godLoader : AssetBundleManager.CreateLoader();

        UnityEngine.Object asset  = loader.Load(GameResType.Effect, name);
        GameObject         effect = GameObject.Instantiate(asset) as GameObject;

        UILayer layer = effect.gameObject.AddComponent <UILayer>();

        layer.type   = UILayerType.UIEffect;
        layer.canvas = rootUI.GetComponent <Canvas>();
        if (!dontDestory)
        {
            layer.AssetLoader = loader;
        }
        if (layer.canvas != null)
        {
            layer.sortingOrder = layer.canvas.sortingOrder + (isAbove ? 1 : -1);
        }

        return(effect);
    }