diff --git a/Assets/02.InformationSave/Editor/CustomEditorBaseEditor.cs b/Assets/02.InformationSave/Editor/CustomEditorBaseEditor.cs new file mode 100644 index 0000000..65224ad --- /dev/null +++ b/Assets/02.InformationSave/Editor/CustomEditorBaseEditor.cs @@ -0,0 +1,27 @@ +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + [CustomEditor(typeof(CustomEditorBase), true)] + public class CustomEditorBaseEditor : UnityEditor.Editor + { + private CustomEditorBase _customEditorBase; + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + serializedObject.Update(); + _customEditorBase = target as CustomEditorBase; + _customEditorBase.Draw(); + //这个函数告诉引擎,相关对象所属于的Prefab已经发生了更改。方便,当我们更改了自定义对象的属性的时候,自动更新到所属的Prefab中 + if (GUI.changed && EditorApplication.isPlaying == false) + { + serializedObject.ApplyModifiedProperties(); + EditorUtility.SetDirty(_customEditorBase); + EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); + } + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/Editor/CustomEditorBaseEditor.cs.meta b/Assets/02.InformationSave/Editor/CustomEditorBaseEditor.cs.meta new file mode 100644 index 0000000..cc331c7 --- /dev/null +++ b/Assets/02.InformationSave/Editor/CustomEditorBaseEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2da8df4f2ba04494a90eec6fda524a49 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Abstract.meta b/Assets/02.InformationSave/RunTime/Abstract.meta new file mode 100644 index 0000000..5645ab5 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Abstract.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3e0efc3ec4ae1fe458358558357e78fb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Abstract/AbstractInformation.cs b/Assets/02.InformationSave/RunTime/Abstract/AbstractInformation.cs new file mode 100644 index 0000000..3a96d8e --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Abstract/AbstractInformation.cs @@ -0,0 +1,225 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using Stary.Evo.InformationSave.Data; +using Newtonsoft.Json; +using UnityEditor; +using UnityEngine; +using System.Linq; + +namespace Stary.Evo.InformationSave +{ + public abstract class AbstractInformation : CustomEditorBase where T : InformationBase, new() + { + [HideInInspector] public List _list = new List(); + + /// + /// 配置文件存储路径 + /// + string path = "InformationSaveData/ScriptObjectSaveData"; + + public virtual void Add() + { + _list.Add(new T()); + Save(_list.Count - 1); + } + + public abstract void Save(int index); + public abstract void Switch(int index); + public virtual T GetTransform(string desc) + { + int index = _list.FindIndex(n => n.desc == desc); + if (index != -1) + { + return _list[index]; + } + else + { + Debug.LogError($"{typeof(T)}:不存在该信息:" + desc); + return default(T); + } + } + + public virtual void Delete(int index) + { + _list.RemoveAt(index); + } + + public virtual void Set(string desc) + { + int index = _list.FindIndex(n => n.desc == desc); + if (index != -1) Switch(index); + } + + #region Editor + +#if UNITY_EDITOR + //更新 + public void UpdateInformation() + { + String sceneNmae = gameObject.scene.name; + ScriptObjectSave scriptObjectSaveData = Resources.Load(path); + if (scriptObjectSaveData == null) + { + Debug.LogError("ScriptObjectSaveData配置文件丢失"); + return; + } + + if (scriptObjectSaveData.dic.ContainsKey(sceneNmae + gameObject.name)) + { + _list.Clear(); + _list = scriptObjectSaveData.dic[sceneNmae + gameObject.name].OfType().ToList(); + } + else + { + Debug.LogError("ScriptObjectSaveData中未存储场景:"+ sceneNmae + " 中物体:" + gameObject.name + "的数据!!!"); + } + } + + //动态保存 + public bool PlayingSave() + { + //文件保存 + if (Application.isEditor) + { + String sceneNmae = gameObject.scene.name; + // 加载 ScriptObjectSaveData + ScriptObjectSave scriptObjectSaveData = Resources.Load(path); + if(scriptObjectSaveData == null) + { + scriptObjectSaveData = CheckAndCreateFoldersAndAsset(); + Debug.Log("创建了ScriptObjectSaveData文件"); + } + + if (scriptObjectSaveData.dic == null) + { + Debug.LogError("ScriptObjectSaveData的dic为空"); + return false; + } + + // 检查是否已经存在相同的键 + if (scriptObjectSaveData.dic.ContainsKey(sceneNmae + gameObject.name)) + { + // 如果存在,选择是否替换原有的 List + if (UnityEditor.EditorUtility.DisplayDialog("提示", "数据集下已有相同名称的物体数据\n是否覆盖更新!!!\n" + "场景名:" + sceneNmae + "\n物体名:" + gameObject.name, "确定", "取消")) + { + scriptObjectSaveData.dic[sceneNmae + gameObject.name] = new List(_list); + } + else + { + return false; + } + } + else + { + // 如果不存在,添加新的键值对 + scriptObjectSaveData.dic.Add(sceneNmae + gameObject.name, new List(_list)); + } + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + + return true; + } + + return false; + } + + private ScriptObjectSave CheckAndCreateFoldersAndAsset() + { + string ResourcesFolderName = "Resources"; + string InformationSaveDataFolderName = "InformationSaveData"; + string ScriptObjectSaveDataFileName = "ScriptObjectSaveData"; + ScriptObjectSave scriptableObject; + + // 判断是否创建Resources文件夹 + string resourcesPath = Path.Combine(Application.dataPath, ResourcesFolderName); + if (!Directory.Exists(resourcesPath)) + { + Directory.CreateDirectory(resourcesPath); + } + + // 判断是否创建InformationSaveData文件夹 + string informationSaveDataPath = Path.Combine(resourcesPath, InformationSaveDataFolderName); + if (!Directory.Exists(informationSaveDataPath)) + { + Directory.CreateDirectory(informationSaveDataPath); + } + + // 创建ScriptObjectSaveData.asset文件 + scriptableObject = ScriptableObject.CreateInstance(); + AssetDatabase.CreateAsset(scriptableObject, "Assets/" + ResourcesFolderName + "/" + InformationSaveDataFolderName + "/" + ScriptObjectSaveDataFileName + ".asset"); + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + + return scriptableObject; + } + + //绘制 + public override void Draw() + { + + int length = _list.Count; + int deleteIndex = -1; + for (int i = 0; i < length; i++) + { + GUILayout.BeginHorizontal(); + _list[i].desc = UnityEditor.EditorGUILayout.TextField(_list[i].desc); + if (GUILayout.Button("切换")) Switch(i); + if (GUILayout.Button("保存")) + { + Save(i); + if (PlayingSave()) Debug.Log("保存成功!"); + } + + if (GUILayout.Button("上移") && i > 0) + { + T temp = _list[i - 1]; + _list[i - 1] = _list[i]; + _list[i] = temp; + } + + if (GUILayout.Button("下移") && i < _list.Count - 1) + { + T temp = _list[i + 1]; + _list[i + 1] = _list[i]; + _list[i] = temp; + } + + if (GUILayout.Button("删除") && UnityEditor.EditorUtility.DisplayDialog("警告", "你确定要删除吗?", "确定", "取消")) + deleteIndex = i; + GUILayout.EndHorizontal(); + if (i != length - 1) GUILayout.Space(20); + } + + if (deleteIndex != -1) Delete(deleteIndex); + GUILayout.Space(30); + GUILayout.BeginHorizontal(); + if (GUILayout.Button("添加")) + { + Add(); + } + + if (GUILayout.Button("更新") && UnityEditor.EditorUtility.DisplayDialog("提示", "你确定要更新吗?", "确定", "取消")) + { + UpdateInformation(); + GUILayout.BeginHorizontal(); + } + + GUILayout.EndHorizontal(); + } + + +#else + public override void Draw(){} +#endif + } + + #endregion + + [System.Serializable] + public class InformationBase + { + public string desc = "初始"; + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Abstract/AbstractInformation.cs.meta b/Assets/02.InformationSave/RunTime/Abstract/AbstractInformation.cs.meta new file mode 100644 index 0000000..80af3b7 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Abstract/AbstractInformation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0f5b94406351c9c4984472ef696d4888 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/AnchoredPosition.cs b/Assets/02.InformationSave/RunTime/AnchoredPosition.cs new file mode 100644 index 0000000..576118c --- /dev/null +++ b/Assets/02.InformationSave/RunTime/AnchoredPosition.cs @@ -0,0 +1,27 @@ +//======================================================= +// 作者:张铮 +// 描述: +//======================================================= +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public sealed class AnchoredPosition : AbstractInformation + { + public override void Save(int index) + { + _list[index].anchoredPosition =GetComponent().anchoredPosition.GetVector2Data() ; + } + + public override void Switch(int index) + { + GetComponent().anchoredPosition = _list[index].anchoredPosition.SetVector2Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector2Data anchoredPosition; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/AnchoredPosition.cs.meta b/Assets/02.InformationSave/RunTime/AnchoredPosition.cs.meta new file mode 100644 index 0000000..3fdcc7c --- /dev/null +++ b/Assets/02.InformationSave/RunTime/AnchoredPosition.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f5c3a514df208eb4cb4a15721b54f849 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Base.meta b/Assets/02.InformationSave/RunTime/Base.meta new file mode 100644 index 0000000..9461e40 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Base.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d8020e670de32754cb7e83d988b27bdd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Base/CustomEditorBase.cs b/Assets/02.InformationSave/RunTime/Base/CustomEditorBase.cs new file mode 100644 index 0000000..7d2901a --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Base/CustomEditorBase.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public abstract class CustomEditorBase : MonoBehaviour + { + public abstract void Draw(); + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Base/CustomEditorBase.cs.meta b/Assets/02.InformationSave/RunTime/Base/CustomEditorBase.cs.meta new file mode 100644 index 0000000..21d2148 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Base/CustomEditorBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 00771a0cc2a1d7a42bb8d06ae6dce935 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/CameraInfo.cs b/Assets/02.InformationSave/RunTime/CameraInfo.cs new file mode 100644 index 0000000..3894cba --- /dev/null +++ b/Assets/02.InformationSave/RunTime/CameraInfo.cs @@ -0,0 +1,39 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public class CameraInfo : AbstractInformation + { + public override void Save(int index) + { + var c = GetComponent(); + var tf = transform; + _list[index].position = tf.position.GetVector3Data(); + _list[index].eulerAngles = tf.eulerAngles.GetVector3Data(); + _list[index].orthographic = c.orthographic; + _list[index].orthographicSize = c.orthographicSize; + _list[index].fieldofView = c.fieldOfView; + } + + public override void Switch(int index) + { + var c = GetComponent(); + var tf = transform; + tf.position = _list[index].position.SetVector3Data(); + tf.eulerAngles = _list[index].eulerAngles.SetVector3Data(); + c.orthographic = _list[index].orthographic; + c.orthographicSize = _list[index].orthographicSize; + c.fieldOfView = _list[index].fieldofView; + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data position; + public Vector3Data eulerAngles; + public bool orthographic; + public float orthographicSize; + public float fieldofView; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/CameraInfo.cs.meta b/Assets/02.InformationSave/RunTime/CameraInfo.cs.meta new file mode 100644 index 0000000..514146f --- /dev/null +++ b/Assets/02.InformationSave/RunTime/CameraInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cf38f4aa9f11b54797838ea149b559d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Data.meta b/Assets/02.InformationSave/RunTime/Data.meta new file mode 100644 index 0000000..12f1bea --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Data.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6543baeed3e940268fc41b7eb6fa31a7 +timeCreated: 1735626715 \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Data/InformationSaveScriptObject.cs b/Assets/02.InformationSave/RunTime/Data/InformationSaveScriptObject.cs new file mode 100644 index 0000000..a489ea3 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Data/InformationSaveScriptObject.cs @@ -0,0 +1,25 @@ +using UnityEngine; +/**************************************************** + 文件:ScriptObjectTopicSave.cs + 作者:张铮 + 邮箱: + 日期:2022/3/10 16:21:54 + 功能: +*****************************************************/ +namespace Stary.Evo.InformationSave.Data +{ + [CreateAssetMenu(fileName = "InformationSaveScriptObject", menuName = "Point8/InformationSaveScriptObject")] + public class InformationSaveScriptObject : ScriptableObject + { + public string[] Urls; + // [Button] + // public void SavaJson(){ + // + // UnityWebRequestSystem.SaveJson(topics,"TopicJson"); + // } + } +} + + + + diff --git a/Assets/02.InformationSave/RunTime/Data/InformationSaveScriptObject.cs.meta b/Assets/02.InformationSave/RunTime/Data/InformationSaveScriptObject.cs.meta new file mode 100644 index 0000000..31dbd32 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Data/InformationSaveScriptObject.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8775212800004330b3958e498e4ac71f +timeCreated: 1735626740 \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Data/ScriptObjectSave.cs b/Assets/02.InformationSave/RunTime/Data/ScriptObjectSave.cs new file mode 100644 index 0000000..a633d6c --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Data/ScriptObjectSave.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Stary.Evo.InformationSave; +using UnityEditor; +using UnityEngine; +using Sirenix.OdinInspector; + +namespace Stary.Evo.InformationSave +{ + [CreateAssetMenu()] + public class ScriptObjectSave : SerializedScriptableObject + { + public Dictionary> dic = new Dictionary>(); + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Data/ScriptObjectSave.cs.meta b/Assets/02.InformationSave/RunTime/Data/ScriptObjectSave.cs.meta new file mode 100644 index 0000000..5c75a84 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Data/ScriptObjectSave.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a08c59ee0e6844441825e5b5427d1e4c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Data/ScriptObjectSaveData.asset b/Assets/02.InformationSave/RunTime/Data/ScriptObjectSaveData.asset new file mode 100644 index 0000000..bf306f0 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Data/ScriptObjectSaveData.asset @@ -0,0 +1,43 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a08c59ee0e6844441825e5b5427d1e4c, type: 3} + m_Name: ScriptObjectSaveData + m_EditorClassIdentifier: + serializationData: + SerializedFormat: 2 + SerializedBytes: + ReferencedUnityObjects: [] + SerializedBytesString: + Prefab: {fileID: 0} + PrefabModificationsReferencedUnityObjects: [] + PrefabModifications: [] + SerializationNodes: + - Name: dic + Entry: 7 + Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Collections.Generic.List`1[[Stary.Evo.InformationSave.InformationBase, + Assembly-CSharp]], mscorlib]], mscorlib + - Name: comparer + Entry: 7 + Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String, + mscorlib]], mscorlib + - Name: + Entry: 8 + Data: + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: diff --git a/Assets/02.InformationSave/RunTime/Data/ScriptObjectSaveData.asset.meta b/Assets/02.InformationSave/RunTime/Data/ScriptObjectSaveData.asset.meta new file mode 100644 index 0000000..87cf931 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Data/ScriptObjectSaveData.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8e2aa5a2cf392c145a1055e82ed08b6f +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/EulerAngles.cs b/Assets/02.InformationSave/RunTime/EulerAngles.cs new file mode 100644 index 0000000..7e7280d --- /dev/null +++ b/Assets/02.InformationSave/RunTime/EulerAngles.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public sealed class EulerAngles : AbstractInformation + { + public override void Save(int index) + { + _list[index].eulerAngles =transform.eulerAngles.GetVector3Data(); + } + + public override void Switch(int index) + { + transform.eulerAngles = _list[index].eulerAngles.SetVector3Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data eulerAngles; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/EulerAngles.cs.meta b/Assets/02.InformationSave/RunTime/EulerAngles.cs.meta new file mode 100644 index 0000000..e8d3819 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/EulerAngles.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cf6220df9bf1ce147bfe973d851f167f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension.meta b/Assets/02.InformationSave/RunTime/Extension.meta new file mode 100644 index 0000000..d2aec37 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fc7186a56102e2f4d803fb53e2dcad09 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/AnchoredPositionExtension.cs b/Assets/02.InformationSave/RunTime/Extension/AnchoredPositionExtension.cs new file mode 100644 index 0000000..cbc2feb --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/AnchoredPositionExtension.cs @@ -0,0 +1,41 @@ +//======================================================= +// 作者:王则昆 +// 描述: +//======================================================= +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class AnchoredPositionExtension + { + public static AnchoredPosition.Information GetAnchoredPositionInformation(this RectTransform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static Vector3 GetAnchoredPosition(this RectTransform tf, string desc) + { + return GetAnchoredPositionInformation(tf, desc).anchoredPosition.SetVector2Data(); + } + + public static void SetAnchoredPosition(this RectTransform tf, string desc) + { + tf.GetComponent().Set(desc); + } + + public static AnchoredPosition.Information GetAnchoredPositionInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static Vector3 GetAnchoredPosition(this Transform tf, string desc) + { + return GetAnchoredPositionInformation(tf, desc).anchoredPosition.SetVector2Data(); + } + + public static void SetAnchoredPosition(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/AnchoredPositionExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/AnchoredPositionExtension.cs.meta new file mode 100644 index 0000000..24aefef --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/AnchoredPositionExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ccf4bfdd8fa15e4bb9f960a8fd8043e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/CameraInfoExtension.cs b/Assets/02.InformationSave/RunTime/Extension/CameraInfoExtension.cs new file mode 100644 index 0000000..734db4d --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/CameraInfoExtension.cs @@ -0,0 +1,27 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class CameraInfoExtension + { + public static CameraInfo.Information GetCameraInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static void SetCameraInfo(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + + public static CameraInfo.Information GetCameraInformation(this Camera camera, string desc) + { + return camera.GetComponent()._list.Find(n => n.desc == desc); + } + + public static void SetCameraInfo(this Camera camera, string desc) + { + camera.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/CameraInfoExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/CameraInfoExtension.cs.meta new file mode 100644 index 0000000..b079a11 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/CameraInfoExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 181681708c62fd746bad97c7c2466778 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/EulerAnglesExtension.cs b/Assets/02.InformationSave/RunTime/Extension/EulerAnglesExtension.cs new file mode 100644 index 0000000..1e2519c --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/EulerAnglesExtension.cs @@ -0,0 +1,22 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class EulerAnglesExtension + { + public static EulerAngles.Information GetEulerAnglesInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static Vector3 GetEulerAngles(this Transform tf, string desc) + { + return GetEulerAnglesInformation(tf, desc).eulerAngles.SetVector3Data(); + } + + public static void SetEulerAngles(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/EulerAnglesExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/EulerAnglesExtension.cs.meta new file mode 100644 index 0000000..1e66a22 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/EulerAnglesExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 44d0cc77fd362de4a9a3e49083ab4083 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/JBoxColliderExtension.cs b/Assets/02.InformationSave/RunTime/Extension/JBoxColliderExtension.cs new file mode 100644 index 0000000..ddc9d28 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/JBoxColliderExtension.cs @@ -0,0 +1,17 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class JBoxColliderExtension + { + public static JBoxCollider.Information GetBoxColliderInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static void SetBoxCollider(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/JBoxColliderExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/JBoxColliderExtension.cs.meta new file mode 100644 index 0000000..efe1438 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/JBoxColliderExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 06c219a2579145e41bb8abe74f529ca1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/LocalCameraInfoExtension.cs b/Assets/02.InformationSave/RunTime/Extension/LocalCameraInfoExtension.cs new file mode 100644 index 0000000..4f1a899 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/LocalCameraInfoExtension.cs @@ -0,0 +1,27 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class LocalCameraInfoExtension + { + public static LocalCameraInfo.Information GetLocalCameraInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static void SetLocalCameraInfo(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + + public static LocalCameraInfo.Information GetLocalCameraInformation(this Camera camera, string desc) + { + return camera.GetComponent()._list.Find(n => n.desc == desc); + } + + public static void SetLocalCameraInfo(this Camera camera, string desc) + { + camera.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/LocalCameraInfoExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/LocalCameraInfoExtension.cs.meta new file mode 100644 index 0000000..e8b3618 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/LocalCameraInfoExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c1834ac1eb7bea34eaf1233d3fbe8b98 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/LocalEulerAnglesExtension.cs b/Assets/02.InformationSave/RunTime/Extension/LocalEulerAnglesExtension.cs new file mode 100644 index 0000000..383e0ba --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/LocalEulerAnglesExtension.cs @@ -0,0 +1,22 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class LocalEulerAnglesExtension + { + public static LocalEulerAngles.Information GetLocalEulerAnglesInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static Vector3 GetLocalEulerAngles(this Transform tf, string desc) + { + return GetLocalEulerAnglesInformation(tf, desc).localEulerAngles.SetVector3Data(); + } + + public static void SetLocalEulerAngles(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/LocalEulerAnglesExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/LocalEulerAnglesExtension.cs.meta new file mode 100644 index 0000000..69e86aa --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/LocalEulerAnglesExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 557f7719d29961f489da4c917f107ed6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/LocalPositionEulerAnglesExtension.cs b/Assets/02.InformationSave/RunTime/Extension/LocalPositionEulerAnglesExtension.cs new file mode 100644 index 0000000..41e150f --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/LocalPositionEulerAnglesExtension.cs @@ -0,0 +1,18 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class LocalPositionEulerAnglesExtension + { + public static LocalPositionEulerAngles.Information GetLocalPositionEulerAnglesInformation(this Transform tf, + string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static void SetLocalPositionEulerAngles(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/LocalPositionEulerAnglesExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/LocalPositionEulerAnglesExtension.cs.meta new file mode 100644 index 0000000..9509428 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/LocalPositionEulerAnglesExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7f5fd207a730ab2459db6ab5cb61ac92 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/LocalPositionExtension.cs b/Assets/02.InformationSave/RunTime/Extension/LocalPositionExtension.cs new file mode 100644 index 0000000..308f70d --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/LocalPositionExtension.cs @@ -0,0 +1,22 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class LocalPositionExtension + { + public static LocalPosition.Information GetLocalPositionInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static Vector3 GetLocalPosition(this Transform tf, string desc) + { + return GetLocalPositionInformation(tf, desc).localPosition.SetVector3Data(); + } + + public static void SetLocalPosition(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/LocalPositionExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/LocalPositionExtension.cs.meta new file mode 100644 index 0000000..7930b93 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/LocalPositionExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ac0cb760733c70641b6b5b696c137dc9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/LocalTransformInfoExtension.cs b/Assets/02.InformationSave/RunTime/Extension/LocalTransformInfoExtension.cs new file mode 100644 index 0000000..3694f9c --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/LocalTransformInfoExtension.cs @@ -0,0 +1,17 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class LocalTransformInfoExtension + { + public static LocalTransformInfo.Information GetLocalTransformInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static void SetLocalTransformInfo(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/LocalTransformInfoExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/LocalTransformInfoExtension.cs.meta new file mode 100644 index 0000000..cc7d56a --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/LocalTransformInfoExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 26f9c07fe30c400479eea478f2e6557f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/PositionEulerAnglesExtension.cs b/Assets/02.InformationSave/RunTime/Extension/PositionEulerAnglesExtension.cs new file mode 100644 index 0000000..a483e49 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/PositionEulerAnglesExtension.cs @@ -0,0 +1,17 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class PositionEulerAnglesExtension + { + public static PositionEulerAngles.Information GetPositionEulerAnglesInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static void SetPositionEulerAngles(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/PositionEulerAnglesExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/PositionEulerAnglesExtension.cs.meta new file mode 100644 index 0000000..704cbb9 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/PositionEulerAnglesExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 158344c49f575164a825cf6b74670213 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/PositionExtension.cs b/Assets/02.InformationSave/RunTime/Extension/PositionExtension.cs new file mode 100644 index 0000000..5434d56 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/PositionExtension.cs @@ -0,0 +1,22 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class PositionExtension + { + public static Position.Information GetPositionInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static Vector3 GetPosition(this Transform tf, string desc) + { + return GetPositionInformation(tf, desc).position.SetVector3Data(); + } + + public static void SetPosition(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/PositionExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/PositionExtension.cs.meta new file mode 100644 index 0000000..6c4dcd2 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/PositionExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6c5840afa5ec12245982ccbc14e3da68 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/RectTransformInfoExtension.cs b/Assets/02.InformationSave/RunTime/Extension/RectTransformInfoExtension.cs new file mode 100644 index 0000000..5a3ced8 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/RectTransformInfoExtension.cs @@ -0,0 +1,18 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class RectTransformInfoExtension + { + public static RectTransformInfo.Information GetRectTransformInformation(this RectTransform rectTransform, + string desc) + { + return rectTransform.GetComponent()._list.Find(n => n.desc == desc); + } + + public static void SetRectTransformInfo(this RectTransform rectTransform, string desc) + { + rectTransform.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/RectTransformInfoExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/RectTransformInfoExtension.cs.meta new file mode 100644 index 0000000..f0419d5 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/RectTransformInfoExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 513bbc7c53696644b84719b8dfe9d099 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/ScaleExtension.cs b/Assets/02.InformationSave/RunTime/Extension/ScaleExtension.cs new file mode 100644 index 0000000..90312d5 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/ScaleExtension.cs @@ -0,0 +1,22 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class ScaleExtension + { + public static Scale.Information GetScaleInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static Vector3 GetScale(this Transform tf, string desc) + { + return GetScaleInformation(tf, desc).scale.SetVector3Data(); + } + + public static void SetScale(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/ScaleExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/ScaleExtension.cs.meta new file mode 100644 index 0000000..63de261 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/ScaleExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ebbe17c6f3f553745b5172d3f99fa4f6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/TrailRendererExtension.cs b/Assets/02.InformationSave/RunTime/Extension/TrailRendererExtension.cs new file mode 100644 index 0000000..c3a5976 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/TrailRendererExtension.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class TrailRendererExtension + { + public static TrailRendererInfo.Information GetTrailRendererInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/TrailRendererExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/TrailRendererExtension.cs.meta new file mode 100644 index 0000000..b1e726b --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/TrailRendererExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2409502855668eb4fa19a26c4675df0a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/TransformInfoExtension.cs b/Assets/02.InformationSave/RunTime/Extension/TransformInfoExtension.cs new file mode 100644 index 0000000..d2422a0 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/TransformInfoExtension.cs @@ -0,0 +1,17 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class TransformInfoExtension + { + public static TransformInfo.Information GetTransformInformation(this Transform tf, string desc) + { + return tf.GetComponent()._list.Find(n => n.desc == desc); + } + + public static void SetTransformInfo(this Transform tf, string desc) + { + tf.GetComponent().Set(desc); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Extension/TransformInfoExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/TransformInfoExtension.cs.meta new file mode 100644 index 0000000..cc3f53f --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/TransformInfoExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 276444401c6e3554497746391a9ce0e5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Extension/VectorExtension.cs b/Assets/02.InformationSave/RunTime/Extension/VectorExtension.cs new file mode 100644 index 0000000..6664e48 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/VectorExtension.cs @@ -0,0 +1,66 @@ +using System; +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public static class VectorExtension { + + + public static Vector3Data GetVector3Data(this Vector3 vector) + { + return new Vector3Data(vector); + } + + public static Vector3 SetVector3Data(this Vector3Data vector3Data) + { + return new Vector3(vector3Data.x, vector3Data.y, vector3Data.z); + } + + public static Vector2Data GetVector2Data( this Vector2 vector) + { + return new Vector2Data(vector); + } + + public static Vector2 SetVector2Data(this Vector2Data vector3Data) + { + return new Vector2(vector3Data.x, vector3Data.y); + } + + } + [Serializable] + public class Vector3Data + { + public float x; + public float y; + public float z; + + public Vector3Data() + { + + } + public Vector3Data(Vector3 vector) + { + x = vector.x; + y = vector.y; + z = vector.z; + } + public Vector3Data(float x, float y, float z) + { + this.x = x; + this.y = y; + this.z = z; + } + } + [Serializable] + public class Vector2Data + { + public float x; + public float y; + + public Vector2Data(Vector2 vector) + { + x = vector.x; + y = vector.y; + } + } + } diff --git a/Assets/02.InformationSave/RunTime/Extension/VectorExtension.cs.meta b/Assets/02.InformationSave/RunTime/Extension/VectorExtension.cs.meta new file mode 100644 index 0000000..ba2dec4 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Extension/VectorExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a7ee1cfff85b47cb864e576a0253a648 +timeCreated: 1735197883 \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/JBoxCollider.cs b/Assets/02.InformationSave/RunTime/JBoxCollider.cs new file mode 100644 index 0000000..4e280a2 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/JBoxCollider.cs @@ -0,0 +1,28 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public class JBoxCollider : AbstractInformation + { + public override void Save(int index) + { + BoxCollider boxCollider = transform.GetComponent(); + _list[index].center =boxCollider.center.GetVector3Data(); + _list[index].size = boxCollider.size.GetVector3Data(); + } + + public override void Switch(int index) + { + BoxCollider boxCollider = transform.GetComponent(); + boxCollider.center =_list[index].center.SetVector3Data(); + boxCollider.size =_list[index].size.SetVector3Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data center; + public Vector3Data size; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/JBoxCollider.cs.meta b/Assets/02.InformationSave/RunTime/JBoxCollider.cs.meta new file mode 100644 index 0000000..02de51a --- /dev/null +++ b/Assets/02.InformationSave/RunTime/JBoxCollider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a9767f825c5c2f74e866f2ec5a79ec23 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/LocalCameraInfo.cs b/Assets/02.InformationSave/RunTime/LocalCameraInfo.cs new file mode 100644 index 0000000..5646420 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/LocalCameraInfo.cs @@ -0,0 +1,39 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public class LocalCameraInfo : AbstractInformation + { + public override void Save(int index) + { + var c = GetComponent(); + var tf = transform; + _list[index].localPosition =tf.localPosition.GetVector3Data(); + _list[index].localEulerAngles = tf.localEulerAngles.GetVector3Data(); + _list[index].orthographic = c.orthographic; + _list[index].orthographicSize = c.orthographicSize; + _list[index].fieldofView = c.fieldOfView; + } + + public override void Switch(int index) + { + var c = GetComponent(); + var tf = transform; + tf.localPosition = _list[index].localPosition.SetVector3Data(); + tf.localEulerAngles = _list[index].localEulerAngles.SetVector3Data(); + c.orthographic = _list[index].orthographic; + c.orthographicSize = _list[index].orthographicSize; + c.fieldOfView = _list[index].fieldofView; + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data localPosition; + public Vector3Data localEulerAngles; + public bool orthographic; + public float orthographicSize; + public float fieldofView; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/LocalCameraInfo.cs.meta b/Assets/02.InformationSave/RunTime/LocalCameraInfo.cs.meta new file mode 100644 index 0000000..2eb8c76 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/LocalCameraInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 38b8221364b888944b7aee29f7c57061 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/LocalEulerAngles.cs b/Assets/02.InformationSave/RunTime/LocalEulerAngles.cs new file mode 100644 index 0000000..c8363df --- /dev/null +++ b/Assets/02.InformationSave/RunTime/LocalEulerAngles.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public sealed class LocalEulerAngles : AbstractInformation + { + public override void Save(int index) + { + _list[index].localEulerAngles =transform.localEulerAngles.GetVector3Data(); + } + + public override void Switch(int index) + { + transform.localEulerAngles =_list[index].localEulerAngles.SetVector3Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data localEulerAngles; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/LocalEulerAngles.cs.meta b/Assets/02.InformationSave/RunTime/LocalEulerAngles.cs.meta new file mode 100644 index 0000000..2acdc84 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/LocalEulerAngles.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 280718ca1ccb11848abb4eaa2820e354 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/LocalPosition.cs b/Assets/02.InformationSave/RunTime/LocalPosition.cs new file mode 100644 index 0000000..84b974d --- /dev/null +++ b/Assets/02.InformationSave/RunTime/LocalPosition.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public sealed class LocalPosition : AbstractInformation + { + public override void Save(int index) + { + _list[index].localPosition = transform.localPosition.GetVector3Data(); + } + + public override void Switch(int index) + { + transform.localPosition = _list[index].localPosition.SetVector3Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data localPosition; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/LocalPosition.cs.meta b/Assets/02.InformationSave/RunTime/LocalPosition.cs.meta new file mode 100644 index 0000000..4dc9a50 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/LocalPosition.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 93ebac8518e1ce64fa0c16bebea343e6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/LocalPositionEulerAngles.cs b/Assets/02.InformationSave/RunTime/LocalPositionEulerAngles.cs new file mode 100644 index 0000000..6423705 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/LocalPositionEulerAngles.cs @@ -0,0 +1,28 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public sealed class LocalPositionEulerAngles : AbstractInformation + { + public override void Save(int index) + { + var tf = transform; + _list[index].localPosition =tf.localPosition.GetVector3Data(); + _list[index].localEulerAngles = tf.localEulerAngles.GetVector3Data(); + } + + public override void Switch(int index) + { + var tf = transform; + tf.localPosition = _list[index].localPosition.SetVector3Data(); + tf.localEulerAngles = _list[index].localEulerAngles.SetVector3Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data localPosition; + public Vector3Data localEulerAngles; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/LocalPositionEulerAngles.cs.meta b/Assets/02.InformationSave/RunTime/LocalPositionEulerAngles.cs.meta new file mode 100644 index 0000000..484f02a --- /dev/null +++ b/Assets/02.InformationSave/RunTime/LocalPositionEulerAngles.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e437187af71967c4ba3a675d6cd528ce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/LocalTransformInfo.cs b/Assets/02.InformationSave/RunTime/LocalTransformInfo.cs new file mode 100644 index 0000000..e54ab1d --- /dev/null +++ b/Assets/02.InformationSave/RunTime/LocalTransformInfo.cs @@ -0,0 +1,31 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public class LocalTransformInfo : AbstractInformation + { + public override void Save(int index) + { + var tf = transform; + _list[index].localPosition = tf.localPosition.GetVector3Data(); + _list[index].localEulerAngles =tf.localEulerAngles.GetVector3Data(); + _list[index].localScale = tf.localScale.GetVector3Data(); + } + + public override void Switch(int index) + { + var tf = transform; + tf.localPosition = _list[index].localPosition.SetVector3Data(); + tf.localEulerAngles = _list[index].localEulerAngles.SetVector3Data(); + tf.localScale = _list[index].localScale.SetVector3Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data localPosition; + public Vector3Data localEulerAngles; + public Vector3Data localScale; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/LocalTransformInfo.cs.meta b/Assets/02.InformationSave/RunTime/LocalTransformInfo.cs.meta new file mode 100644 index 0000000..e2fa35c --- /dev/null +++ b/Assets/02.InformationSave/RunTime/LocalTransformInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 550b2f30af9635045803b99a475a03ea +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Position.cs b/Assets/02.InformationSave/RunTime/Position.cs new file mode 100644 index 0000000..e3fae44 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Position.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public sealed class Position : AbstractInformation + { + public override void Save(int index) + { + _list[index].position = transform.position.GetVector3Data(); + } + + public override void Switch(int index) + { + transform.position = _list[index].position.SetVector3Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data position; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Position.cs.meta b/Assets/02.InformationSave/RunTime/Position.cs.meta new file mode 100644 index 0000000..72be8ec --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Position.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9609cbb4c8813d74689777d78711e4d5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/PositionEulerAngles.cs b/Assets/02.InformationSave/RunTime/PositionEulerAngles.cs new file mode 100644 index 0000000..945ded0 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/PositionEulerAngles.cs @@ -0,0 +1,28 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public sealed class PositionEulerAngles : AbstractInformation + { + public override void Save(int index) + { + var tf = transform; + _list[index].position =tf.position.GetVector3Data(); + _list[index].eulerAngles = tf.eulerAngles.GetVector3Data(); + } + + public override void Switch(int index) + { + var tf = transform; + tf.position = _list[index].position.SetVector3Data(); + tf.eulerAngles = _list[index].eulerAngles.SetVector3Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data position; + public Vector3Data eulerAngles; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/PositionEulerAngles.cs.meta b/Assets/02.InformationSave/RunTime/PositionEulerAngles.cs.meta new file mode 100644 index 0000000..a8d18fe --- /dev/null +++ b/Assets/02.InformationSave/RunTime/PositionEulerAngles.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ee618e2966ba0e94d83de5732a8e0b7f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/RectTransformInfo.cs b/Assets/02.InformationSave/RunTime/RectTransformInfo.cs new file mode 100644 index 0000000..1cfa0c8 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/RectTransformInfo.cs @@ -0,0 +1,47 @@ + +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public class RectTransformInfo : AbstractInformation + { + public override void Save(int index) + { + var rectTransform = GetComponent(); + _list[index].anchorPosition = rectTransform.anchoredPosition3D.GetVector3Data(); + _list[index].sizeDelta = rectTransform.sizeDelta.GetVector2Data(); + _list[index].eulerAngles = rectTransform.eulerAngles.GetVector3Data(); + _list[index].localScale = rectTransform.localScale.GetVector3Data(); + + _list[index].anchorMin = rectTransform.anchorMin.GetVector2Data(); + _list[index].anchorMax = rectTransform.anchorMax.GetVector2Data(); + _list[index].pivot = rectTransform.pivot.GetVector2Data(); + } + + public override void Switch(int index) + { + var rectTransform = GetComponent(); + rectTransform.anchoredPosition3D =_list[index].anchorPosition.SetVector3Data(); + rectTransform.sizeDelta = _list[index].sizeDelta.SetVector2Data(); + rectTransform.eulerAngles =_list[index].eulerAngles.SetVector3Data(); + rectTransform.localScale = _list[index].localScale.SetVector3Data(); + + rectTransform.anchorMin =_list[index].anchorMin.SetVector2Data(); + rectTransform.anchorMax =_list[index].anchorMax.SetVector2Data(); + rectTransform.pivot =_list[index].pivot.SetVector2Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data anchorPosition; + public Vector2Data sizeDelta; + public Vector3Data eulerAngles; + public Vector3Data localScale; + + public Vector2Data anchorMin; + public Vector2Data anchorMax; + public Vector2Data pivot; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/RectTransformInfo.cs.meta b/Assets/02.InformationSave/RunTime/RectTransformInfo.cs.meta new file mode 100644 index 0000000..78a2078 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/RectTransformInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c996c2dea2256ab4e8f690091315ef57 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/Scale.cs b/Assets/02.InformationSave/RunTime/Scale.cs new file mode 100644 index 0000000..993763e --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Scale.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public sealed class Scale : AbstractInformation + { + public override void Save(int index) + { + _list[index].scale = transform.localScale.GetVector3Data(); + } + + public override void Switch(int index) + { + transform.localScale =_list[index].scale.SetVector3Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data scale; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Scale.cs.meta b/Assets/02.InformationSave/RunTime/Scale.cs.meta new file mode 100644 index 0000000..5d02071 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/Scale.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bdf673576bf52084e8f9762011826aaa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/TrailRendererInfo.cs b/Assets/02.InformationSave/RunTime/TrailRendererInfo.cs new file mode 100644 index 0000000..6f3511b --- /dev/null +++ b/Assets/02.InformationSave/RunTime/TrailRendererInfo.cs @@ -0,0 +1,25 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public class TrailRendererInfo : AbstractInformation + { + public override void Save(int index) + { + TrailRenderer tr = transform.GetComponent(); + _list[index].time = tr.time; + } + + public override void Switch(int index) + { + TrailRenderer tr = transform.GetComponent(); + tr.time = _list[index].time; + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public float time; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/TrailRendererInfo.cs.meta b/Assets/02.InformationSave/RunTime/TrailRendererInfo.cs.meta new file mode 100644 index 0000000..c4d1c9d --- /dev/null +++ b/Assets/02.InformationSave/RunTime/TrailRendererInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2fbebc203db208a42bc3c5c279992067 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/RunTime/TransformInfo.cs b/Assets/02.InformationSave/RunTime/TransformInfo.cs new file mode 100644 index 0000000..bac9e55 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/TransformInfo.cs @@ -0,0 +1,31 @@ +using UnityEngine; + +namespace Stary.Evo.InformationSave +{ + public class TransformInfo : AbstractInformation + { + public override void Save(int index) + { + var tf = transform; + _list[index].position =tf.position.GetVector3Data(); + _list[index].eulerAngles = tf.eulerAngles.GetVector3Data(); + _list[index].localScale = tf.localScale.GetVector3Data(); + } + + public override void Switch(int index) + { + var tf = transform; + tf.position = _list[index].position.SetVector3Data(); + tf.eulerAngles =_list[index].eulerAngles.SetVector3Data(); + tf.localScale = _list[index].localScale.SetVector3Data(); + } + + [System.Serializable] + public sealed class Information : InformationBase + { + public Vector3Data position; + public Vector3Data eulerAngles; + public Vector3Data localScale; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/TransformInfo.cs.meta b/Assets/02.InformationSave/RunTime/TransformInfo.cs.meta new file mode 100644 index 0000000..d549f78 --- /dev/null +++ b/Assets/02.InformationSave/RunTime/TransformInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5a0f5c0e9005eca40a2e8ec448b3d8de +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/03.FiniteStateMachine/RunTime/FSMController.cs b/Assets/03.FiniteStateMachine/RunTime/FSMController.cs new file mode 100644 index 0000000..9848406 --- /dev/null +++ b/Assets/03.FiniteStateMachine/RunTime/FSMController.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +public class FSMController : MonoBehaviour +{ + private Dictionary states = new Dictionary(); + + public void AddState(SingleState state) + { + var type = state.GetType(); + if (!states.ContainsKey(type)) + { + // ʱʼ + state.Machine = this; + state.OnInit(); + states.Add(type, state); + } + else + { + Debug.LogError("FSMControllerѾӹ״̬"); + } + } + +/* //public bool IsRunning() where T : SingleState => IsRunning(typeof(T)); + + //public void Enter() where T : SingleState => Enter(typeof(T)); + + //public void Exit() where T : SingleState => Exit(typeof(T)); + + //public void ForceEnter() where T : SingleState => ForceEnter(typeof(T));*/ + + public bool IsRunning(Type type) + { + if (states.ContainsKey(type)) + { + if (states[type].IsRunning) return true; + } + else + { + Debug.LogError("״̬Ѳڣ"); + } + return false; + } + + public void Enter(Type type) + { + if (states.ContainsKey(type)) + { + if (IsRunning(type)) + { + Debug.LogError("״̬ڽУ޷ٴν룡"); + return; + } + ForceEnter(type); + } + else + { + Debug.LogError("״̬Ѳڣ"); + } + + } + + public void ForceEnter(Type type) + { + if (states.ContainsKey(type)) + { + SingleState state = states[type]; + state.OnEnter(); + state.IsRunning = true; + } + else + { + Debug.LogError("״̬Ѳڣ"); + } + } + + public void Exit(Type type) + { + if (states.TryGetValue(type, out SingleState state)) + { + if (!IsRunning(type)) return; + state.IsRunning = false; + state.OnExit(); + } + else + { + Debug.LogError("״̬Ѳڣ"); + } + + } + + public void ExitAll() + { + foreach (var state in states) + { + if (state.Value.IsRunning) Exit(state.Key); + } + } + + private void Update() + { + foreach (var state in states) + { + if (state.Value.IsRunning) state.Value.Update(); + } + } + + private void FixedUpdate() + { + foreach (var state in states) + { + if (state.Value.IsRunning) state.Value.FixedUpdate(); + } + } + + private void OnDestroy() + { + ExitAll(); + // ֵеÿ״̬ + foreach (var key in states.Keys.ToList()) + { + states[key].OnDestory(); + // ÿֵΪ nullͷ + states[key] = null; + } + // ֵ + states.Clear(); + } +} \ No newline at end of file diff --git a/Assets/03.FiniteStateMachine/RunTime/FSMController.cs.meta b/Assets/03.FiniteStateMachine/RunTime/FSMController.cs.meta new file mode 100644 index 0000000..d49012e --- /dev/null +++ b/Assets/03.FiniteStateMachine/RunTime/FSMController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0f1ae852fd60caf4da2aedfdd2b32e07 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/03.FiniteStateMachine/RunTime/FSMInitialize.cs b/Assets/03.FiniteStateMachine/RunTime/FSMInitialize.cs new file mode 100644 index 0000000..60d4635 --- /dev/null +++ b/Assets/03.FiniteStateMachine/RunTime/FSMInitialize.cs @@ -0,0 +1,46 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.SceneManagement; + +public static class FSMInitialize +{ + /// + /// ״̬ʼ + /// + /// ָ + /// + public static FSMManager Init(Scene targetScene) + { + GameObject targetObject = targetScene.GetRootGameObjects().FirstOrDefault(go => go.name == "FSMManger"); + FSMManager fSMManager; + + if (targetObject == null) + { + targetObject = new GameObject("FSMManger"); + SceneManager.MoveGameObjectToScene(targetObject, targetScene); + + fSMManager = new FSMManager(); + fSMManager.FSMMangerObject = targetObject; + + void OnSceneUnloaded(Scene scene) + { + // жʱͷŻ + if (scene.name == targetScene.name) + { + GameObject.Destroy(targetObject); + fSMManager = null; + } + } + SceneManager.sceneUnloaded += OnSceneUnloaded; + + return fSMManager; + } + else + { + Debug.LogError(": "+targetScene.name + "ѾʼFSM״̬"); + return null; + } + } +} diff --git a/Assets/03.FiniteStateMachine/RunTime/FSMInitialize.cs.meta b/Assets/03.FiniteStateMachine/RunTime/FSMInitialize.cs.meta new file mode 100644 index 0000000..55323a9 --- /dev/null +++ b/Assets/03.FiniteStateMachine/RunTime/FSMInitialize.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b42c8b9ea04cabf4d96cb64afb21a797 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/03.FiniteStateMachine/RunTime/FSMManager.cs b/Assets/03.FiniteStateMachine/RunTime/FSMManager.cs new file mode 100644 index 0000000..dd62904 --- /dev/null +++ b/Assets/03.FiniteStateMachine/RunTime/FSMManager.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +public class FSMManager +{ + public GameObject FSMMangerObject; + private Dictionary controllers = new Dictionary(); + private Dictionary states = new Dictionary(); + private int nextControllerId = 0; + private int nextStateId = 0; + + /// + /// FSMController + /// + /// شFSMControllerʶIntֵ + public int CreateFSMController() + { + if(FSMMangerObject == null) + { + Debug.LogError("FSM״̬δʼ"); + return -1; + } + else + { + int id = nextControllerId++; + GameObject newController = new GameObject("FSMController" + id); + newController.transform.SetParent(FSMMangerObject.transform); + var controller = newController.AddComponent(); + controllers[id] = controller; + return id; + } + } + + /// + /// ָFSMController + /// + /// + public void DestroyFSMController(int controllerId) + { + if (controllers.TryGetValue(controllerId, out var controller)) + { + GameObject.Destroy(controller.gameObject); + controllers.Remove(controllerId); + } + else + { + Debug.LogError("IdFSMControllerڻѱ٣"); + } + } + + /// + /// ˳ָControllerе״̬ + /// + /// + public void ExitAllStateInController(int controllerId) + { + if (controllers.TryGetValue(controllerId, out var controller)) + { + controller.ExitAll(); + } + else + { + Debug.LogError("IdFSMControllerڻѱ٣"); + } + } + + /// + /// ״̬ + /// + /// ״̬صControllerId + /// ״̬Ϊ + /// + public int CreateState(int controllerId, StateDateAction stateDateAction) + { + if (controllers.TryGetValue(controllerId, out var controller)) + { + // stateӵָcontroller + SingleState state = new SingleState(); + state.stateDate = stateDateAction; + controller.AddState(state); + int id = nextStateId++; + states[id] = state; + return id; + + } + else + { + Debug.LogError("IdFSMControllerڻѱ٣״̬ʼʧܣ"); + return -1; + } + } + + /// + /// ָ״̬ + /// + /// + public void EnterState(int stateId) + { + if(states.TryGetValue(stateId, out var state)) + { + state.Machine.Enter(state.GetType()); + } + else + { + Debug.LogError("Id״̬ڣ"); + } + } + + /// + /// 뿪ָ״̬ + /// + /// + public void ExitState(int stateId) + { + if (states.TryGetValue(stateId, out var state)) + { + state.Machine.Exit(state.GetType()); + } + else + { + Debug.LogError("Id״̬ڣ"); + } + } + + /// + /// ָ״̬ + /// + /// + public void DestroyState(int stateId) + { + if (states.TryGetValue(stateId, out var state)) + { + states.Remove(stateId); + } + } + + // ״̬ӵFSMController + public void AddStateToController(int controllerId, int stateId) + { + if (controllers.TryGetValue(controllerId, out var controller) && states.TryGetValue(stateId, out var state)) + { + controller.AddState(state); + } + } +} \ No newline at end of file diff --git a/Assets/03.FiniteStateMachine/RunTime/FSMManager.cs.meta b/Assets/03.FiniteStateMachine/RunTime/FSMManager.cs.meta new file mode 100644 index 0000000..939fe3f --- /dev/null +++ b/Assets/03.FiniteStateMachine/RunTime/FSMManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5ac80573cd6d59246a7fe1b954f1b57e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/03.FiniteStateMachine/RunTime/IState.cs b/Assets/03.FiniteStateMachine/RunTime/IState.cs new file mode 100644 index 0000000..72d43d7 --- /dev/null +++ b/Assets/03.FiniteStateMachine/RunTime/IState.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public interface IState +{ + public FSMController Machine { get; set; } + public void OnEnter(); + public void OnExit(); + public void Update(); + public void FixedUpdate(); + public void OnInit(); + public void OnDestory(); + +} + +public abstract class AbstractState : IState +{ + public FSMController Machine { get; set; } + public abstract void OnEnter(); + public abstract void OnExit(); + public abstract void Update(); + public abstract void FixedUpdate(); + public abstract void OnInit(); + public abstract void OnDestory(); +} + +/// +/// ״̬оΪ +/// OnInitActionʼ +/// OnEnterAction룩 +/// UpdateActionѭ +/// FixedUpdateActionѭ +/// OnExitAction뿪 +/// OnDestoryAction٣ +/// +public struct StateDateAction +{ + public System.Action OnEnterAction; + public System.Action OnExitAction; + public System.Action UpdateAction; + public System.Action FixedUpdateAction; + public System.Action OnInitAction; + public System.Action OnDestoryAction; +} + +/// +/// ״̬ +/// +public class SingleState : AbstractState +{ + public StateDateAction stateDate; + public bool IsRunning; + + public override void FixedUpdate() + { + stateDate.FixedUpdateAction?.Invoke(); + } + + public override void OnDestory() + { + stateDate.OnDestoryAction?.Invoke(); + } + + public override void OnEnter() + { + stateDate.OnEnterAction?.Invoke(); + } + + public override void OnExit() + { + stateDate.OnExitAction?.Invoke(); + } + + public override void OnInit() + { + stateDate.OnInitAction?.Invoke(); + } + + public override void Update() + { + stateDate.UpdateAction?.Invoke(); + } +} diff --git a/Assets/03.FiniteStateMachine/RunTime/IState.cs.meta b/Assets/03.FiniteStateMachine/RunTime/IState.cs.meta new file mode 100644 index 0000000..07d7888 --- /dev/null +++ b/Assets/03.FiniteStateMachine/RunTime/IState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9a115cd1615ea994493a6950339d2f1e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/03.FiniteStateMachine/RunTime/PlayerFSMExample.cs b/Assets/03.FiniteStateMachine/RunTime/PlayerFSMExample.cs new file mode 100644 index 0000000..b6228ca --- /dev/null +++ b/Assets/03.FiniteStateMachine/RunTime/PlayerFSMExample.cs @@ -0,0 +1,53 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; + +public class PlayerFSMExample : MonoBehaviour +{ + private int controllerId; + private int idleStateId; + private float timer = 0.0f; + private FSMManager fSMManager; + + void Start() + { + fSMManager = FSMInitialize.Init(gameObject.scene); + controllerId = fSMManager.CreateFSMController(); + StateDateAction stateDateAction = new StateDateAction() + { + OnEnterAction = () => + { + Debug.Log("״̬"); + }, + UpdateAction = () => + { + timer += Time.deltaTime; + Debug.Log("ǰʱ䣺" + timer); + }, + OnExitAction = () => + { + Debug.Log("뿪״̬"); + } + }; + idleStateId = fSMManager.CreateState(controllerId, stateDateAction); + } + + void Update() + { + // ¿ոлRunning״̬ + if (Input.GetKeyDown(KeyCode.A)) + { + fSMManager.EnterState(idleStateId); + } + if (Input.GetKeyDown(KeyCode.D)) + { + fSMManager.ExitState(idleStateId); + } + } + + void OnDestroy() + { + + } +} \ No newline at end of file diff --git a/Assets/03.FiniteStateMachine/RunTime/PlayerFSMExample.cs.meta b/Assets/03.FiniteStateMachine/RunTime/PlayerFSMExample.cs.meta new file mode 100644 index 0000000..26a4701 --- /dev/null +++ b/Assets/03.FiniteStateMachine/RunTime/PlayerFSMExample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0deab708fd53bb4428ef48220df57be7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/04.AudioCore/RunTime/AudioCoreManager.cs b/Assets/04.AudioCore/RunTime/AudioCoreManager.cs new file mode 100644 index 0000000..816d7ee --- /dev/null +++ b/Assets/04.AudioCore/RunTime/AudioCoreManager.cs @@ -0,0 +1,93 @@ +using UnityEngine; +using System.Collections.Generic; + +namespace AudioCore +{ + public static class AudioCoreManager + { + private static AudioSourcePool audioSourcePool; + private static VoicePlayer Voice; + private static SFXPlayer SFX; + private static MusicPlayer Music; + + static AudioCoreManager() + { + audioSourcePool = new AudioSourcePool(); + // ʼ + Voice = new VoicePlayer(audioSourcePool); + SFX = new SFXPlayer(audioSourcePool); + Music = new MusicPlayer(audioSourcePool); + } + + #region + + /// + /// + /// + /// {[clip:Ƶ], [volume:], + /// [onComplete:صΪ], [delayOnCompleteTime:ӳٻصִеʱ]} + public static void PlayVoice(AudioData audioData) + { + Voice.Play(audioData); + } + + /// + /// ֹͣǰ + /// + public static void StopVoice() + { + AudioData audioData = new AudioData(); + Voice.Stop(audioData); + } + + #endregion + + #region Ч + + /// + /// Ч + /// + /// {[clip:Ƶ], [volume:], + /// [onComplete:صΪ], [delayOnCompleteTime:ӳٻصִеʱ]} + public static void PlaySFX(AudioData audioData) + { + SFX.Play(audioData); + } + + /// + /// ֹͣЧ + /// + public static void StopAllSFX() + { + AudioData audioData = new AudioData(); + SFX.Stop(audioData); + } + + #endregion + + #region + + /// + /// ű + /// + /// {[clip:Ƶ], [volume:], [fadeDuration:Ȼʱ]} + public static void PlayMusic(AudioData audioData) + { + Music.Play(audioData); + } + + /// + /// ֹͣű + /// + /// Ȼʱ + public static void StopMusic(float fadeDuration = 1f) + { + AudioData audioData = new AudioData(); + audioData.fadeDuration = fadeDuration; + Music.Stop(audioData); + } + + #endregion + + } +} \ No newline at end of file diff --git a/Assets/04.AudioCore/RunTime/AudioCoreManager.cs.meta b/Assets/04.AudioCore/RunTime/AudioCoreManager.cs.meta new file mode 100644 index 0000000..f42b09e --- /dev/null +++ b/Assets/04.AudioCore/RunTime/AudioCoreManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d2dc9112fdb158489cae641ffcec61e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/04.AudioCore/RunTime/AudioSourcePool.cs b/Assets/04.AudioCore/RunTime/AudioSourcePool.cs new file mode 100644 index 0000000..c682f27 --- /dev/null +++ b/Assets/04.AudioCore/RunTime/AudioSourcePool.cs @@ -0,0 +1,142 @@ +using UnityEngine; +using System.Collections.Generic; +using UnityEngine.SceneManagement; + +namespace AudioCore +{ + public class AudioSourcePool + { + private Dictionary> poolDict = new Dictionary>(); + private GameObject poolObject; + + /// + /// سʼ + /// + private void PoolAwake() + { + // ǷѾһΪ"AudioSourcePool"Ķ + SceneManager.sceneUnloaded += OnSceneUnloaded; + poolObject = GameObject.Find("AudioSourcePool"); + if (poolObject == null) + { + // ڣһ¶ + poolObject = new GameObject("AudioSourcePool"); + } + CoroutineHelper.SetRunner(); + + // ʼ Voice أ 1 ɶ̬չ + poolDict["Voice"] = new Queue(); + CreateAudioSource("Voice"); + + // ʼ Music أ 2 + poolDict["Music"] = new Queue(); + for (int i = 0; i < 2; i++) + { + CreateAudioSource("Music"); + } + + // ʼ SFX أʼ 4 ɶ̬չ + poolDict["SFX"] = new Queue(); + for (int i = 0; i < 4; i++) + { + CreateAudioSource("SFX"); + } + } + + /// + /// + /// + /// + private void CreateAudioSource(string type) + { + GameObject newObject = new GameObject($"AudioSource_{type}"); + newObject.transform.SetParent(poolObject.transform); // ¶ΪǰӶ + newObject.AddComponent().playOnAwake = false; // AudioSource Զ + if (type == "Music") + { + newObject.GetComponent().loop = true; + } + poolDict[type].Enqueue(newObject); + } + + /// + /// ȡ + /// + /// + /// + public AudioSource GetAudioSource(string type) + { + if (poolObject == null) + { + PoolAwake(); + } + + if (!poolDict.ContainsKey(type)) + { + Debug.LogError($"в: {type}"); + return null; + } + + if (poolDict[type].Count == 0) + { + // Ϊգ̬µ GameObject SFX Voice + if (type == "SFX" && type == "Voice") + { + CreateAudioSource(type); + } + else + { + Debug.LogWarning($" {type} ꣬޷µ AudioSource"); + return null; + } + + CreateAudioSource(type); + } + + GameObject audioObject = poolDict[type].Dequeue(); + AudioSource audioSource = audioObject.GetComponent(); + return audioSource; + } + + /// + /// ն + /// + /// + /// + public void ReturnAudioSource(string type, GameObject audioObject) + { + if (!poolDict.ContainsKey(type)) + { + Debug.LogError($"в: {type}"); + return; + } + + AudioSource audioSource = audioObject.GetComponent(); + audioSource.Stop(); // ֹͣ + audioSource.clip = null; // Ƶ + audioSource.volume = 1f; // Сָ + poolDict[type].Enqueue(audioObject); // յ + } + + /// + /// ʱն + /// + /// + void OnSceneUnloaded(Scene scene) + { + foreach (var pair in poolDict) + { + Queue queue = pair.Value; + while (queue.Count > 0) + { + GameObject obj = queue.Dequeue(); + if (obj != null) + { + UnityEngine.Object.Destroy(obj); + } + } + } + poolDict.Clear(); + } + } +} \ No newline at end of file diff --git a/Assets/04.AudioCore/RunTime/AudioSourcePool.cs.meta b/Assets/04.AudioCore/RunTime/AudioSourcePool.cs.meta new file mode 100644 index 0000000..5f7a88b --- /dev/null +++ b/Assets/04.AudioCore/RunTime/AudioSourcePool.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b0879cbfda12f434f97c3e393664b7ec +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/04.AudioCore/RunTime/CoroutineHelper.cs b/Assets/04.AudioCore/RunTime/CoroutineHelper.cs new file mode 100644 index 0000000..263ab9a --- /dev/null +++ b/Assets/04.AudioCore/RunTime/CoroutineHelper.cs @@ -0,0 +1,28 @@ +using System.Collections; +using UnityEngine; +using UnityEngine.Internal; + +namespace AudioCore +{ + public static class CoroutineHelper + { + private static CoroutineRunner coroutineRunner; + + public static void SetRunner() + { + GameObject runnerObject = new GameObject("CoroutineRunner"); + coroutineRunner = runnerObject.AddComponent(); + } + public static Coroutine StartCoroutine(IEnumerator coroutine) + { + Coroutine myCoroutine = coroutineRunner.StartCoroutine(coroutine); + return myCoroutine; + } + public static void StopCoroutine(Coroutine myCoroutine) + { + coroutineRunner.StopCoroutine(myCoroutine); + } + + private class CoroutineRunner : MonoBehaviour { } + } +} diff --git a/Assets/04.AudioCore/RunTime/CoroutineHelper.cs.meta b/Assets/04.AudioCore/RunTime/CoroutineHelper.cs.meta new file mode 100644 index 0000000..8a7885c --- /dev/null +++ b/Assets/04.AudioCore/RunTime/CoroutineHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6f7491906db8d634a8aa1655c3b5621a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/04.AudioCore/RunTime/IAudio.cs b/Assets/04.AudioCore/RunTime/IAudio.cs new file mode 100644 index 0000000..bcf044f --- /dev/null +++ b/Assets/04.AudioCore/RunTime/IAudio.cs @@ -0,0 +1,85 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AudioCore +{ + /// + /// Audio + /// + public struct AudioData + { + /// + /// ӳٲʱ + /// + public float delayTime; + + /// + /// Ƶ + /// + public AudioClip clip; + + /// + /// + /// + public float volume; + + /// + /// صΪ + /// + public System.Action onComplete; + + /// + /// ӳٻصִеʱ + /// + public float delayOnCompleteTime; + + /// + /// Ȼʱ + /// + public float fadeDuration; + + /// + /// Ƿ񲻴һζԻ + /// + public bool isNotOverVoice; + + /// + /// Ƿ3D + /// + public bool is3D; + + /// + /// 3D + /// + public GameObject soundObject; + } + + public interface IAudio + { + void Play(AudioData audioData); + + void Stop(AudioData audioData); + + } + public abstract class AbstractAudio : IAudio + { + public abstract void Play(AudioData audioData); + + public abstract void Stop(AudioData audioData); + + /// + /// Ƶݳʼ + /// + /// + /// + public virtual AudioData AudioDataInitialize(AudioData audioData) + { + if (audioData.volume == 0) + { + audioData.volume = 1f; + } + return audioData; + } + } +} diff --git a/Assets/04.AudioCore/RunTime/IAudio.cs.meta b/Assets/04.AudioCore/RunTime/IAudio.cs.meta new file mode 100644 index 0000000..9b2f830 --- /dev/null +++ b/Assets/04.AudioCore/RunTime/IAudio.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a45ad70b96df7ae428058f547876d158 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/04.AudioCore/RunTime/MusicPlayer.cs b/Assets/04.AudioCore/RunTime/MusicPlayer.cs new file mode 100644 index 0000000..4848a0c --- /dev/null +++ b/Assets/04.AudioCore/RunTime/MusicPlayer.cs @@ -0,0 +1,128 @@ +using System.Collections; +using UnityEngine; + +namespace AudioCore +{ + public class MusicPlayer : AbstractAudio + { + private AudioSourcePool audioSourcePool; + private AudioSource audioSource1; + private AudioSource audioSource2; + private AudioSource currentAudioSource; + + public MusicPlayer(AudioSourcePool audioSourcePool) + { + this.audioSourcePool = audioSourcePool; + } + + /// + /// ű + /// + /// {[clip:Ƶ], [volume:], [fadeDuration:Ȼʱ]} + public override void Play(AudioData audioData) + { + audioData = AudioDataInitialize(audioData); + if (audioSource1 == null) + { + audioSource1 = audioSourcePool.GetAudioSource("Music"); + audioSource1.clip = audioData.clip; + audioSource1.volume = audioData.volume; + currentAudioSource = audioSource1; + currentAudioSource.Play(); + CoroutineHelper.StartCoroutine(FadeMusic(audioSource1, audioData.fadeDuration, audioSource2)); + } + else + { + if (audioSource2 == null) + { + audioSource2 = audioSourcePool.GetAudioSource("Music"); + audioSource2.clip = audioData.clip; + audioSource2.volume = audioData.volume; + currentAudioSource = audioSource2; + currentAudioSource.Play(); + CoroutineHelper.StartCoroutine(FadeMusic(audioSource2, audioData.fadeDuration, audioSource1)); + } + else + { + Debug.LogWarning("ͬʱл"); + } + } + + } + + /// + /// رձ + /// + /// {[fadeDuration:Ȼʱ]} + public override void Stop(AudioData audioData) + { + audioData = AudioDataInitialize(audioData); + CoroutineHelper.StartCoroutine(FadeOutMusic(currentAudioSource, audioData.fadeDuration)); + } + + /// + /// лƵ + /// + /// ŵƵ + /// 仯ʱ + /// ֹͣƵ + /// + private IEnumerator FadeMusic(AudioSource source1, float fadeDuration, AudioSource source2 = null) + { + yield return FadeInMusic(source1, fadeDuration); + + if (source2 != null) + { + yield return FadeOutMusic(source2, fadeDuration); + } + + } + + /// + /// رƵЭ + /// + /// + /// + /// + private IEnumerator FadeOutMusic(AudioSource source, float fadeDuration) + { + float startVolume = source.volume; + + while (source.volume > 0) + { + source.volume -= startVolume * Time.deltaTime / fadeDuration; + yield return null; + } + + source.Stop(); + audioSourcePool.ReturnAudioSource("Music", source.gameObject); + + if (currentAudioSource == audioSource1) + { + audioSource2 = null; + } + else if (currentAudioSource == audioSource2) + { + audioSource1 = null; + } + } + + /// + /// ƵЭ + /// + /// + /// + /// + private IEnumerator FadeInMusic(AudioSource source, float fadeDuration) + { + float targetVolume = source.volume; + source.volume = 0; + + while (source.volume < targetVolume) + { + source.volume += targetVolume * Time.deltaTime / fadeDuration; + yield return null; + } + } + } +} \ No newline at end of file diff --git a/Assets/04.AudioCore/RunTime/MusicPlayer.cs.meta b/Assets/04.AudioCore/RunTime/MusicPlayer.cs.meta new file mode 100644 index 0000000..0b0aba4 --- /dev/null +++ b/Assets/04.AudioCore/RunTime/MusicPlayer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cbd824d200553654e958ab9e5ef3f040 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/04.AudioCore/RunTime/SFXPlayer.cs b/Assets/04.AudioCore/RunTime/SFXPlayer.cs new file mode 100644 index 0000000..fb5484d --- /dev/null +++ b/Assets/04.AudioCore/RunTime/SFXPlayer.cs @@ -0,0 +1,71 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AudioCore +{ + public class SFXPlayer : AbstractAudio + { + private AudioSourcePool audioSourcePool; + private List activeSources = new List(); // ڲŵ AudioSource б + + public SFXPlayer(AudioSourcePool audioSourcePool) + { + this.audioSourcePool = audioSourcePool; + } + + /// + /// Ч + /// + /// {[clip:Ƶ], [volume:], + /// [onComplete:صΪ], [delayOnCompleteTime:ӳٻصִеʱ]} + public override void Play(AudioData audioData) + { + AudioSource source = audioSourcePool.GetAudioSource("SFX"); + if (source == null) return; + + source.clip = audioData.clip; + source.volume = audioData.volume; + source.Play(); + + // AudioSource б + activeSources.Add(source); + + // ʹЭ̴ӳٺͻص + CoroutineHelper.StartCoroutine(PlaySFXCoroutine(source, audioData.delayOnCompleteTime, audioData.onComplete)); + } + + /// + /// ֹͣЧ + /// + /// {[޿ʹñ]} + public override void Stop(AudioData audioData) + { + foreach (var source in activeSources) + { + if (source.isPlaying) + { + source.Stop(); + audioSourcePool.ReturnAudioSource("SFX", source.gameObject); + } + } + activeSources.Clear(); + } + + /// + /// ЧЭ + /// + /// + /// + /// + /// + private IEnumerator PlaySFXCoroutine(AudioSource source, float delay, System.Action onComplete) + { + yield return new WaitForSeconds(source.clip.length + delay); + + onComplete?.Invoke(); + audioSourcePool.ReturnAudioSource("SFX", source.gameObject); + activeSources.Remove(source); + } + } +} \ No newline at end of file diff --git a/Assets/04.AudioCore/RunTime/SFXPlayer.cs.meta b/Assets/04.AudioCore/RunTime/SFXPlayer.cs.meta new file mode 100644 index 0000000..8b3d782 --- /dev/null +++ b/Assets/04.AudioCore/RunTime/SFXPlayer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 19ed6bde81273554f89ece0a1147f33d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/04.AudioCore/RunTime/Test.cs b/Assets/04.AudioCore/RunTime/Test.cs new file mode 100644 index 0000000..3123d06 --- /dev/null +++ b/Assets/04.AudioCore/RunTime/Test.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; +using AudioCore; + +public class Test : MonoBehaviour +{ + public AudioClip clip1; + public AudioClip clip2; + public AudioClip clip21; + public AudioClip clip22; + public AudioClip clip31; + public AudioClip clip32; + + void Start() + { + //AudioCore.PlayerPrefs(); + } + + void Update() + { + if (Input.GetKeyDown(KeyCode.A)) + { + AudioCoreManager.PlayVoice(new AudioData { clip = clip1 }); + } + if (Input.GetKeyDown(KeyCode.S)) + { + AudioCoreManager.PlayVoice(new AudioData { clip = clip2 }); + } + if (Input.GetKeyDown(KeyCode.D)) + { + AudioCoreManager.PlaySFX(new AudioData { clip = clip21 }); + } + if (Input.GetKeyDown(KeyCode.F)) + { + AudioCoreManager.PlaySFX(new AudioData { clip = clip22 }); + } + if (Input.GetKeyDown(KeyCode.G)) + { + AudioCoreManager.PlayMusic(new AudioData { clip = clip31 }); + } + if (Input.GetKeyDown(KeyCode.H)) + { + AudioCoreManager.PlayMusic(new AudioData { clip = clip32 }); + } + if (Input.GetKeyDown(KeyCode.Z)) + { + AudioCoreManager.StopVoice(); + } + if (Input.GetKeyDown(KeyCode.X)) + { + AudioCoreManager.StopAllSFX(); + } + if (Input.GetKeyDown(KeyCode.C)) + { + AudioCoreManager.StopMusic(); + } + if (Input.GetKeyDown(KeyCode.Space)) + { + SceneManager.LoadScene(1); + } + } +} diff --git a/Assets/04.AudioCore/RunTime/Test.cs.meta b/Assets/04.AudioCore/RunTime/Test.cs.meta new file mode 100644 index 0000000..4bdb8db --- /dev/null +++ b/Assets/04.AudioCore/RunTime/Test.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2cca50490fb28574697c5fd3d2d37b52 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/04.AudioCore/RunTime/VoicePlayer.cs b/Assets/04.AudioCore/RunTime/VoicePlayer.cs new file mode 100644 index 0000000..8575d8b --- /dev/null +++ b/Assets/04.AudioCore/RunTime/VoicePlayer.cs @@ -0,0 +1,76 @@ +using System.Collections; +using UnityEngine; + +namespace AudioCore +{ + public class VoicePlayer : AbstractAudio + { + private AudioSourcePool audioSourcePool; + private AudioSource currentSource; + private Coroutine myCoroutine; + + public VoicePlayer(AudioSourcePool audioSourcePool) + { + this.audioSourcePool = audioSourcePool; + } + + /// + /// + /// + /// {[clip:Ƶ], [volume:], + /// [onComplete:صΪ], [delayOnCompleteTime:ӳٻصִеʱ]} + public override void Play(AudioData audioData) + { + // ֹͣǰڲŵЭ + Stop(new AudioData { }); + + audioData = AudioDataInitialize(audioData); + + if (myCoroutine != null) + { + CoroutineHelper.StopCoroutine(myCoroutine); + myCoroutine = null; + } + currentSource = audioSourcePool.GetAudioSource("Voice"); + if (currentSource == null) return; + + currentSource.clip = audioData.clip; + currentSource.volume = audioData.volume; + currentSource.Play(); + + // ʹЭ̴ӳٺͻص + myCoroutine = CoroutineHelper.StartCoroutine(PlayVoiceCoroutine(currentSource, audioData.delayOnCompleteTime, audioData.onComplete)); + } + + /// + /// ֹͣ + /// + /// /// {[޿ʹñ]} + public override void Stop(AudioData audioData) + { + if (currentSource != null && currentSource.isPlaying) + { + currentSource.Stop(); + audioSourcePool.ReturnAudioSource("Voice", currentSource.gameObject); + currentSource = null; + } + } + + /// + /// Э + /// + /// + /// + /// + /// + private IEnumerator PlayVoiceCoroutine(AudioSource source, float delayOnComplete, System.Action onComplete) + { + yield return new WaitForSeconds(source.clip.length + delayOnComplete); + + onComplete?.Invoke(); + audioSourcePool.ReturnAudioSource("Voice", source.gameObject); + currentSource = null; + myCoroutine = null; + } + } +} \ No newline at end of file diff --git a/Assets/04.AudioCore/RunTime/VoicePlayer.cs.meta b/Assets/04.AudioCore/RunTime/VoicePlayer.cs.meta new file mode 100644 index 0000000..1ca4aa7 --- /dev/null +++ b/Assets/04.AudioCore/RunTime/VoicePlayer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ff93caf4019714a4797e6986c6e5c234 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/04.AudioCore/package.json b/Assets/04.AudioCore/package.json index 85089a1..48f0aba 100644 --- a/Assets/04.AudioCore/package.json +++ b/Assets/04.AudioCore/package.json @@ -2,7 +2,7 @@ "name": "com.staryevo.codechecker", "version": "1.0.0", "displayName": "01.CodeChecker", - "description": "代码检查工具", + "description": "音频播放工具", "unity": "2021.3", "unityRelease": "30f1", "keywords": [ diff --git a/Assets/Audio.meta b/Assets/Audio.meta new file mode 100644 index 0000000..1d4c902 --- /dev/null +++ b/Assets/Audio.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bf2ebf709c2dff24086961e12cdf61b3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Music.meta b/Assets/Audio/Music.meta new file mode 100644 index 0000000..0785db5 --- /dev/null +++ b/Assets/Audio/Music.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ec0df2cf44e3f1d45b7cf7d914fc1f60 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/SFX.meta b/Assets/Audio/SFX.meta new file mode 100644 index 0000000..171f1a0 --- /dev/null +++ b/Assets/Audio/SFX.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 21d3c62239a23f942858ede80c7c8581 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Voice.meta b/Assets/Audio/Voice.meta new file mode 100644 index 0000000..89b3d8a --- /dev/null +++ b/Assets/Audio/Voice.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d0d386b8e27f46849b37c318647caf9c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Voice/Au_象鸟_游戏引入.wav b/Assets/Audio/Voice/Au_象鸟_游戏引入.wav new file mode 100644 index 0000000..da72d68 Binary files /dev/null and b/Assets/Audio/Voice/Au_象鸟_游戏引入.wav differ diff --git a/Assets/Audio/Voice/Au_象鸟_游戏引入.wav.meta b/Assets/Audio/Voice/Au_象鸟_游戏引入.wav.meta new file mode 100644 index 0000000..a85969f --- /dev/null +++ b/Assets/Audio/Voice/Au_象鸟_游戏引入.wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: 6689aaa78797acf4aa733003ddad16b9 +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Voice/Au_象鸟_结尾升华2.wav b/Assets/Audio/Voice/Au_象鸟_结尾升华2.wav new file mode 100644 index 0000000..c61433c Binary files /dev/null and b/Assets/Audio/Voice/Au_象鸟_结尾升华2.wav differ diff --git a/Assets/Audio/Voice/Au_象鸟_结尾升华2.wav.meta b/Assets/Audio/Voice/Au_象鸟_结尾升华2.wav.meta new file mode 100644 index 0000000..f1d4c04 --- /dev/null +++ b/Assets/Audio/Voice/Au_象鸟_结尾升华2.wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: 933538c8c54c7b24e9b1c2e06fc52506 +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene 1.unity b/Assets/Scenes/SampleScene 1.unity new file mode 100644 index 0000000..a8565fb --- /dev/null +++ b/Assets/Scenes/SampleScene 1.unity @@ -0,0 +1,352 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 705507994} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &265350652 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 265350654} + - component: {fileID: 265350653} + m_Layer: 0 + m_Name: GameObject + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &265350653 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 265350652} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2cca50490fb28574697c5fd3d2d37b52, type: 3} + m_Name: + m_EditorClassIdentifier: + clip1: {fileID: 8300000, guid: 6689aaa78797acf4aa733003ddad16b9, type: 3} + clip2: {fileID: 8300000, guid: 933538c8c54c7b24e9b1c2e06fc52506, type: 3} + clip21: {fileID: 8300000, guid: 6689aaa78797acf4aa733003ddad16b9, type: 3} + clip22: {fileID: 8300000, guid: 933538c8c54c7b24e9b1c2e06fc52506, type: 3} + clip31: {fileID: 0} + clip32: {fileID: 0} +--- !u!4 &265350654 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 265350652} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &705507993 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 705507995} + - component: {fileID: 705507994} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &705507994 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 1 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &705507995 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &963194225 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 963194228} + - component: {fileID: 963194227} + - component: {fileID: 963194226} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &963194226 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 +--- !u!20 &963194227 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &963194228 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scenes/SampleScene 1.unity.meta b/Assets/Scenes/SampleScene 1.unity.meta new file mode 100644 index 0000000..ff55def --- /dev/null +++ b/Assets/Scenes/SampleScene 1.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2bef2297eeb62d948b3fde560e43e9a2 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 2221b04..2da6faf 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -38,7 +38,6 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 705507994} - m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -118,14 +117,67 @@ NavMeshSettings: manualTileSize: 0 tileSize: 256 accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &265350652 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 265350654} + - component: {fileID: 265350653} + m_Layer: 0 + m_Name: GameObject + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &265350653 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 265350652} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2cca50490fb28574697c5fd3d2d37b52, type: 3} + m_Name: + m_EditorClassIdentifier: + clip1: {fileID: 8300000, guid: 6689aaa78797acf4aa733003ddad16b9, type: 3} + clip2: {fileID: 8300000, guid: 933538c8c54c7b24e9b1c2e06fc52506, type: 3} + clip21: {fileID: 8300000, guid: 6689aaa78797acf4aa733003ddad16b9, type: 3} + clip22: {fileID: 8300000, guid: 933538c8c54c7b24e9b1c2e06fc52506, type: 3} + clip31: {fileID: 8300000, guid: 6689aaa78797acf4aa733003ddad16b9, type: 3} + clip32: {fileID: 8300000, guid: 933538c8c54c7b24e9b1c2e06fc52506, type: 3} +--- !u!4 &265350654 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 265350652} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &705507993 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 705507995} @@ -141,15 +193,18 @@ GameObject: Light: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 705507993} m_Enabled: 1 - serializedVersion: 8 + serializedVersion: 10 m_Type: 1 + m_Shape: 0 m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} m_Intensity: 1 m_Range: 10 m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 m_CookieSize: 10 m_Shadows: m_Type: 2 @@ -159,6 +214,24 @@ Light: m_Bias: 0.05 m_NormalBias: 0.4 m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 m_Cookie: {fileID: 0} m_DrawHalo: 0 m_Flare: {fileID: 0} @@ -166,23 +239,29 @@ Light: m_CullingMask: serializedVersion: 2 m_Bits: 4294967295 + m_RenderingLayerMask: 1 m_Lightmapping: 1 m_LightShadowCasterMode: 0 m_AreaSize: {x: 1, y: 1} m_BounceIntensity: 1 m_ColorTemperature: 6570 m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 m_ShadowRadius: 0 m_ShadowAngle: 0 --- !u!4 &705507995 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 705507993} m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 0, y: 3, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 1 @@ -191,7 +270,8 @@ Transform: GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 963194228} @@ -208,23 +288,26 @@ GameObject: AudioListener: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 963194225} m_Enabled: 1 --- !u!20 &963194227 Camera: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 963194225} m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 m_SensorSize: {x: 36, y: 24} m_LensShift: {x: 0, y: 0} - m_GateFitMode: 2 m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 @@ -256,11 +339,13 @@ Camera: Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 963194225} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 1, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0