Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

[SOLVED] I can't use 'ut.Time' in my projects!

Discussion in 'Project Tiny' started by MUGIK, Dec 7, 2018.

  1. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    428
    In projects from TinySamples I can use 'ut.Time' in code, but not in projects that I created.
    Unity 2018.3.0b12


    Here is video, that demonstrates my problem:


    Notice, that I closed VS Code before create new project, so everything going from scratch. Anyway, I have compiler error, that complains about ut.Time.

    UPD:
    I also tried to include all modules and then reload unity, but this didn't help.
    upload_2018-12-7_18-47-55.png
     
  2. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,322
    Can't you just post the script, using the code tags, and the error message? They are too small in the video.
     
  3. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    428
    My bad!
    To use ut.Time we need to create this system or copy from sample project.
    upload_2018-12-7_19-3-16.png
    Code (JavaScript):
    1. namespace ut
    2. {
    3.     /**
    4.      * Placeholder system to provide a UnityEngine.Time like API
    5.      *
    6.      * e.g.
    7.      *  let deltaTime = ut.Time.deltaTime();
    8.      *  let time = ut.Time.time();
    9.      *
    10.      */
    11.     @ut.executeBefore(ut.Shared.UserCodeStart)
    12.     export class Time extends ut.ComponentSystem
    13.     {
    14.         private static _deltaTime: number = 0;
    15.         private static _time: number = 0;
    16.      
    17.         static deltaTime(): number {
    18.             return Time._deltaTime;
    19.         }
    20.  
    21.         static time(): number {
    22.             return Time._time;
    23.         }
    24.  
    25.         static reset()
    26.         {
    27.            Time._time = 0;
    28.         }
    29.      
    30.         OnUpdate(): void {
    31.             let dt = this.scheduler.deltaTime();
    32.             Time._deltaTime = dt;
    33.             Time._time += dt;
    34.         }
    35.     }
    36. }
    37.  
    The 'ut' namespace has misled me.
     
    Last edited: Dec 7, 2018
    CloverDev likes this.