浏览代码

add Light control

/add_hero_sample
guanghuispark 3 年前
当前提交
6bf8e32e
共有 3 个文件被更改,包括 532 次插入363 次删除
  1. 854
      AwesomeUIWidgets/Assets/Scenes/ItemPickerRoom.unity
  2. 6
      AwesomeUIWidgets/Assets/Scripts/DateAndTimePicker.cs
  3. 35
      AwesomeUIWidgets/Assets/Scripts/LightManager.cs

854
AwesomeUIWidgets/Assets/Scenes/ItemPickerRoom.unity
文件差异内容过多而无法显示
查看文件

6
AwesomeUIWidgets/Assets/Scripts/DateAndTimePicker.cs


mode: CupertinoDatePickerMode.dateAndTime,
initialDateTime: this.dateTime,
onDateTimeChanged: (DateTime newDateTime) => {
this.setState(() => this.dateTime = newDateTime);
this.setState(() =>
{
LightManager.time = newDateTime;
this.dateTime = newDateTime;
});
}
)
));

35
AwesomeUIWidgets/Assets/Scripts/LightManager.cs


using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LightManager : MonoBehaviour
{
public GameObject directLight;
public static DateTime time;
private const float one_day_seconds = 86400f;
private const float offset = 0.0f;
// Start is called before the first frame update
void Start()
{
time = DateTime.Now;
Debug.Log(time.TimeOfDay);
}
// Update is called once per frame
void Update()
{
DateTime start_of_today = new DateTime(time.Year, time.Month, time.Day);
TimeSpan timeSpan = time - start_of_today;
float total_seconds = (float)timeSpan.TotalSeconds;
float x = (total_seconds - 21600) *180 / 43200 - offset;
if (x > 180) x = 180;
if (x < 0) x = 0;
directLight.transform.rotation = Quaternion.Euler(x,72,0);
if (x > 90) x = 180 - x;
directLight.GetComponent<Light>().intensity = x / 90;
}
}
正在加载...
取消
保存