TimeOfDayManager.SetTime C# (CSharp) Méthode

SetTime() public méthode

public SetTime ( float timeIn ) : void
timeIn float
Résultat void
    public void SetTime(float timeIn)
    {
        if (debug) Debug.Log("timeOfDay: " + timeIn,this);

        var ttime = timeIn;
        var tmax = 0f;//timeSlider.maxValue;

        if (ttime < 0) {
            ttime = ((ttime%tmax) + tmax)%tmax; // Ugh math, this is how you keep in 0-1 range when a number goes negative, tip of the day ;-)
        } else {
            ttime = ttime%tmax;
        }

        //UpdateLabel(time.ToString());
        //timeSlider.value = ttime;
        time = ttime;

        StaggeredUpdate();
    }

Usage Example

Exemple #1
0
    internal void OnValidate()       // For editor use
    {
        if (debugLogness)
        {
            Debug.Log("Validate Object: " + hasSetup, this);
        }
        if (hasSetup)
        {
            if (!mirrorLight)
            {
                lightProp = null;
            }
            if (mirrorLight && lightProp == null)
            {
                mirror();
            }

            //Run();
            if (timeOfDayManager != null)
            {
                if (lastSentTime != time && time != 0)                    // TODO hack, we want manual alteration of the time slider to cause an update, but for exampple 'AgentProperties' causes an 'OnValidate' to be called as part of it's setup

                //Debug.Log("lastSentTime:"+lastSentTime+":"+time,this);

                {
                    timeOfDayManager.SetTime(time);
                    lastSentTime = time;
                }
                timeOfDayManager.AmIadded(this);                 // This checks even if timeOfDayManager is not null, does it also have a reference to me, as its possible it got orphaned/forgotten by it

                Run();
            }
            else
            {
                Debug.Log("timeOfDayManager null, new object, run Manager first, running all of them now", this);
                FindObjectsOfType <TimeOfDayManager>().ToList().ForEach(o => o.Setup());
            }
            if (timeOfDayManager == null)
            {
                Debug.LogWarning("no timeOfDayManager wants me!", this);
            }
        }
    }