更新错误的预制体
This commit is contained in:
72
Convention/[Runtime]/Camera/FreeSceneCamera.cs
Normal file
72
Convention/[Runtime]/Camera/FreeSceneCamera.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cinemachine;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Convention
|
||||
{
|
||||
public class FreeSceneCamera : MonoSingleton<FreeSceneCamera>, ILoadedInHierarchy
|
||||
{
|
||||
[Resources, InspectorDraw(InspectorDrawType.Reference)] public Transform TargetFollow;
|
||||
//[Resources, InspectorDraw(InspectorDrawType.Reference)] public CinemachineVirtualCamera VirtualCamera;
|
||||
[Setting, InspectorDraw(InspectorDrawType.Text)] public float moveSpeed = 1;
|
||||
[Setting, InspectorDraw(InspectorDrawType.Text)] public float rotationSpeed = 1;
|
||||
private bool m_IsFocus = false;
|
||||
[Setting, InspectorDraw(InspectorDrawType.Toggle)]
|
||||
public bool isFocus
|
||||
{
|
||||
get => m_IsFocus;
|
||||
set
|
||||
{
|
||||
if (m_IsFocus != value)
|
||||
{
|
||||
m_IsFocus = value;
|
||||
Cursor.lockState = m_IsFocus ? CursorLockMode.Locked : CursorLockMode.None;
|
||||
Cursor.visible = !m_IsFocus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_IsFocus = false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Vector3 dxyz = Vector3.zero;
|
||||
Vector3 rxyz = Vector3.zero;
|
||||
if (Keyboard.current[Key.W].isPressed || Keyboard.current[Key.UpArrow].isPressed)
|
||||
dxyz += TargetFollow.forward;
|
||||
if (Keyboard.current[Key.A].isPressed || Keyboard.current[Key.LeftArrow].isPressed)
|
||||
dxyz += -TargetFollow.right;
|
||||
if (Keyboard.current[Key.D].isPressed || Keyboard.current[Key.RightArrow].isPressed)
|
||||
dxyz += TargetFollow.right;
|
||||
if (Keyboard.current[Key.S].isPressed || Keyboard.current[Key.DownArrow].isPressed)
|
||||
dxyz += -TargetFollow.forward;
|
||||
if (Keyboard.current[Key.Space].isPressed)
|
||||
dxyz += TargetFollow.up;
|
||||
if (Keyboard.current[Key.LeftShift].isPressed)
|
||||
dxyz += -TargetFollow.up;
|
||||
|
||||
var drotation = Vector3.zero;
|
||||
if (isFocus)
|
||||
{
|
||||
var temp = Mouse.current.delta.ReadValue();
|
||||
drotation = new(-temp.y, temp.x, 0);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
TargetFollow.Translate(dxyz * moveSpeed, Space.Self);
|
||||
TargetFollow.Rotate(drotation * rotationSpeed, Space.Self);
|
||||
|
||||
//
|
||||
|
||||
if (Keyboard.current[Key.Escape].isPressed)
|
||||
isFocus = false;
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Runtime]/Camera/FreeSceneCamera.cs.meta
Normal file
11
Convention/[Runtime]/Camera/FreeSceneCamera.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8a335d6894daac4c980d4519ab1e3ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -287,7 +287,7 @@ namespace Convention
|
||||
{
|
||||
SaveAsText(JsonUtility.ToJson(data));
|
||||
}
|
||||
public void SaveAsJson<T>(T data, string key)
|
||||
public void SaveAsJson<T>(T data, string key = "data")
|
||||
{
|
||||
ES3.Save(key, data,FullPath);
|
||||
}
|
||||
@@ -472,7 +472,8 @@ namespace Convention
|
||||
if (IsDir())
|
||||
Directory.CreateDirectory(this.FullPath);
|
||||
else
|
||||
File.Create(this.FullPath);
|
||||
File.Create(this.FullPath).Close();
|
||||
Refresh();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Convention
|
||||
{
|
||||
@@ -14,14 +15,6 @@ namespace Convention
|
||||
ProjectConfig.InitExtensionEnv();
|
||||
}
|
||||
|
||||
public static void GenerateEmptyConfigJson(ToolFile file)
|
||||
{
|
||||
file.SaveAsRawJson<Dictionary<string, object>>(new()
|
||||
{
|
||||
{ "properties",new Dictionary<string, object>() }
|
||||
});
|
||||
}
|
||||
|
||||
private int configLogging_tspace = "Property not found".Length;
|
||||
|
||||
private ToolFile DataDir;
|
||||
@@ -46,7 +39,7 @@ namespace Convention
|
||||
// build up init data file
|
||||
var configFile = this.ConfigFile;
|
||||
if (configFile.Exists() == false)
|
||||
GenerateEmptyConfigJson(configFile);
|
||||
SaveProperties();
|
||||
else if (isLoad)
|
||||
this.LoadProperties();
|
||||
}
|
||||
@@ -133,13 +126,16 @@ namespace Convention
|
||||
}
|
||||
public int DataSize() => data_pair.Count;
|
||||
|
||||
[Serializable]
|
||||
public class InternalProperty
|
||||
{
|
||||
public Dictionary<string, object> property = new();
|
||||
}
|
||||
|
||||
public GlobalConfig SaveProperties()
|
||||
{
|
||||
var configFile = this.ConfigFile;
|
||||
configFile.SaveAsRawJson<Dictionary<string, Dictionary<string, object>>>(new()
|
||||
{
|
||||
{ "properties", data_pair }
|
||||
});
|
||||
configFile.SaveAsJson(new InternalProperty() { property = data_pair });
|
||||
return this;
|
||||
}
|
||||
public GlobalConfig LoadProperties()
|
||||
@@ -151,11 +147,7 @@ namespace Convention
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = configFile.LoadAsRawJson<Dictionary<string, Dictionary<string, object>>>();
|
||||
if (data.TryGetValue("properties", out data_pair) == false)
|
||||
{
|
||||
throw new Exception($"Can't find properties not found in config file");
|
||||
}
|
||||
data_pair = configFile.LoadAsJson<InternalProperty>().property;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user