예제 #1
0
    //播放受击特效
    public uint ReqPlayHitFx(string fx_name, Vector3 position, Vector3 rotation, Vector3 scale, int level = 0)
    {
        Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
        if (rs == null)
        {
            return(0);
        }
        if (string.IsNullOrEmpty(fx_name))
        {
            return(0);
        }
        string path = fx_name;// (FxDir + fx_name).Replace(".prefab", ".fx").ToLower();

        IEffect effect = null;

        rs.CreateEffect(ref path, ref effect, (obj) =>
        {
            if (obj == null)
            {
                Log.LogGroup("ZDY", "fx load failed: {0}", path);
                return;
            }
            if (obj.GetNodeTransForm() == null)
            {
                return;
            }
            DoPlay(obj.GetNodeTransForm().gameObject, position, rotation, scale);
        }, nLevel: level);
        return(effect.GetID());
    }
예제 #2
0
    /// <summary>
    /// //挂接特效
    /// </summary>
    /// <param name="fx_name"></param>
    /// <param name="attach_node">挂节点</param>
    /// <param name="position">偏移位置</param>
    /// <param name="scale">缩放</param>
    public uint ReqPlayFx(string fx_name, Transform attach_node, Vector3 position, Vector3 scale, int level = 0)
    {
        Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
        if (rs == null)
        {
            return(0);
        }
        string path = fx_name;

        if (fx_name.EndsWith(".prefab"))
        {//先做下对老的兼容
            path = (FxDir + fx_name).Replace(".prefab", ".fx").ToLower();
        }

        IEffect effect = null;

        rs.CreateEffect(ref path, ref effect, (obj) =>
        {
            if (obj == null)
            {
                Log.Error("ReqPlayFx obj ================ fx load failed: " + path);
                return;
            }
            if (obj.GetNodeTransForm() == null)
            {
                Log.Error("ReqPlayFx GetNodeTransForm ================ fx load failed: " + path);
                return;
            }
            DoPlay(obj.GetNodeTransForm().gameObject, attach_node, position, scale);
        }, nLevel: level);
        return(effect.GetID());
    }