效果模块,以及代码位置整理
This commit is contained in:
49
Assets/Scripts/Manager/BasePrefabsCollection.cs
Normal file
49
Assets/Scripts/Manager/BasePrefabsCollection.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
[CreateAssetMenu(fileName = "BasePrefabsCollection", menuName = "Ichni/BasePrefabsCollection", order = 0)]
|
||||
public class BasePrefabsCollection : SerializedScriptableObject
|
||||
{
|
||||
[Title("基础预制体")] public GameObject emptyObject;
|
||||
public GameObject elementFolder;
|
||||
public GameObject gameCamera;
|
||||
|
||||
[Title("Track相关")] public GameObject track;
|
||||
public GameObject pathNode;
|
||||
public Material defaultTrackMaterial;
|
||||
|
||||
[Title("Trail相关")] public GameObject trail;
|
||||
public Material defaultTrailMaterial;
|
||||
|
||||
[Title("Note 相关")] public GameObject tapNote;
|
||||
public GameObject stayNote;
|
||||
public GameObject holdNote;
|
||||
public GameObject flickNote;
|
||||
public AudioClip tapNoteSound;
|
||||
public AudioClip stayNoteSound;
|
||||
public AudioClip holdNoteStartSound;
|
||||
public AudioClip holdNoteLoopSound;
|
||||
public AudioClip holdNoteEndSound;
|
||||
public AudioClip flickNoteSound;
|
||||
|
||||
[Title("Effect相关")] public GameObject bloomShake;
|
||||
|
||||
[Title("DynamicUI相关-Simple")] public GameObject dynamicUIContainer;
|
||||
public GameObject inputField;
|
||||
public GameObject Vector3inputField;
|
||||
public GameObject text;
|
||||
public GameObject button;
|
||||
public GameObject toggle;
|
||||
public GameObject dropdown;
|
||||
public GameObject baseColorPicker;
|
||||
public GameObject emissionColorPicker;
|
||||
[Title("DynamicUI相关-Composite")]
|
||||
public GameObject compositeParameterWindow;
|
||||
public GameObject stringUnit;
|
||||
public GameObject animatedFloatUnit;
|
||||
public GameObject animatedIntUnit;
|
||||
public GameObject animatedBoolUnit;
|
||||
}
|
||||
36
Assets/Scripts/Manager/BasePrefabsCollection.cs.meta
Normal file
36
Assets/Scripts/Manager/BasePrefabsCollection.cs.meta
Normal file
@@ -0,0 +1,36 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bfe18cabd8814ad0b27f5969180c1d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- emptyObject: {instanceID: 0}
|
||||
- elementFolder: {instanceID: 0}
|
||||
- gameCamera: {instanceID: 0}
|
||||
- track: {instanceID: 0}
|
||||
- pathNode: {instanceID: 0}
|
||||
- defaultTrackMaterial: {instanceID: 0}
|
||||
- trail: {instanceID: 0}
|
||||
- defaultTrailMaterial: {instanceID: 0}
|
||||
- tapNote: {instanceID: 0}
|
||||
- stayNote: {instanceID: 0}
|
||||
- holdNote: {instanceID: 0}
|
||||
- flickNote: {instanceID: 0}
|
||||
- tapNoteSound: {instanceID: 0}
|
||||
- stayNoteSound: {instanceID: 0}
|
||||
- holdNoteStartSound: {instanceID: 0}
|
||||
- holdNoteLoopSound: {instanceID: 0}
|
||||
- holdNoteEndSound: {instanceID: 0}
|
||||
- flickNoteSound: {instanceID: 0}
|
||||
- bloomShake: {instanceID: 0}
|
||||
- dynamicUIContainer: {instanceID: 0}
|
||||
- inputField: {fileID: 8936320662031972394, guid: 79e257fb81d2b0a4dade94526886cf0e,
|
||||
type: 3}
|
||||
- Vec3inputField: {fileID: 8936320662031972394, guid: 86a1f66d7e43c7e4a8ab14c84b86af8c,
|
||||
type: 3}
|
||||
- text: {fileID: 7331471404896706636, guid: 0420d23f7ef40d74183ba313464088cc, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
105
Assets/Scripts/Manager/EditorManager.cs
Normal file
105
Assets/Scripts/Manager/EditorManager.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Ichni.RhythmGame.ThemeBundles.Basic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
public class EditorManager : SerializedMonoBehaviour
|
||||
{
|
||||
public static EditorManager instance;
|
||||
|
||||
public ProjectManager projectManager;
|
||||
public EditorUIManager uiManager;
|
||||
public EditorSettings editorSettings;
|
||||
|
||||
public ProjectInformation projectInformation;
|
||||
public SongInformation songInformation;
|
||||
public BeatmapContainer beatmapContainer;
|
||||
public CommandScripts commandScripts;
|
||||
|
||||
public NoteBase.NoteJudgeType currentJudgeType;
|
||||
public BasePrefabsCollection basePrefabs;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
projectManager = new ProjectManager();
|
||||
if (!ES3.FileExists(Application.streamingAssetsPath + "/EditorSettings.es3"))
|
||||
{
|
||||
editorSettings = new EditorSettings(300, 100, 100);
|
||||
EditorSettings.SaveSettings(editorSettings);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorSettings.LoadSettings(ref editorSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//CreateNew();
|
||||
projectManager.loadManager.Load("TestProject");
|
||||
uiManager.timeline.musicPlayer.audioSource.clip = songInformation.song;
|
||||
|
||||
beatmapContainer.gameElementList.ForEach(gameElement =>
|
||||
{
|
||||
if (gameElement is IHaveTransformSubmodule transformedElement)
|
||||
{
|
||||
transformedElement.SetTransformObserver();
|
||||
}
|
||||
|
||||
gameElement.AfterInitialize();
|
||||
gameElement.Refresh();
|
||||
});
|
||||
|
||||
// projectManager.saveManager.Save();
|
||||
// projectManager.exportManager.Export();
|
||||
}
|
||||
|
||||
private void CreateNew()
|
||||
{
|
||||
projectManager.GenerateProject("TestProject");
|
||||
|
||||
var f0 = ElementFolder.GenerateElement("Folder", Guid.NewGuid(), new List<string>(), true, null);
|
||||
var dis0 = Displacement.GenerateElement("Displacement-0",Guid.NewGuid(), new List<string>(),true, f0,
|
||||
new FlexibleFloat(),
|
||||
new FlexibleFloat(new List<AnimatedFloat>(){new (0,2,0,10, AnimationCurveType.Linear)}),
|
||||
new FlexibleFloat());
|
||||
var dis1 = Displacement.GenerateElement("Displacement-1", Guid.NewGuid(), new List<string>(), true, f0,
|
||||
new FlexibleFloat(new List<AnimatedFloat>()
|
||||
{
|
||||
new(0, 0.5f, 0, -4, AnimationCurveType.OutQuad),
|
||||
new(0.5f, 1, -4, 0, AnimationCurveType.InQuad),
|
||||
new(1, 1.5f, 0, 4, AnimationCurveType.OutQuad),
|
||||
new(1.5f, 2, 4, 0, AnimationCurveType.InQuad),
|
||||
}),
|
||||
new FlexibleFloat(new List<AnimatedFloat>(){new (0,2,0,-10, AnimationCurveType.Linear)}),
|
||||
new FlexibleFloat());
|
||||
|
||||
var t0 = Track.GenerateElement("Track", Guid.NewGuid(), new List<string>(), true, f0);
|
||||
t0.trackPathSubmodule = new TrackPathSubmodule(t0, Track.TrackSpaceType.Linear, Track.TrackSamplingType.TimeDistributed, false);
|
||||
t0.submoduleList.Add(t0.trackPathSubmodule);
|
||||
t0.trackTimeSubmodule = new TrackTimeSubmoduleMovable(t0, 0, 2, 1, AnimationCurveType.OutQuad);
|
||||
t0.submoduleList.Add(t0.trackTimeSubmodule);
|
||||
var pp0 = TrackPercentPoint.GenerateElement("TrackPercentPoint-0", Guid.NewGuid(), new List<string>(), true, t0,
|
||||
new FlexibleFloat(new List<AnimatedFloat>() { new(0, 2, 0, 1, AnimationCurveType.OutQuad) }));
|
||||
var tr0 = Trail.GenerateElement("Trail-0", Guid.NewGuid(), new List<string>(), true, pp0, 5);
|
||||
// t0.trackRendererSubmodule = new TrackRendererSubmoduleAutoOrient(t0);
|
||||
var p0 = PathNode.GenerateElement("PathNode-0", Guid.NewGuid(), new List<string>(), true, t0);
|
||||
p0.transformSubmodule = new TransformSubmodule(p0, new Vector3(-5, 5, 10), Vector3.zero, Vector3.one);
|
||||
p0.colorSubmodule = new ColorSubmodule(p0, Color.white);
|
||||
var p1 = PathNode.GenerateElement("PathNode-1", Guid.NewGuid(), new List<string>(), true, t0);
|
||||
p1.transformSubmodule = new TransformSubmodule(p1, new Vector3(5, -5, 10), Vector3.zero, Vector3.one);
|
||||
p1.colorSubmodule = new ColorSubmodule(p1, Color.red);
|
||||
var n0 = Tap.GenerateElement("Note-0", Guid.NewGuid(), new List<string>(), true, t0, 1f);
|
||||
var n0v = BasicNoteVisual.GenerateElement("Note-0-V", Guid.NewGuid(), new List<string>(), true, n0,
|
||||
"basic", "BasicNoteTap3D");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Manager/EditorManager.cs.meta
Normal file
11
Assets/Scripts/Manager/EditorManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d40f46869fc84408ab4870b70e789ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/Scripts/Manager/InputListener.cs
Normal file
38
Assets/Scripts/Manager/InputListener.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class InputListener : MonoBehaviour
|
||||
{
|
||||
private void Update()
|
||||
{
|
||||
if (Keyboard.current.leftCtrlKey.isPressed)
|
||||
{
|
||||
if (Keyboard.current.sKey.wasPressedThisFrame)
|
||||
{
|
||||
EditorManager.instance.projectManager.saveManager.Save();
|
||||
}
|
||||
else if (Keyboard.current.eKey.wasPressedThisFrame)
|
||||
{
|
||||
EditorManager.instance.projectManager.exportManager.Export();
|
||||
}
|
||||
else if (Keyboard.current.digit1Key.wasPressedThisFrame)
|
||||
{
|
||||
EditorManager.instance.uiManager.mainPage.resolutionHints.SetPhoneFrame();
|
||||
}
|
||||
else if (Keyboard.current.digit2Key.wasPressedThisFrame)
|
||||
{
|
||||
EditorManager.instance.uiManager.mainPage.resolutionHints.SetIPadFrame();
|
||||
}
|
||||
else if (Keyboard.current.digit3Key.wasPressedThisFrame)
|
||||
{
|
||||
EditorManager.instance.uiManager.mainPage.resolutionHints.SetSafeAreaFrame();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Manager/InputListener.cs.meta
Normal file
11
Assets/Scripts/Manager/InputListener.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bc62b724b099426b9121ce12d1dc1cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/Scripts/Manager/PostProcessingManager.cs
Normal file
18
Assets/Scripts/Manager/PostProcessingManager.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PostProcessingManager : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Manager/PostProcessingManager.cs.meta
Normal file
11
Assets/Scripts/Manager/PostProcessingManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b242683d247c4ee59ef50fd8ef06701
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
173
Assets/Scripts/Manager/ProjectManager.cs
Normal file
173
Assets/Scripts/Manager/ProjectManager.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
public class ProjectManager
|
||||
{
|
||||
public static readonly ES3Settings SaveSettings = new ES3Settings
|
||||
{
|
||||
compressionType = ES3.CompressionType.None,
|
||||
encryptionType = ES3.EncryptionType.None,
|
||||
format = ES3.Format.JSON,
|
||||
};
|
||||
|
||||
public static readonly ES3Settings ExportSettings = new ES3Settings
|
||||
{
|
||||
compressionType = ES3.CompressionType.Gzip,
|
||||
encryptionType = ES3.EncryptionType.AES,
|
||||
encryptionPassword = "Soullies515",
|
||||
format = ES3.Format.JSON,
|
||||
};
|
||||
|
||||
public SaveManager saveManager;
|
||||
public LoadManager loadManager;
|
||||
public ExportManager exportManager;
|
||||
|
||||
public ProjectManager()
|
||||
{
|
||||
saveManager = new SaveManager();
|
||||
loadManager = new LoadManager();
|
||||
exportManager = new ExportManager();
|
||||
}
|
||||
|
||||
public void GenerateProject(string projectName)
|
||||
{
|
||||
EditorManager.instance.projectInformation = new ProjectInformation(projectName, "Soullies",
|
||||
"2.0", "2025-02-08", "2025-02-08", new List<string>());
|
||||
EditorManager.instance.songInformation = new SongInformation("TestSong", 120, 0);
|
||||
EditorManager.instance.beatmapContainer = new BeatmapContainer();
|
||||
EditorManager.instance.commandScripts = new CommandScripts(new List<string>());
|
||||
|
||||
//Create project folder
|
||||
if (!System.IO.Directory.Exists(EditorManager.instance.projectInformation.projectPath))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(EditorManager.instance.projectInformation.projectPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ExportManager
|
||||
{
|
||||
public void Export()
|
||||
{
|
||||
string exportPath = Application.streamingAssetsPath + "/Export/" +
|
||||
EditorManager.instance.projectInformation.projectName;
|
||||
string projectInfoPath = exportPath + "/ProjectInfo.bytes";
|
||||
string songInfoPath = exportPath + "/SongInfo.bytes";
|
||||
string beatmapPath = exportPath + "/BeatMap.bytes";
|
||||
string commandScriptsPath = exportPath + "/CommandScripts.bytes";
|
||||
|
||||
ExportProjectInfo(projectInfoPath);
|
||||
ExportSongInfo(songInfoPath);
|
||||
ExportBeatMap(beatmapPath);
|
||||
ExportCommandScripts(commandScriptsPath);
|
||||
}
|
||||
|
||||
private void ExportProjectInfo(string exportPath)
|
||||
{
|
||||
EditorManager.instance.projectInformation.SaveBM();
|
||||
ES3.Save("ProjectInformation", EditorManager.instance.projectInformation.matchedBM as ProjectInformation_BM,
|
||||
exportPath, ProjectManager.ExportSettings);
|
||||
}
|
||||
|
||||
private void ExportSongInfo(string exportPath)
|
||||
{
|
||||
EditorManager.instance.songInformation.SaveBM();
|
||||
ES3.Save("SongInformation", EditorManager.instance.songInformation.matchedBM as SongInformation_BM,
|
||||
exportPath, ProjectManager.ExportSettings);
|
||||
}
|
||||
|
||||
private void ExportBeatMap(string exportPath)
|
||||
{
|
||||
EditorManager.instance.beatmapContainer.SaveBM();
|
||||
ES3.Save("BeatMap", EditorManager.instance.beatmapContainer.matchedBM as BeatmapContainer_BM,
|
||||
exportPath, ProjectManager.ExportSettings);
|
||||
}
|
||||
|
||||
private void ExportCommandScripts(string exportPath)
|
||||
{
|
||||
EditorManager.instance.commandScripts.SaveBM();
|
||||
ES3.Save("CommandScripts", EditorManager.instance.commandScripts.matchedBM as CommandScripts_BM,
|
||||
exportPath, ProjectManager.ExportSettings);
|
||||
}
|
||||
}
|
||||
|
||||
public class SaveManager
|
||||
{
|
||||
public void Save()
|
||||
{
|
||||
SaveProjectInfo();
|
||||
SaveSongInfo();
|
||||
SaveBeatMap();
|
||||
SaveCommandScripts();
|
||||
}
|
||||
|
||||
private void SaveProjectInfo()
|
||||
{
|
||||
EditorManager.instance.projectInformation.SaveBM();
|
||||
ES3.Save("ProjectInformation", EditorManager.instance.projectInformation.matchedBM as ProjectInformation_BM,
|
||||
EditorManager.instance.projectInformation.peojectInfoPath, ProjectManager.SaveSettings);
|
||||
}
|
||||
|
||||
private void SaveSongInfo()
|
||||
{
|
||||
EditorManager.instance.songInformation.SaveBM();
|
||||
ES3.Save("SongInformation", EditorManager.instance.songInformation.matchedBM as SongInformation_BM,
|
||||
EditorManager.instance.projectInformation.songInfoPath, ProjectManager.SaveSettings);
|
||||
}
|
||||
|
||||
private void SaveBeatMap()
|
||||
{
|
||||
EditorManager.instance.beatmapContainer.SaveBM();
|
||||
ES3.Save("BeatMap", EditorManager.instance.beatmapContainer.matchedBM as BeatmapContainer_BM,
|
||||
EditorManager.instance.projectInformation.beatmapPath, ProjectManager.SaveSettings);
|
||||
}
|
||||
|
||||
private void SaveCommandScripts()
|
||||
{
|
||||
EditorManager.instance.commandScripts.SaveBM();
|
||||
ES3.Save("CommandScripts", EditorManager.instance.commandScripts.matchedBM as CommandScripts_BM,
|
||||
EditorManager.instance.projectInformation.CommandScriptsPath, ProjectManager.SaveSettings);
|
||||
}
|
||||
}
|
||||
|
||||
public class LoadManager
|
||||
{
|
||||
public void Load(string projectName)
|
||||
{
|
||||
LoadProjectInfo(projectName);
|
||||
LoadSongInfo();
|
||||
LoadBeatMap();
|
||||
LoadCommandScripts();
|
||||
}
|
||||
|
||||
private void LoadProjectInfo(string projectName)
|
||||
{
|
||||
string projectInfoPath = Application.streamingAssetsPath + "/Projects/" + projectName + "/ProjectInfo.json";
|
||||
ES3.Load<ProjectInformation_BM>("ProjectInformation", projectInfoPath, ProjectManager.SaveSettings).ExecuteBM();
|
||||
}
|
||||
|
||||
private void LoadSongInfo()
|
||||
{
|
||||
ES3.Load<SongInformation_BM>("SongInformation", EditorManager.instance.projectInformation.songInfoPath,
|
||||
ProjectManager.SaveSettings).ExecuteBM();
|
||||
}
|
||||
|
||||
private void LoadBeatMap()
|
||||
{
|
||||
ES3.Load<BeatmapContainer_BM>("BeatMap", EditorManager.instance.projectInformation.beatmapPath,
|
||||
ProjectManager.SaveSettings).ExecuteBM();
|
||||
}
|
||||
|
||||
private void LoadCommandScripts()
|
||||
{
|
||||
ES3.Load<CommandScripts_BM>("CommandScripts", EditorManager.instance.projectInformation.CommandScriptsPath,
|
||||
ProjectManager.SaveSettings).ExecuteBM();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Manager/ProjectManager.cs.meta
Normal file
11
Assets/Scripts/Manager/ProjectManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eaac9d0bf222646fc89d03493f9fca69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
232
Assets/Scripts/Manager/ThemeBundleManager.cs
Normal file
232
Assets/Scripts/Manager/ThemeBundleManager.cs
Normal file
@@ -0,0 +1,232 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
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;
|
||||
|
||||
loadedThemeBundleList = new List<ThemeBundle>();
|
||||
|
||||
AssetBundle.UnloadAllAssetBundles(true);
|
||||
LoadAllThemeBundlesAbstract();
|
||||
//DontDestroyOnLoad(gameObject);
|
||||
LoadThemeBundle("basic");
|
||||
}
|
||||
|
||||
|
||||
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 fileName;
|
||||
public string displayName;
|
||||
public string description;
|
||||
public List<string> tags;
|
||||
public string iconPath;
|
||||
|
||||
public ThemeBundleAbstract()
|
||||
{
|
||||
}
|
||||
|
||||
public ThemeBundleAbstract(string fileName)
|
||||
{
|
||||
this.fileName = fileName;
|
||||
this.displayName = fileName;
|
||||
this.description = "Default Description";
|
||||
this.tags = new List<string>();
|
||||
this.iconPath = "Icons/Default.png";
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Manager/ThemeBundleManager.cs.meta
Normal file
11
Assets/Scripts/Manager/ThemeBundleManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d27859adda1341aaa0db8a117d5431c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user