Ejemplo n.º 1
0
        protected virtual void Update()
        {
            if (m_SyncWithSystem)
            {
                // Set Timeline.
                if (m_ProgressTime)
                {
                    m_Timeline = (float)DateTime.TimeOfDay.TotalHours;
                }

                m_Year  = DateTime.Year;  // Set Year.
                m_Month = DateTime.Month; // Set Month.
                m_Day   = DateTime.Day;   // Set Day.
            }
            else
            {
                RepeatDateTime();  // Repeat full date cycle.

                // Add time to timeline.
                if (m_ProgressTime)
                {
                    CSky_DateTimeHelper.AddTimeToTimeline(ref m_Timeline, DurationCycle, k_TimelineLength);
                }
            }

            UpdateEvents();  // Update unity events.
        }
Ejemplo n.º 2
0
        private System.DateTime GetDateTime()
        {
            if (!m_SyncWithSystem)
            {
                // Create new DateTime.
                System.DateTime dateTime = new System.DateTime(0, System.DateTimeKind.Utc);

                // Add date and time in DateTime.
                dateTime = dateTime.AddYears(m_Year - 1).AddMonths(m_Month - 1).AddDays(m_Day - 1).AddHours(m_Timeline);

                // Set date.
                m_Year  = dateTime.Year;
                m_Month = dateTime.Month;
                m_Day   = dateTime.Day;

                // Set timeline.
                m_Timeline = CSky_DateTimeHelper.TimeToFloat(dateTime.Hour, dateTime.Minute, dateTime.Second, dateTime.Millisecond);

                return(dateTime);
            }

            return(System.DateTime.Now); // System date time.
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Set time to timeline.
 /// </summary>
 /// <param name="hour"></param>
 /// <param name="minute"></param>
 /// <param name="second"></param>
 private void SetTime(int hour, int minute, int second)
 {
     m_Timeline = CSky_DateTimeHelper.TimeToFloat(hour, minute, second);
 }
        protected override void _OnInspectorGUI()
        {
            #region Time.

            AC_EditorGUIUtility.ShurikenFoldoutHeader("Time", TextTitleStyle, ref m_TimeFoldout);

            if (m_TimeFoldout)
            {
                AC_EditorGUIUtility.ShurikenHeader("Timeline", TextSectionStyle, 20);
                EditorGUILayout.Separator();

                GUI.backgroundColor = m_ProgressTime.boolValue ? green : red;

                EditorGUILayout.PropertyField(m_ProgressTime, new GUIContent("ProgressTime"));

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUILayout.PropertyField(m_Timeline, new GUIContent("Timeline"));
                EditorGUILayout.EndVertical();

                GUI.backgroundColor = Color.white;

                EditorGUILayout.Separator();


                AC_EditorGUIUtility.ShurikenHeader("Time Length", TextSectionStyle, 20);
                EditorGUILayout.Separator();

                if (!m_SyncWithSystem.boolValue)
                {
                    GUI.backgroundColor = m_UseDayNightLength.boolValue ? green : red;

                    EditorGUILayout.PropertyField(m_UseDayNightLength, new GUIContent("Use Day Night Length"));

                    GUI.backgroundColor = Color.white;

                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    if (m_UseDayNightLength.boolValue)
                    {
                        if (!OverrideDayRange)
                        {
                            // Day Range.
                            float min = m_DayRange.vector2Value.x;
                            float max = m_DayRange.vector2Value.y;

                            AC_EditorGUIUtility.ShurikenHeader("Day Range", TextSectionStyle, 20);

                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.MinMaxSlider(ref min, ref max, 0, 24);

                                m_DayRange.vector2Value = new Vector2(min, max);

                                EditorGUILayout.PropertyField(m_DayRange, new GUIContent(""));
                            }
                            EditorGUILayout.EndHorizontal();

                            string startInfo = "Day Start: " + CSky_DateTimeHelper.TimeToString
                                               (
                                CSky_DateTimeHelper.GetTimelineHour(min),
                                CSky_DateTimeHelper.GetTimelineMinute(min)
                                               );

                            string endInfo = "Day End: " + CSky_DateTimeHelper.TimeToString
                                             (
                                CSky_DateTimeHelper.GetTimelineHour(max),
                                CSky_DateTimeHelper.GetTimelineMinute(max)
                                             );
                            EditorGUILayout.HelpBox(startInfo + " | " + endInfo, MessageType.Info);

                            EditorGUILayout.Separator();
                        }
                        AC_EditorGUIUtility.Separator(2);
                        EditorGUILayout.PropertyField(m_DayLength, new GUIContent("Day In Minutes"));
                        EditorGUILayout.PropertyField(m_NightLength, new GUIContent("Night In Minutes"));
                    }
                    else
                    {
                        EditorGUILayout.PropertyField(m_DayLength, new GUIContent("Day In Minutes"));
                    }
                    EditorGUILayout.Separator();
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.Separator();


                AC_EditorGUIUtility.ShurikenHeader("Set Time", TextSectionStyle, 20);

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUILayout.PropertyField(m_Hour, new GUIContent("Hour"));
                    EditorGUILayout.PropertyField(m_Minute, new GUIContent("Minute"));
                    EditorGUILayout.PropertyField(m_Second, new GUIContent("Second"));

                    GUI.backgroundColor = green;
                    if (GUILayout.Button("Set Time", GUILayout.MinHeight(30)))
                    {
                        tar.Hour   = m_Hour.intValue;
                        tar.Minute = m_Minute.intValue;
                        tar.Second = m_Second.intValue;
                    }
                    GUI.backgroundColor = Color.white;
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.Separator();
            }

            #endregion


            #region Date

            AC_EditorGUIUtility.ShurikenFoldoutHeader("Date", TextTitleStyle, ref m_DateFoldout);
            if (m_DateFoldout)
            {
                EditorGUILayout.PropertyField(m_Day, new GUIContent("Day"));
                EditorGUILayout.PropertyField(m_Month, new GUIContent("Month"));
                EditorGUILayout.PropertyField(m_Year, new GUIContent("Year"));
            }

            #endregion

            AC_EditorGUIUtility.ShurikenFoldoutHeader("Options", TextTitleStyle, ref m_OptionsFoldout);
            if (m_OptionsFoldout)
            {
                GUI.backgroundColor = m_SyncWithSystem.boolValue ? Color.green : Color.red;
                EditorGUILayout.Separator();
                EditorGUILayout.PropertyField(m_SyncWithSystem, new GUIContent("Synchronize With System DateTime"));
                EditorGUILayout.Separator();
                GUI.backgroundColor = Color.white;
            }



            LastUpdateInspector();
        }