fix:代码提初始化
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
public class EventTest : MonoBehaviour
|
||||
{
|
||||
|
||||
void Start()
|
||||
{
|
||||
EnviroManager.instance.OnHourPassed += () =>
|
||||
{
|
||||
Debug.Log("Hour Passed!");
|
||||
};
|
||||
|
||||
EnviroManager.instance.OnDayPassed += () =>
|
||||
{
|
||||
Debug.Log("New Day!");
|
||||
};
|
||||
|
||||
EnviroManager.instance.OnYearPassed += () =>
|
||||
{
|
||||
Debug.Log("New Year!");
|
||||
};
|
||||
|
||||
EnviroManager.instance.OnDayTime += () =>
|
||||
{
|
||||
Debug.Log("Day!");
|
||||
};
|
||||
|
||||
EnviroManager.instance.OnNightTime += () =>
|
||||
{
|
||||
Debug.Log("Night!");
|
||||
};
|
||||
|
||||
EnviroManager.instance.OnSeasonChanged += (EnviroEnvironment.Seasons s) =>
|
||||
{
|
||||
Debug.Log("Season changed to: " + s.ToString());
|
||||
};
|
||||
|
||||
EnviroManager.instance.OnWeatherChanged += (EnviroWeatherType w) =>
|
||||
{
|
||||
Debug.Log("Weather changed to: " + w.name + " from:" + EnviroManager.instance.Weather.targetWeatherType.name);
|
||||
};
|
||||
|
||||
EnviroManager.instance.OnZoneWeatherChanged += (EnviroWeatherType w, EnviroZone z) =>
|
||||
{
|
||||
Debug.Log("Weather changed to: " + w.name.ToString() + " in zone:" + z.name);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 786eb4e742d16e64f9d44693699a412d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Sample/Scripts/EventTest.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,82 @@
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(Camera))]
|
||||
public class SimpleFlyController : MonoBehaviour
|
||||
{
|
||||
[Header("Mouse Look Settings")]
|
||||
public float lookSensitivity = 2f;
|
||||
public float lookSmoothing = 5f;
|
||||
public float maxPitch = 89f;
|
||||
|
||||
[Header("Movement Settings")]
|
||||
public float moveSpeed = 10f;
|
||||
public float fastMultiplier = 3f;
|
||||
|
||||
float yaw;
|
||||
float pitch;
|
||||
Vector2 smoothLook;
|
||||
bool cursorLocked = true;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Vector3 euler = transform.eulerAngles;
|
||||
yaw = euler.y;
|
||||
pitch = euler.x;
|
||||
|
||||
LockCursor(true);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
HandleCursorToggle();
|
||||
if (cursorLocked)
|
||||
{
|
||||
HandleMouseLook();
|
||||
HandleMovement();
|
||||
}
|
||||
}
|
||||
|
||||
void HandleCursorToggle()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
LockCursor(!cursorLocked);
|
||||
}
|
||||
|
||||
void LockCursor(bool locked)
|
||||
{
|
||||
cursorLocked = locked;
|
||||
Cursor.lockState = locked ? CursorLockMode.Locked : CursorLockMode.None;
|
||||
Cursor.visible = !locked;
|
||||
}
|
||||
|
||||
void HandleMouseLook()
|
||||
{
|
||||
Vector2 mouseInput = new Vector2(
|
||||
Input.GetAxis("Mouse X"),
|
||||
Input.GetAxis("Mouse Y")
|
||||
);
|
||||
|
||||
// Smooth mouse movement (optional)
|
||||
smoothLook = Vector2.Lerp(smoothLook, mouseInput, Time.deltaTime * lookSmoothing);
|
||||
|
||||
yaw += smoothLook.x * lookSensitivity;
|
||||
pitch -= smoothLook.y * lookSensitivity;
|
||||
pitch = Mathf.Clamp(pitch, -maxPitch, maxPitch);
|
||||
|
||||
transform.rotation = Quaternion.Euler(pitch, yaw, 0);
|
||||
}
|
||||
|
||||
void HandleMovement()
|
||||
{
|
||||
float moveX = Input.GetAxisRaw("Horizontal"); // A/D
|
||||
float moveY = 0f;
|
||||
float moveZ = Input.GetAxisRaw("Vertical"); // W/S
|
||||
|
||||
if (Input.GetKey(KeyCode.E)) moveY += 1f; // Up
|
||||
if (Input.GetKey(KeyCode.Q)) moveY -= 1f; // Down
|
||||
|
||||
Vector3 move = new Vector3(moveX, moveY, moveZ).normalized;
|
||||
float speed = moveSpeed * (Input.GetKey(KeyCode.LeftShift) ? fastMultiplier : 1f);
|
||||
transform.position += transform.TransformDirection(move) * speed * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb41acd897014da429d1897a48c8c330
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
116
Assets/Enviro 3 - Sky and Weather/Sample/Scripts/UISample.cs
Normal file
116
Assets/Enviro 3 - Sky and Weather/Sample/Scripts/UISample.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
public class UISample : MonoBehaviour
|
||||
{
|
||||
[Header("Time")]
|
||||
public Slider hourSlider;
|
||||
public Text hourText;
|
||||
public Text dateText;
|
||||
[Header("Weather")]
|
||||
public Text currentWeatherText;
|
||||
[Header("Environment")]
|
||||
public Text seasonText;
|
||||
public Text temperatureText;
|
||||
public Text wetnessText;
|
||||
public Text snowText;
|
||||
[Header("Quality")]
|
||||
public Text currentQualityText;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if(EnviroManager.instance.Time != null)
|
||||
{
|
||||
//hourSlider.value = EnviroManager.instance.Time.GetTimeOfDay() / 24f;
|
||||
hourText.text = EnviroManager.instance.Time.GetTimeStringWithSeconds();
|
||||
dateText.text = string.Format("{0:00}/{1:00}/{2:0000}", EnviroManager.instance.Time.days, EnviroManager.instance.Time.months, EnviroManager.instance.Time.years);
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Weather != null)
|
||||
{
|
||||
currentWeatherText.text = "Current Weather: " + EnviroManager.instance.Weather.targetWeatherType.name;
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
{
|
||||
temperatureText.text = "Temperature: " + string.Format("{0:0.0} °C", EnviroManager.instance.Environment.Settings.temperature);
|
||||
wetnessText.text = "Wetness: " + string.Format("{0:0.00}", EnviroManager.instance.Environment.Settings.wetness);
|
||||
snowText.text = "Snow: " + string.Format("{0:0.00}", EnviroManager.instance.Environment.Settings.snow);
|
||||
|
||||
string sText = "";
|
||||
|
||||
switch (EnviroManager.instance.Environment.Settings.season)
|
||||
{
|
||||
case EnviroEnvironment.Seasons.Spring:
|
||||
sText = "Current Season: Spring";
|
||||
break;
|
||||
case EnviroEnvironment.Seasons.Summer:
|
||||
sText = "Current Season: Summer";
|
||||
break;
|
||||
case EnviroEnvironment.Seasons.Autumn:
|
||||
sText = "Current Season: Autumn";
|
||||
break;
|
||||
case EnviroEnvironment.Seasons.Winter:
|
||||
sText = "Current Season: Winter";
|
||||
break;
|
||||
}
|
||||
seasonText.text = sText;
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Quality != null)
|
||||
{
|
||||
currentQualityText.text = "Current Quality: " + EnviroManager.instance.Quality.Settings.defaultQuality.name;
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeHourSlider ()
|
||||
{
|
||||
if(EnviroManager.instance.Time == null)
|
||||
return;
|
||||
|
||||
if (hourSlider.value < 0f)
|
||||
hourSlider.value = 0f;
|
||||
|
||||
EnviroManager.instance.Time.SetTimeOfDay (hourSlider.value * 24f);
|
||||
}
|
||||
|
||||
public void ChangeQuality(int q)
|
||||
{
|
||||
if(EnviroManager.instance.Quality != null)
|
||||
{
|
||||
if(EnviroManager.instance.Quality.Settings.Qualities.Count >= q)
|
||||
EnviroManager.instance.Quality.Settings.defaultQuality = EnviroManager.instance.Quality.Settings.Qualities[q];
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeWeather(int w)
|
||||
{
|
||||
if(EnviroManager.instance.Weather != null)
|
||||
{
|
||||
if(EnviroManager.instance.Weather.Settings.weatherTypes.Count >= w)
|
||||
EnviroManager.instance.Weather.ChangeWeather(EnviroManager.instance.Weather.Settings.weatherTypes[w]);
|
||||
}
|
||||
}
|
||||
public void ChangeTimeSimulation(bool t)
|
||||
{
|
||||
if(EnviroManager.instance.Time != null)
|
||||
{
|
||||
EnviroManager.instance.Time.Settings.simulate = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50649864dde853c4f806967f7c759be7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Sample/Scripts/UISample.cs
|
||||
uploadId: 660896
|
||||
Reference in New Issue
Block a user