Esempio n. 1
0
    public void Init()
    {
        if (player != null)
        {
            return;
        }

        if (anim != null && mesh != null && mtrl != null && textureRawData != null)
        {
            GPUSkinningPlayerResources res = null;

            if (Application.isPlaying)
            {
                playerManager.Register(anim, mesh, mtrl, textureRawData, this, out res);
            }
            else
            {
                res                   = new GPUSkinningPlayerResources();
                res.anim              = anim;
                res.mesh              = mesh;
                res.mtrl              = new Material(mtrl);
                res.texture           = GPUSkinningUtil.CreateTexture2D(textureRawData, anim);
                res.mtrl.hideFlags    = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor;
                res.texture.hideFlags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor;
            }

            player = new GPUSkinningPlayer(gameObject, res);
            player.RootMotionEnabled = Application.isPlaying ? rootMotionEnabled : false;

            if (anim != null && anim.clips != null && anim.clips.Length > 0)
            {
                player.Play(anim.clips[Mathf.Clamp(defaultPlayingClipIndex, 0, anim.clips.Length)].name);
            }
        }
    }
    private void Start()
    {
        player = GetComponent <GPUSkinningPlayerMono>().Player;
        player.Play("Idle");

        actionTime = Random.Range(5, 30);
    }
    private void Start()
    {
        thisTransform = transform;
        camTransform  = Camera.main.transform;

        camOffsetPos = camTransform.position - thisTransform.position;

        player = GetComponent <GPUSkinningPlayerMono>().Player;
        player.Play("Idle");
    }
    private void Start()
    {
        QualitySettings.shadows = ShadowQuality.Disable;

        thisTransform = transform;
        camTransform  = Camera.main.transform;

        camOffsetPos = camTransform.position - thisTransform.position;

        player = GetComponent <GPUSkinningPlayerMono>().Player;
        player.Play("Idle");
    }
    /// <summary>
    /// 初始化PlayerMono设置:
    /// 创建/查询对应的GPUSkinningPlayerResources,通过GPUSkinningPlayerManager管理
    /// fzy remark:初始化存在潜在的开销问题,在首次生成PlayerMono时,Creating CullingBounds会产生较大的开销
    /// </summary>
    public void Init()
    {
        //player != null 表示已经初始化,return结束执行
        if (player != null)
        {
            return;
        }

        GPUSkinningPlayerResources res = null;

        //所有属性设置完毕,开始初始化
        if (anim != null && mesh != null && mtrl != null && textureRawData != null)
        {
            //运行时,注册蒙皮网格、动画、材质等数据
            if (Application.isPlaying)
            {
                playerManager.Register(anim, mesh, mtrl, textureRawData, this, out res);
            }
            else
            {
                //编辑时,创建蒙皮网格资源实例,保存数据
                res                   = new GPUSkinningPlayerResources();
                res.anim              = anim;
                res.mesh              = mesh;
                res.texture           = GPUSkinningUtil.CreateTexture2D(textureRawData, anim);
                res.texture.hideFlags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor;
                //初始化Material(一共有6种Material)
                //创建的Material和Texture不保存(游戏运行时在Project视图无法找到索引,游戏运行后销毁)
                res.InitMaterial(mtrl, HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor);
            }

            player = new GPUSkinningPlayer(gameObject, res);
            // 非运行状态设置为false(preview)
            player.RootMotionEnabled = Application.isPlaying ? rootMotionEnabled : false;
            player.LODEnabled        = Application.isPlaying ? lodEnabled : false;
            // 动画片段播放的设置
            player.CullingMode = cullingMode;

            if (anim != null && anim.clips != null && anim.clips.Length > 0)
            {
                player.Play(anim.clips[Mathf.Clamp(defaultPlayingClipIndex, 0, anim.clips.Length)].name);
            }
        }

        // fzy add:
        myRes         = res;
        mf            = GetComponent <MeshFilter>();
        mf.sharedMesh = mesh;
        mr            = GetComponent <MeshRenderer>();
        SetMaterial(GPUSkinningPlayerResources.MaterialState.RootOff_BlendOff);
        mpb = new MaterialPropertyBlock();
    }
Esempio n. 6
0
    public void Init()
    {
        if (player != null)
        {
            return;
        }
        if (anim != null && mesh != null && mtrl != null && textureRawData != null)
        {
            GPUSkinningPlayerResources res = null;

            if (Application.isPlaying)
            {
                //if (EZ.Global.gApp.CurScene != null && EZ.Global.gApp.CurScene.GetPlayerMgr() != null)
                if (EZ.Global.gApp.CurScene != null)
                {
                    m_PlayerMonoManager.Register(anim, mesh, mtrl, textureRawData, this, out res);
                }
                else
                {
                    return;
                }
            }
            else
            {
                res      = new GPUSkinningPlayerResources();
                res.anim = anim;
                res.mesh = mesh;
                res.InitMaterial(mtrl, HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor);
                res.texture           = GPUSkinningUtil.CreateTexture2D(textureRawData, anim);
                res.texture.hideFlags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor;
            }

            player = new GPUSkinningPlayer(gameObject, res);
            //player.RootMotionEnabled = Application.isPlaying ? rootMotionEnabled : false;
            player.RootMotionEnabled = false;
            //player.LODEnabled = Application.isPlaying ? lodEnabled : false;
            player.LODEnabled  = false;
            player.CullingMode = cullingMode;

            if (anim != null && anim.clips != null && anim.clips.Length > 0)
            {
                player.Play(anim.clips[Mathf.Clamp(defaultPlayingClipIndex, 0, anim.clips.Length)].name);
            }
        }
    }
    public void Init()
    {
        if (player != null)
        {
            return;
        }

        if (anim != null && mesh != null && mtrl != null && boneTexture != null)
        {
            GPUSkinningPlayerResources res = null;

            if (Application.isPlaying)
            {
                playerManager.Register(anim, mesh, mtrl, boneTexture, this, out res);
            }
            else
            {
                res      = new GPUSkinningPlayerResources();
                res.anim = anim;
                res.mesh = mesh;
                res.InitMaterial(mtrl, HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor);
                res.boneTexture = boneTexture;    //GPUSkinningUtil.CreateTexture2D(boneTexture, anim);
                //res.boneTexture.hideFlags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor;
            }

            player = new GPUSkinningPlayer(gameObject, res);
            player.RootMotionEnabled = Application.isPlaying ? rootMotionEnabled : false;
            player.LODEnabled        = Application.isPlaying ? lodEnabled : false;
            player.CullingMode       = cullingMode;

            if (anim != null && anim.clips != null && anim.clips.Length > 0)
            {
                player.Play(anim.clips[Mathf.Clamp(defaultPlayingClipIndex, 0, anim.clips.Length)].name);
            }
        }
    }
Esempio n. 8
0
 public void PlayAnim(string animName, float normalize = 0)
 {
     player.Play(animName, normalize);
 }