InformationSaveAndAudioCore_Over
This commit is contained in:
27
Assets/02.InformationSave/Editor/CustomEditorBaseEditor.cs
Normal file
27
Assets/02.InformationSave/Editor/CustomEditorBaseEditor.cs
Normal file
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3c60c3d4c25c5c428dc3e5835b40ac5
|
||||
guid: 2da8df4f2ba04494a90eec6fda524a49
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
8
Assets/02.InformationSave/RunTime/Abstract.meta
Normal file
8
Assets/02.InformationSave/RunTime/Abstract.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e0efc3ec4ae1fe458358558357e78fb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,201 @@
|
||||
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<T> : CustomEditorBase where T : InformationBase, new()
|
||||
{
|
||||
[HideInInspector] public List<T> _list = new List<T>();
|
||||
|
||||
/// <summary>
|
||||
/// 配置文件存储路径
|
||||
/// </summary>
|
||||
string path = "Assets/02.InformationSave/RunTime/Data/ScriptObjectSaveData.asset";
|
||||
|
||||
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 = AssetDatabase.LoadAssetAtPath<ScriptObjectSave>(path);
|
||||
if(scriptObjectSaveData == null)
|
||||
{
|
||||
Debug.LogError("ScriptObjectSaveData配置文件丢失");
|
||||
return;
|
||||
}
|
||||
|
||||
if (scriptObjectSaveData.dic.ContainsKey(sceneNmae + gameObject.name))
|
||||
{
|
||||
_list.Clear();
|
||||
_list = scriptObjectSaveData.dic[sceneNmae + gameObject.name].OfType<T>().ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("ScriptObjectSaveData中未存储场景:"+ sceneNmae + " 中物体:" + gameObject.name + "的数据!!!");
|
||||
}
|
||||
}
|
||||
|
||||
//动态保存
|
||||
public bool PlayingSave()
|
||||
{
|
||||
//文件保存
|
||||
if (Application.isEditor)
|
||||
{
|
||||
String sceneNmae = gameObject.scene.name;
|
||||
// 加载 ScriptObjectSaveData
|
||||
ScriptObjectSave scriptObjectSaveData = AssetDatabase.LoadAssetAtPath<ScriptObjectSave>(path);
|
||||
if(scriptObjectSaveData != null)
|
||||
{
|
||||
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<InformationBase>(_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果不存在,添加新的键值对
|
||||
scriptObjectSaveData.dic.Add(sceneNmae + gameObject.name, new List<InformationBase>(_list));
|
||||
}
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("ScriptObjectSaveData配置文件丢失");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//private int guidIndex;
|
||||
|
||||
//private List<string> strings = new List<string>();
|
||||
|
||||
//绘制
|
||||
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 = "初始";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f5b94406351c9c4984472ef696d4888
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Assets/02.InformationSave/RunTime/AnchoredPosition.cs
Normal file
27
Assets/02.InformationSave/RunTime/AnchoredPosition.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
//=======================================================
|
||||
// 作者:张铮
|
||||
// 描述:
|
||||
//=======================================================
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public sealed class AnchoredPosition : AbstractInformation<AnchoredPosition.Information>
|
||||
{
|
||||
public override void Save(int index)
|
||||
{
|
||||
_list[index].anchoredPosition =GetComponent<RectTransform>().anchoredPosition.GetVector2Data() ;
|
||||
}
|
||||
|
||||
public override void Switch(int index)
|
||||
{
|
||||
GetComponent<RectTransform>().anchoredPosition = _list[index].anchoredPosition.SetVector2Data();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public sealed class Information : InformationBase
|
||||
{
|
||||
public Vector2Data anchoredPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/AnchoredPosition.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/AnchoredPosition.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5c3a514df208eb4cb4a15721b54f849
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/02.InformationSave/RunTime/Base.meta
Normal file
8
Assets/02.InformationSave/RunTime/Base.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8020e670de32754cb7e83d988b27bdd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public abstract class CustomEditorBase : MonoBehaviour
|
||||
{
|
||||
public abstract void Draw();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00771a0cc2a1d7a42bb8d06ae6dce935
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/02.InformationSave/RunTime/CameraInfo.cs
Normal file
39
Assets/02.InformationSave/RunTime/CameraInfo.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public class CameraInfo : AbstractInformation<CameraInfo.Information>
|
||||
{
|
||||
public override void Save(int index)
|
||||
{
|
||||
var c = GetComponent<Camera>();
|
||||
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<Camera>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/CameraInfo.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/CameraInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3cf38f4aa9f11b54797838ea149b559d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
3
Assets/02.InformationSave/RunTime/Data.meta
Normal file
3
Assets/02.InformationSave/RunTime/Data.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6543baeed3e940268fc41b7eb6fa31a7
|
||||
timeCreated: 1735626715
|
||||
@@ -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");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8775212800004330b3958e498e4ac71f
|
||||
timeCreated: 1735626740
|
||||
16
Assets/02.InformationSave/RunTime/Data/ScriptObjectSave.cs
Normal file
16
Assets/02.InformationSave/RunTime/Data/ScriptObjectSave.cs
Normal file
@@ -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<string, List<InformationBase>> dic = new Dictionary<string, List<InformationBase>>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a08c59ee0e6844441825e5b5427d1e4c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e2aa5a2cf392c145a1055e82ed08b6f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/02.InformationSave/RunTime/EulerAngles.cs
Normal file
23
Assets/02.InformationSave/RunTime/EulerAngles.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public sealed class EulerAngles : AbstractInformation<EulerAngles.Information>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/EulerAngles.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/EulerAngles.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf6220df9bf1ce147bfe973d851f167f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/02.InformationSave/RunTime/Extension.meta
Normal file
8
Assets/02.InformationSave/RunTime/Extension.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc7186a56102e2f4d803fb53e2dcad09
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<AnchoredPosition>()._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<AnchoredPosition>().Set(desc);
|
||||
}
|
||||
|
||||
public static AnchoredPosition.Information GetAnchoredPositionInformation(this Transform tf, string desc)
|
||||
{
|
||||
return tf.GetComponent<AnchoredPosition>()._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<AnchoredPosition>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ccf4bfdd8fa15e4bb9f960a8fd8043e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<CameraInfo>()._list.Find(n => n.desc == desc);
|
||||
}
|
||||
|
||||
public static void SetCameraInfo(this Transform tf, string desc)
|
||||
{
|
||||
tf.GetComponent<CameraInfo>().Set(desc);
|
||||
}
|
||||
|
||||
public static CameraInfo.Information GetCameraInformation(this Camera camera, string desc)
|
||||
{
|
||||
return camera.GetComponent<CameraInfo>()._list.Find(n => n.desc == desc);
|
||||
}
|
||||
|
||||
public static void SetCameraInfo(this Camera camera, string desc)
|
||||
{
|
||||
camera.GetComponent<CameraInfo>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 181681708c62fd746bad97c7c2466778
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<EulerAngles>()._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<EulerAngles>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44d0cc77fd362de4a9a3e49083ab4083
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<JBoxCollider>()._list.Find(n => n.desc == desc);
|
||||
}
|
||||
|
||||
public static void SetBoxCollider(this Transform tf, string desc)
|
||||
{
|
||||
tf.GetComponent<JBoxCollider>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06c219a2579145e41bb8abe74f529ca1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<LocalCameraInfo>()._list.Find(n => n.desc == desc);
|
||||
}
|
||||
|
||||
public static void SetLocalCameraInfo(this Transform tf, string desc)
|
||||
{
|
||||
tf.GetComponent<LocalCameraInfo>().Set(desc);
|
||||
}
|
||||
|
||||
public static LocalCameraInfo.Information GetLocalCameraInformation(this Camera camera, string desc)
|
||||
{
|
||||
return camera.GetComponent<LocalCameraInfo>()._list.Find(n => n.desc == desc);
|
||||
}
|
||||
|
||||
public static void SetLocalCameraInfo(this Camera camera, string desc)
|
||||
{
|
||||
camera.GetComponent<LocalCameraInfo>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1834ac1eb7bea34eaf1233d3fbe8b98
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<LocalEulerAngles>()._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<LocalEulerAngles>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 557f7719d29961f489da4c917f107ed6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<LocalPositionEulerAngles>()._list.Find(n => n.desc == desc);
|
||||
}
|
||||
|
||||
public static void SetLocalPositionEulerAngles(this Transform tf, string desc)
|
||||
{
|
||||
tf.GetComponent<LocalPositionEulerAngles>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f5fd207a730ab2459db6ab5cb61ac92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<LocalPosition>()._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<LocalPosition>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac0cb760733c70641b6b5b696c137dc9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<LocalTransformInfo>()._list.Find(n => n.desc == desc);
|
||||
}
|
||||
|
||||
public static void SetLocalTransformInfo(this Transform tf, string desc)
|
||||
{
|
||||
tf.GetComponent<LocalTransformInfo>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26f9c07fe30c400479eea478f2e6557f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<PositionEulerAngles>()._list.Find(n => n.desc == desc);
|
||||
}
|
||||
|
||||
public static void SetPositionEulerAngles(this Transform tf, string desc)
|
||||
{
|
||||
tf.GetComponent<PositionEulerAngles>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 158344c49f575164a825cf6b74670213
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<Position>()._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<Position>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c5840afa5ec12245982ccbc14e3da68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<RectTransformInfo>()._list.Find(n => n.desc == desc);
|
||||
}
|
||||
|
||||
public static void SetRectTransformInfo(this RectTransform rectTransform, string desc)
|
||||
{
|
||||
rectTransform.GetComponent<RectTransformInfo>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 513bbc7c53696644b84719b8dfe9d099
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<Scale>()._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<Scale>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebbe17c6f3f553745b5172d3f99fa4f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<TrailRendererInfo>()._list.Find(n => n.desc == desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2409502855668eb4fa19a26c4675df0a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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<TransformInfo>()._list.Find(n => n.desc == desc);
|
||||
}
|
||||
|
||||
public static void SetTransformInfo(this Transform tf, string desc)
|
||||
{
|
||||
tf.GetComponent<TransformInfo>().Set(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 276444401c6e3554497746391a9ce0e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7ee1cfff85b47cb864e576a0253a648
|
||||
timeCreated: 1735197883
|
||||
28
Assets/02.InformationSave/RunTime/JBoxCollider.cs
Normal file
28
Assets/02.InformationSave/RunTime/JBoxCollider.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public class JBoxCollider : AbstractInformation<JBoxCollider.Information>
|
||||
{
|
||||
public override void Save(int index)
|
||||
{
|
||||
BoxCollider boxCollider = transform.GetComponent<BoxCollider>();
|
||||
_list[index].center =boxCollider.center.GetVector3Data();
|
||||
_list[index].size = boxCollider.size.GetVector3Data();
|
||||
}
|
||||
|
||||
public override void Switch(int index)
|
||||
{
|
||||
BoxCollider boxCollider = transform.GetComponent<BoxCollider>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/JBoxCollider.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/JBoxCollider.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9767f825c5c2f74e866f2ec5a79ec23
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/02.InformationSave/RunTime/LocalCameraInfo.cs
Normal file
39
Assets/02.InformationSave/RunTime/LocalCameraInfo.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public class LocalCameraInfo : AbstractInformation<LocalCameraInfo.Information>
|
||||
{
|
||||
public override void Save(int index)
|
||||
{
|
||||
var c = GetComponent<Camera>();
|
||||
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<Camera>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/LocalCameraInfo.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/LocalCameraInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38b8221364b888944b7aee29f7c57061
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/02.InformationSave/RunTime/LocalEulerAngles.cs
Normal file
23
Assets/02.InformationSave/RunTime/LocalEulerAngles.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public sealed class LocalEulerAngles : AbstractInformation<LocalEulerAngles.Information>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/LocalEulerAngles.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/LocalEulerAngles.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 280718ca1ccb11848abb4eaa2820e354
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/02.InformationSave/RunTime/LocalPosition.cs
Normal file
23
Assets/02.InformationSave/RunTime/LocalPosition.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public sealed class LocalPosition : AbstractInformation<LocalPosition.Information>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/LocalPosition.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/LocalPosition.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93ebac8518e1ce64fa0c16bebea343e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public sealed class LocalPositionEulerAngles : AbstractInformation<LocalPositionEulerAngles.Information>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e437187af71967c4ba3a675d6cd528ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/02.InformationSave/RunTime/LocalTransformInfo.cs
Normal file
31
Assets/02.InformationSave/RunTime/LocalTransformInfo.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public class LocalTransformInfo : AbstractInformation<LocalTransformInfo.Information>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/LocalTransformInfo.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/LocalTransformInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 550b2f30af9635045803b99a475a03ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/02.InformationSave/RunTime/Position.cs
Normal file
23
Assets/02.InformationSave/RunTime/Position.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public sealed class Position : AbstractInformation<Position.Information>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/Position.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/Position.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9609cbb4c8813d74689777d78711e4d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
Assets/02.InformationSave/RunTime/PositionEulerAngles.cs
Normal file
28
Assets/02.InformationSave/RunTime/PositionEulerAngles.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public sealed class PositionEulerAngles : AbstractInformation<PositionEulerAngles.Information>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee618e2966ba0e94d83de5732a8e0b7f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
47
Assets/02.InformationSave/RunTime/RectTransformInfo.cs
Normal file
47
Assets/02.InformationSave/RunTime/RectTransformInfo.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public class RectTransformInfo : AbstractInformation<RectTransformInfo.Information>
|
||||
{
|
||||
public override void Save(int index)
|
||||
{
|
||||
var rectTransform = GetComponent<RectTransform>();
|
||||
_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>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/RectTransformInfo.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/RectTransformInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c996c2dea2256ab4e8f690091315ef57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/02.InformationSave/RunTime/Scale.cs
Normal file
23
Assets/02.InformationSave/RunTime/Scale.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public sealed class Scale : AbstractInformation<Scale.Information>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/Scale.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/Scale.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdf673576bf52084e8f9762011826aaa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/02.InformationSave/RunTime/TrailRendererInfo.cs
Normal file
25
Assets/02.InformationSave/RunTime/TrailRendererInfo.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public class TrailRendererInfo : AbstractInformation<TrailRendererInfo.Information>
|
||||
{
|
||||
public override void Save(int index)
|
||||
{
|
||||
TrailRenderer tr = transform.GetComponent<TrailRenderer>();
|
||||
_list[index].time = tr.time;
|
||||
}
|
||||
|
||||
public override void Switch(int index)
|
||||
{
|
||||
TrailRenderer tr = transform.GetComponent<TrailRenderer>();
|
||||
tr.time = _list[index].time;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public sealed class Information : InformationBase
|
||||
{
|
||||
public float time;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/TrailRendererInfo.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/TrailRendererInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fbebc203db208a42bc3c5c279992067
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/02.InformationSave/RunTime/TransformInfo.cs
Normal file
31
Assets/02.InformationSave/RunTime/TransformInfo.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public class TransformInfo : AbstractInformation<TransformInfo.Information>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/02.InformationSave/RunTime/TransformInfo.cs.meta
Normal file
11
Assets/02.InformationSave/RunTime/TransformInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a0f5c0e9005eca40a2e8ec448b3d8de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +1,10 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public static class AudioCoreManager
|
||||
namespace AudioCore
|
||||
{
|
||||
public static class AudioCoreManager
|
||||
{
|
||||
private static AudioSourcePool audioSourcePool;
|
||||
private static VoicePlayer Voice;
|
||||
private static SFXPlayer SFX;
|
||||
@@ -87,4 +89,5 @@ public static class AudioCoreManager
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,10 @@ using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class AudioSourcePool
|
||||
namespace AudioCore
|
||||
{
|
||||
public class AudioSourcePool
|
||||
{
|
||||
private Dictionary<string, Queue<GameObject>> poolDict = new Dictionary<string, Queue<GameObject>>();
|
||||
private GameObject poolObject;
|
||||
|
||||
@@ -50,7 +52,7 @@ public class AudioSourcePool
|
||||
GameObject newObject = new GameObject($"AudioSource_{type}");
|
||||
newObject.transform.SetParent(poolObject.transform); // 将新对象作为当前对象的子对象
|
||||
newObject.AddComponent<AudioSource>().playOnAwake = false; // 添加 AudioSource 组件并禁用自动播放
|
||||
if(type == "Music")
|
||||
if (type == "Music")
|
||||
{
|
||||
newObject.GetComponent<AudioSource>().loop = true;
|
||||
}
|
||||
@@ -64,7 +66,7 @@ public class AudioSourcePool
|
||||
/// <returns></returns>
|
||||
public AudioSource GetAudioSource(string type)
|
||||
{
|
||||
if(poolObject == null)
|
||||
if (poolObject == null)
|
||||
{
|
||||
PoolAwake();
|
||||
}
|
||||
@@ -128,7 +130,7 @@ public class AudioSourcePool
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
GameObject obj = queue.Dequeue();
|
||||
if(obj != null)
|
||||
if (obj != null)
|
||||
{
|
||||
UnityEngine.Object.Destroy(obj);
|
||||
}
|
||||
@@ -136,4 +138,5 @@ public class AudioSourcePool
|
||||
}
|
||||
poolDict.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Internal;
|
||||
public static class CoroutineHelper
|
||||
|
||||
namespace AudioCore
|
||||
{
|
||||
public static class CoroutineHelper
|
||||
{
|
||||
private static CoroutineRunner coroutineRunner;
|
||||
|
||||
public static void SetRunner()
|
||||
@@ -21,4 +24,5 @@ public static class CoroutineHelper
|
||||
}
|
||||
|
||||
private class CoroutineRunner : MonoBehaviour { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class GenericPool<T> where T : new()
|
||||
{
|
||||
private Queue<T> _pool = new Queue<T>();
|
||||
private int _maxSize;
|
||||
|
||||
public GenericPool(int initialSize, int maxSize)
|
||||
{
|
||||
_maxSize = maxSize;
|
||||
for (int i = 0; i < initialSize; i++)
|
||||
{
|
||||
_pool.Enqueue(new T());
|
||||
}
|
||||
}
|
||||
|
||||
// 从对象池中获取一个对象
|
||||
public T Get()
|
||||
{
|
||||
if (_pool.Count > 0)
|
||||
{
|
||||
return _pool.Dequeue();
|
||||
}
|
||||
|
||||
// 如果池为空且未达到最大大小,则创建新对象
|
||||
if (_pool.Count < _maxSize)
|
||||
{
|
||||
return new T();
|
||||
}
|
||||
|
||||
// 如果池已满,返回默认值(或抛出异常)
|
||||
return default(T);
|
||||
}
|
||||
|
||||
// 将对象回收到对象池中
|
||||
public void Return(T item)
|
||||
{
|
||||
if (item == null) return;
|
||||
|
||||
if (_pool.Count < _maxSize)
|
||||
{
|
||||
_pool.Enqueue(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,13 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Audio数据
|
||||
/// </summary>
|
||||
public struct AudioData
|
||||
namespace AudioCore
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio数据
|
||||
/// </summary>
|
||||
public struct AudioData
|
||||
{
|
||||
/// <summary>
|
||||
/// 延迟播放时间
|
||||
/// </summary>
|
||||
@@ -51,17 +53,17 @@ public struct AudioData
|
||||
/// 3D声音载体
|
||||
/// </summary>
|
||||
public GameObject soundObject;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IAudio
|
||||
{
|
||||
public interface IAudio
|
||||
{
|
||||
void Play(AudioData audioData);
|
||||
|
||||
void Stop(AudioData audioData);
|
||||
|
||||
}
|
||||
public abstract class AbstractAudio : IAudio
|
||||
{
|
||||
}
|
||||
public abstract class AbstractAudio : IAudio
|
||||
{
|
||||
public abstract void Play(AudioData audioData);
|
||||
|
||||
public abstract void Stop(AudioData audioData);
|
||||
@@ -73,10 +75,11 @@ public abstract class AbstractAudio : IAudio
|
||||
/// <returns></returns>
|
||||
public virtual AudioData AudioDataInitialize(AudioData audioData)
|
||||
{
|
||||
if(audioData.volume == 0)
|
||||
if (audioData.volume == 0)
|
||||
{
|
||||
audioData.volume = 1f;
|
||||
}
|
||||
return audioData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class MusicPlayer : AbstractAudio
|
||||
namespace AudioCore
|
||||
{
|
||||
public class MusicPlayer : AbstractAudio
|
||||
{
|
||||
private AudioSourcePool audioSourcePool;
|
||||
private AudioSource audioSource1;
|
||||
private AudioSource audioSource2;
|
||||
@@ -69,7 +71,7 @@ public class MusicPlayer : AbstractAudio
|
||||
{
|
||||
yield return FadeInMusic(source1, fadeDuration);
|
||||
|
||||
if(source2 != null)
|
||||
if (source2 != null)
|
||||
{
|
||||
yield return FadeOutMusic(source2, fadeDuration);
|
||||
}
|
||||
@@ -95,11 +97,11 @@ public class MusicPlayer : AbstractAudio
|
||||
source.Stop();
|
||||
audioSourcePool.ReturnAudioSource("Music", source.gameObject);
|
||||
|
||||
if(currentAudioSource == audioSource1)
|
||||
if (currentAudioSource == audioSource1)
|
||||
{
|
||||
audioSource2 = null;
|
||||
}
|
||||
else if(currentAudioSource == audioSource2)
|
||||
else if (currentAudioSource == audioSource2)
|
||||
{
|
||||
audioSource1 = null;
|
||||
}
|
||||
@@ -122,4 +124,5 @@ public class MusicPlayer : AbstractAudio
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,10 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SFXPlayer : AbstractAudio
|
||||
namespace AudioCore
|
||||
{
|
||||
public class SFXPlayer : AbstractAudio
|
||||
{
|
||||
private AudioSourcePool audioSourcePool;
|
||||
private List<AudioSource> activeSources = new List<AudioSource>(); // 正在播放的 AudioSource 列表
|
||||
|
||||
@@ -65,4 +67,5 @@ public class SFXPlayer : AbstractAudio
|
||||
audioSourcePool.ReturnAudioSource("SFX", source.gameObject);
|
||||
activeSources.Remove(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using AudioCore;
|
||||
|
||||
public class Test : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class VoicePlayer : AbstractAudio
|
||||
namespace AudioCore
|
||||
{
|
||||
public class VoicePlayer : AbstractAudio
|
||||
{
|
||||
private AudioSourcePool audioSourcePool;
|
||||
private AudioSource currentSource;
|
||||
private Coroutine myCoroutine;
|
||||
@@ -24,7 +26,7 @@ public class VoicePlayer : AbstractAudio
|
||||
|
||||
audioData = AudioDataInitialize(audioData);
|
||||
|
||||
if (myCoroutine!= null)
|
||||
if (myCoroutine != null)
|
||||
{
|
||||
CoroutineHelper.StopCoroutine(myCoroutine);
|
||||
myCoroutine = null;
|
||||
@@ -63,11 +65,12 @@ public class VoicePlayer : AbstractAudio
|
||||
/// <returns></returns>
|
||||
private IEnumerator PlayVoiceCoroutine(AudioSource source, float delayOnComplete, System.Action onComplete)
|
||||
{
|
||||
yield return new WaitForSeconds(source.clip.length+delayOnComplete);
|
||||
yield return new WaitForSeconds(source.clip.length + delayOnComplete);
|
||||
|
||||
onComplete?.Invoke();
|
||||
audioSourcePool.ReturnAudioSource("Voice", source.gameObject);
|
||||
currentSource = null;
|
||||
myCoroutine = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user