Re: Learn! le nouveau module de formation d'Unity Tech.
Publié : 28 Jan 2017 17:13
Bien cool ça
Le forum de la communauté francophone d'Unity
http://www.unity3d-france.com/unity/phpBB3/
http://www.unity3d-france.com/unity/phpBB3/viewtopic.php?f=3&t=5609
voici Optimizing scripts in Unity gamesMax a écrit :Deux tuto supplémentaires et intéressants :
Optimizing garbage collection in Unity games
Optimizing graphics rendering in Unity games
C'est con mais il faut y penser: Ne pas laisser un Update () vide. Mieux vaut le supprimer.For this reason, empty Update() calls can be particularly wasteful. We may assume that because the function is empty and our code contains no direct calls to it, the empty function will not run. This is not the case: behind the scenes, these safety checks and native calls still happen even when the body of the Update() function is blank. To avoid wasted CPU time, we should ensure that our game does not contain empty Update() calls
Je l'ai toujours fait sans avoir cette info d'optimisation, je le faisais car je trouve cela plus "propre"...boubouk50 a écrit :C'est con mais il faut y penser: Ne pas laisser un Update () vide. Mieux vaut le supprimer.
Grilled.... (La Manager des Knights est plus "facile" a comprendre que celui de la démo d'Untiy)F@B a écrit :il est important aussi d'avoir un seul Update() dans un manager qui passe 10000 appel sur le scripts des GO que 10000 scripts avec un Update() dans chacun des scripts du GO.
https://blogs.unity3d.com/2015/12/23/1k-update-calls/
Code : Tout sélectionner
// http://blog.theknightsofunity.com/monobehavior-calls-optimization/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class BoxManager : MonoBehaviour {
public static BoxManager Instance { get; private set; }
public List<BoxManaged> _managedBoxes = new List<BoxManaged>();
void Awake(){
Instance = this;
}
void Update(){
for (int i = 0; i < _managedBoxes.Count; ++i){
_managedBoxes[i]._Update();
}
}
public void Register(BoxManaged box){
_managedBoxes.Add(box);
}
public void Unregister(BoxManaged box){
_managedBoxes.Remove(box);
}
}
Code : Tout sélectionner
// http://blog.theknightsofunity.com/monobehavior-calls-optimization/
using UnityEngine;
public class BoxManaged : MonoBehaviour {
void OnEnable(){
BoxManager.Instance.Register(this);
}
void OnDisable(){
BoxManager.Instance.Unregister(this);
}
public void _Update(){
transform.Rotate( 10.0f * Time.deltaTime, 20.0f * Time.deltaTime, 30.0f * Time.deltaTime);
}
}
Je n'essayerais meme pas de vous griller toi ou Max !ZJP a écrit :Grilled.... Image (La Manager des Knights est plus "facile" a comprendre que celui de la démo d'Untiy)