U3D慢鏡頭及各個物體慢速度播放

U3D慢鏡頭及各個物體慢速度播放
----------------------------總體時間慢速度播放------------------------PlaySpeed.CS----------

 

using System.Collections;

 

using System.Collections.Generic;

 

using UnityEngine;



public class Playspeed: MonoBehaviour {

 

public float mySpeed =1;

 

// Use this for initialization

 

void Start () {

 

}

 

// Update is called once per frame

 

void Update () {

 

Time.timeScale= mySpeed;

 

}

 

}



----------------------------具體角色慢速度播放---------------------ChrSpeed.CS-------------

 

using System.Collections;

 

using System.Collections.Generic;

 

using UnityEngine;



public class ChrSpeed: MonoBehaviour {

 

public float mySpeed =1;

 

// Use this for initialization

 

void Start () {

 

}

 

// Update is called once per frame

 

void Update () {

 

this.GetComponent<Animator>().speed = mySpeed;

 

}

 

}



----------------------------具體粒子慢速度播放-----------------PtSpeed.CS-----------------

 

using System.Collections;

 

using System.Collections.Generic;

 

using UnityEngine;



public class PTspeed : MonoBehaviour {

 

public float mSpeed =1;

 

// Use this for initialization

 

void Start () {



}



// Update is called once per frame

 

void Update () {

 

this.GetComponent<ParticleSystem>().playbackSpeed = mSpeed;

 

}

 

}



--------------------具體粒子及子級粒子的慢速度播放-----------PTspeedChildren .cs --------------------

 

using System.Collections;

 

using System.Collections.Generic;

 

using UnityEngine;



public class PTspeedChildren : MonoBehaviour {

 

public float mSpeed =1;

 

// Use this for initialization

 

void Start () {



}



// Update is called once per frame

 

void Update () {

 

//this.GetComponent<ParticleSystem>().playbackSpeed = mSpeed;

 

ParticleSystem[] aaa = this.gameObject.GetComponentsInChildren<ParticleSystem>();

 

    foreach(var p in aaa)

 

        {

 

            p.playbackSpeed = mSpeed;

 

        }

 

}

 

}
相關文章
相關標籤/搜索