Search Unity

Getting the time...

Discussion in 'Scripting' started by Charles Hinshaw, Mar 4, 2008.

  1. Charles Hinshaw

    Charles Hinshaw

    Joined:
    Feb 6, 2008
    Posts:
    1,070
    I would like to do the following:

    - determine if the computer is connected to the internet
    - if yes, make SNTP requests to several NTP time servers and parse the replies
    - if no, look for some "standard" system file that should be modified today and get the modified date
    - AND if no, look at the local time for the machine

    I am not yet very familiar with any system related calls in the context of Unity... and this is all proving much harder than I had hoped.

    Does anybody have any starting advice on how to implement this in Unity -- I understand in theory how to implement it, and I could do it in a number of ways... but I get this massive conceptual wall whenever I try to implement it in C#.
     
  2. Charles Hinshaw

    Charles Hinshaw

    Joined:
    Feb 6, 2008
    Posts:
    1,070
    Nevermind... forced myself to just go through it step by step.

    Although... does anyone know of a good resource for doing any Mono/.NET system related stuff? For reference outside of the Unity-specific manuals.
     
  3. JohnyZuper

    JohnyZuper

    Joined:
    Jan 7, 2008
    Posts:
    174
    So how did you do it?
    Is there a way to get the system time through Javascript?
     
  4. phoen

    phoen

    Joined:
    Oct 25, 2005
    Posts:
    94
  5. JohnyZuper

    JohnyZuper

    Joined:
    Jan 7, 2008
    Posts:
    174
    I used
    Code (csharp):
    1.  
    2. import System;
    3.  
    4. date = DateTime.Now;
    That works too.