基础内容

必要插件安装
缓动曲线和动画基础
ElementFolder,Track与其次级模块,PathNode重构
This commit is contained in:
SoulliesOfficial
2025-01-26 21:10:16 -05:00
parent 40f63dd2bd
commit 8d0abec75f
9320 changed files with 2950357 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
[CreateAssetMenu(fileName = "BasePrefabsCollection", menuName = "Ichni/BasePrefabsCollection", order = 0)]
public class BasePrefabsCollection : SerializedScriptableObject
{
[Title("基础预制体")]
public GameObject emptyObject;
public GameObject elementFolder;
public GameObject track;
public GameObject pathNode;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9bfe18cabd8814ad0b27f5969180c1d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Ichni
{
public class EditorManager : SerializedMonoBehaviour
{
public static EditorManager instance;
public SongModule songModule;
public BasePrefabsCollection basePrefabs;
private void Awake()
{
instance = this;
}
private void Start()
{
var f0 = ElementFolder.GenerateElement("Folder", null);
var t0 = Track.GenerateElement("Track", f0, Vector3.left * 5f);
t0.trackPathSubmodule = new TrackPathSubmodule();
t0.trackTimeSubmodule = new TrackTimeSubmoduleMovable();
t0.trackRendererSubmodule = new TrackRendererSubmoduleAutoOrient();
(t0.trackPathSubmodule).NewInitialize(t0, false, Track.TrackSpaceType.Linear, Track.TrackSamplingType.TimeDistributed);
(t0.trackTimeSubmodule as TrackTimeSubmoduleMovable).NewInitialize(t0, 0, 1, 1, AnimationCurveType.Linear);
(t0.trackRendererSubmodule as TrackRendererSubmoduleAutoOrient).NewInitialize(t0);
var p0 = PathNode.GeneratePathNode("PathNode-0", t0, 0, Vector3.zero, Vector3.forward, 1, Color.white);
var p1 = PathNode.GeneratePathNode("PathNode-1", t0, 1, Vector3.one * 10f, Vector3.left, 0, Color.white);
t0.AfterInitialize();
}
}
public class SongModule
{
public float songTime;
public float songBeat;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d40f46869fc84408ab4870b70e789ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,232 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Networking;
namespace Ichni
{
public class ThemeBundleManager : MonoBehaviour
{
public static ThemeBundleManager instance;
public List<ThemeBundleAbstract> themeBundleAbstractList;
public List<string> selectedThemeBundleList;
public List<ThemeBundle> loadedThemeBundleList;
public int waitingBundleAmount;
private void Awake()
{
instance = this;
}
private void Start()
{
loadedThemeBundleList = new List<ThemeBundle>();
AssetBundle.UnloadAllAssetBundles(true);
LoadAllThemeBundlesAbstract();
//DontDestroyOnLoad(gameObject);
LoadThemeBundle("fundamental");
}
public T GetObject<T>(string themeBundleName, string objectName) where T : class
{
return loadedThemeBundleList.Find(bundle => bundle.themeBundleName == themeBundleName)?.GetObject<T>(objectName);
}
public void LoadThemeBundles(List<string> list)
{
foreach (var bundle in list)
{
LoadThemeBundle(bundle);
}
}
public void LoadAllThemeBundlesAbstract()
{
string uri = Application.streamingAssetsPath + "/ThemeBundles";
if (ES3.DirectoryExists(uri))
{
List<string> allFileList = ES3.GetFiles(uri).ToList();
List<string> absList = new List<string>();
foreach (var abs in allFileList)
{
if (abs.EndsWith(".abs"))
{
absList.Add(abs);
}
}
foreach (var abs in absList)
{
ES3Settings settings = new ES3Settings(uri + "/" + abs, ES3.EncryptionType.None);
themeBundleAbstractList.Add(ES3.Load<ThemeBundleAbstract>("ThemeBundleAbstract", settings));
}
}
}
public void LoadThemeBundle(string themeBundleName)
{
waitingBundleAmount++;
StartCoroutine(LoadThemeBundleCoroutine(themeBundleName));
}
IEnumerator LoadThemeBundleCoroutine(string themeBundleName)
{
string uri = "";
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.WindowsPlayer)
{
uri = Application.streamingAssetsPath + "/ThemeBundles/Windows64/" + themeBundleName;
}else if (Application.platform == RuntimePlatform.OSXEditor ||
Application.platform == RuntimePlatform.OSXPlayer)
{
uri = Application.streamingAssetsPath + "/ThemeBundles/OSX/" + themeBundleName;
}
UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(uri, 0);
yield return request.SendWebRequest();
AssetBundle bundle = AssetBundle.LoadFromFile(uri);
Object[] ob = bundle.LoadAllAssets<Object>();
loadedThemeBundleList.Add(new ThemeBundle(themeBundleName));
for (int i = 0; i < ob.Length; i++)
{
if (ob[i].GetType() == typeof(GameObject))
{
loadedThemeBundleList[^1].assetList_GameObject.Add(ob[i] as GameObject);
}
else if (ob[i].GetType() == typeof(Material))
{
loadedThemeBundleList[^1].assetList_Material.Add(ob[i] as Material);
}
else if (ob[i].GetType() == typeof(Texture2D))
{
loadedThemeBundleList[^1].assetList_Texture.Add(ob[i] as Texture2D);
}
else
{
loadedThemeBundleList[^1].assetList_Other.Add(ob[i]);
}
}
yield return new WaitForEndOfFrame();
waitingBundleAmount--;
}
}
[System.Serializable]
public class ThemeBundleAbstract
{
public string themeBundleName;
public List<string> tags;
public string iconPath;
public ThemeBundleAbstract()
{
}
public ThemeBundleAbstract(string themeBundleName, List<string> tags, string iconPath)
{
this.themeBundleName = themeBundleName;
this.tags = tags;
this.iconPath = iconPath;
}
public Texture2D GetIcon()
{
string uri = Application.streamingAssetsPath + "/" + iconPath;
if (ES3.FileExists(uri))
{
Texture2D sp = ES3.LoadImage(uri);
return sp;
}
return null;
}
}
[System.Serializable]
public class ThemeBundle
{
public string themeBundleName;
public List<GameObject> assetList_GameObject;
public List<Material> assetList_Material;
public List<Texture2D> assetList_Texture;
public List<Object> assetList_Other;
public ThemeBundle(string name)
{
themeBundleName = name;
assetList_GameObject = new List<GameObject>();
assetList_Material = new List<Material>();
assetList_Texture = new List<Texture2D>();
assetList_Other = new List<Object>();
}
public T GetObject<T>(string name)
{
if (name == "None")
{
return default(T);
}
T[] assetList;
if (typeof(T) == typeof(GameObject))
{
assetList = assetList_GameObject.ToArray() as T[];
for (int i = 0; i < assetList_GameObject.Count; i++)
{
if (name == assetList_GameObject[i].name)
{
return assetList[i];
}
}
}
else if (typeof(T) == typeof(Material))
{
assetList = assetList_Material.ToArray() as T[];
for (int i = 0; i < assetList_Material.Count; i++)
{
if (name == assetList_Material[i].name)
{
return assetList[i];
}
}
}
else if (typeof(T) == typeof(Texture2D))
{
assetList = assetList_Texture.ToArray() as T[];
for (int i = 0; i < assetList_Texture.Count; i++)
{
if (name == assetList_Texture[i].name)
{
return assetList[i];
}
}
}
else
{
assetList = assetList_Other.ToArray() as T[];
for (int i = 0; i < assetList_Other.Count; i++)
{
if (name == assetList_Other[i].name)
{
return assetList[i];
}
}
}
return default(T);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d27859adda1341aaa0db8a117d5431c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: