Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Player Loop

Discussion in '2018.1 Beta' started by Krajca, Feb 1, 2018.

  1. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    201
    I played with player loop lately. I made this sample for others:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Experimental.LowLevel;
    5.  
    6. [ExecuteInEditMode]
    7. public class PlayerLoopChange : MonoBehaviour
    8. {
    9.     PlayerLoopSystem pls;
    10.     private void OnEnable()
    11.     {
    12.         pls = PlayerLoop.GetDefaultPlayerLoop();
    13.  
    14.         Debug.Log(pls.type);
    15.         for (int i = 0; i < pls.subSystemList.Length; i++)
    16.         {
    17.             Debug.Log(pls.subSystemList[i].type);
    18.             if (pls.subSystemList[i].type == typeof(UnityEngine.Experimental.PlayerLoop.EarlyUpdate))
    19.                 pls.subSystemList[i].updateDelegate = EarlyUpdate;
    20.        
    21.         }
    22.  
    23.         PlayerLoop.SetPlayerLoop(pls);
    24.     }
    25.  
    26.     void EarlyUpdate()
    27.     {
    28.         Debug.Log("EarlyUpdate");
    29.     }
    30.     // Use this for initialization
    31.     void Start()
    32.     {
    33.  
    34.     }
    35.    
    36.     // Update is called once per frame
    37.     void Update()
    38.     {
    39.         Debug.Log("Update");
    40.     }
    41. }
    but my question is: can i do it simpler than this or can i do it with more "proper" way compare to do this?
     
unityunity