zoukankan      html  css  js  c++  java
  • Unity 3d 几种Update

    本篇简单介绍Unity3d中几种Update方法的区别。

    Update方法

    所有

    Update

    Update是在每次渲染新的一帧的时候才会调用,也就是说,这个函数的更新频率和设备的性能有关以及被渲染的物体(可以认为是三角形的数量)。在性能好的机器上可能fps 30,差的可能小些。这会导致同一个游戏在不同的机器上效果不一致,有的快有的慢。因为Update的执行间隔不一样了。

    FixedUpdate

    FixedUpdate是在固定的时间间隔执行,不受游戏帧率的影响。Tips:在处理Rigidbody的时候最好用FixedUpdate

    FixedUpdate设置:Edit --> Project Settings --> Time

    outPut

    LateUpdate

    LateUpdate是在所有Update函数调用后被调用。这可用于调整脚本执行顺序。

    UpdateFixedUpdate的区别

    • FPS = 2;
    
    using UnityEngine;
    using System.Collections;
    
    public class FPS : MonoBehaviour {
    	
    	void Awake() {
    		Application.targetFrameRate = 2;
    	}
    
    	void Update () {
    		
    		Debug.Log ("Update");
    		
    	}
    	
    	void FixedUpdate () {
    		
    		Debug.Log ("FixedUpdate");
    		
    	}
    }
    
    
    

    outPut

    • FPS = 60;
    
    using UnityEngine;
    using System.Collections;
    
    public class FPS : MonoBehaviour {
    	
    	void Awake() {
    		Application.targetFrameRate = 60;
    	}
    
    	void Update () {
    		
    		Debug.Log ("Update");
    		
    	}
    	
    	void FixedUpdate () {
    		
    		Debug.Log ("FixedUpdate");
    		
    	}
    }
    
    
    

    outPut

  • 相关阅读:
    C语言1博客作业03
    C语言1博客作业02
    C语言I博客作业08
    C语言I博客作业07
    C语言I博客作业06
    C语言I博客作业05
    C语言I博客作业04
    C语言I博客作业03
    C语言I博客作业02
    第一次作业(重做)
  • 原文地址:https://www.cnblogs.com/chenjy1225/p/9661896.html
Copyright © 2011-2022 走看看