架构大更

This commit is contained in:
SoulliesOfficial
2026-03-20 11:56:50 -04:00
parent e60ef64d01
commit d09b58fd80
3663 changed files with 15232012 additions and 105579 deletions

View File

@@ -3,6 +3,7 @@ using System;
using System.IO;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Callbacks;
using UnityEditor.SceneManagement;
using UnityEngine;
@@ -17,27 +18,27 @@ namespace Kamgam.UGUIParticles
public const string AssetLink = "https://assetstore.unity.com/packages/slug/274456";
public static string _assetRootPathDefault = "Assets/Kamgam/UGUIParticles/";
public static string ExamplePath = AssetRootPath + "Examples/UGUIParticlesDemo.unity";
public static string AssetRootPath
{
get
{
#if UNITY_EDITOR
if (System.IO.File.Exists(_assetRootPathDefault))
{
return _assetRootPathDefault;
}
if (File.Exists(_assetRootPathDefault)) return _assetRootPathDefault;
// The the tool was moved then search for the installer script and derive the root
// path from there. Used Assets/ as ultimate fallback.
string finalPath = "Assets/";
string assetRootPathRelative = _assetRootPathDefault.Replace("Assets/", "");
var finalPath = "Assets/";
var assetRootPathRelative = _assetRootPathDefault.Replace("Assets/", "");
var installerGUIDS = AssetDatabase.FindAssets("t:Script Installer");
foreach (var guid in installerGUIDS)
{
var path = AssetDatabase.GUIDToAssetPath(guid);
if (path.Contains(assetRootPathRelative))
{
int index = path.IndexOf(assetRootPathRelative);
var index = path.IndexOf(assetRootPathRelative);
return path.Substring(0, index) + assetRootPathRelative;
}
}
@@ -49,32 +50,6 @@ namespace Kamgam.UGUIParticles
}
}
public static string ExamplePath = AssetRootPath + "Examples/UGUIParticlesDemo.unity";
public static Version GetVersion() => new Version(Version);
[UnityEditor.Callbacks.DidReloadScripts(998001)]
public static void InstallIfNeeded()
{
bool versionChanged = VersionHelper.UpgradeVersion(GetVersion, out Version oldVersion, out Version newVersion);
if (versionChanged)
{
if (versionChanged)
{
Debug.Log(AssetName + " version changed from " + oldVersion + " to " + newVersion);
if (AddDefineSymbol())
{
CrossCompileCallbacks.RegisterCallback(showWelcomeMessage);
}
else
{
showWelcomeMessage();
}
}
}
}
public int callbackOrder => 0;
public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget newTarget)
@@ -83,6 +58,27 @@ namespace Kamgam.UGUIParticles
AddDefineSymbol();
}
public static Version GetVersion()
{
return new Version(Version);
}
[DidReloadScripts(998001)]
public static void InstallIfNeeded()
{
var versionChanged = VersionHelper.UpgradeVersion(GetVersion, out var oldVersion, out var newVersion);
if (versionChanged)
if (versionChanged)
{
Debug.Log(AssetName + " version changed from " + oldVersion + " to " + newVersion);
if (AddDefineSymbol())
CrossCompileCallbacks.RegisterCallback(showWelcomeMessage);
else
showWelcomeMessage();
}
}
[MenuItem("Tools/" + AssetName + "/Debug/Add Defines", priority = 501)]
private static void AddDefineSymbolMenu()
{
@@ -91,9 +87,9 @@ namespace Kamgam.UGUIParticles
private static bool AddDefineSymbol()
{
bool didChange = false;
var didChange = false;
foreach (BuildTargetGroup targetGroup in System.Enum.GetValues(typeof(BuildTargetGroup)))
foreach (BuildTargetGroup targetGroup in Enum.GetValues(typeof(BuildTargetGroup)))
{
#pragma warning disable CS0618 // Type or member is obsolete
if (targetGroup == BuildTargetGroup.Unknown || targetGroup == BuildTargetGroup.GameCoreScarlett)
@@ -103,7 +99,8 @@ namespace Kamgam.UGUIParticles
try
{
#if UNITY_2023_1_OR_NEWER
string currentDefineSymbols = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(targetGroup));
var currentDefineSymbols =
PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(targetGroup));
#else
string currentDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
#endif
@@ -112,7 +109,8 @@ namespace Kamgam.UGUIParticles
continue;
#if UNITY_2023_1_OR_NEWER
PlayerSettings.SetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(targetGroup), currentDefineSymbols + ";" + Define);
PlayerSettings.SetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(targetGroup),
currentDefineSymbols + ";" + Define);
#else
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, currentDefineSymbols + ";" + Define);
#endif
@@ -132,7 +130,7 @@ namespace Kamgam.UGUIParticles
[MenuItem("Tools/" + AssetName + "/Debug/Remove Defines", priority = 502)]
private static void RemoveDefineSymbol()
{
foreach (BuildTargetGroup targetGroup in System.Enum.GetValues(typeof(BuildTargetGroup)))
foreach (BuildTargetGroup targetGroup in Enum.GetValues(typeof(BuildTargetGroup)))
{
#pragma warning disable CS0618 // Type or member is obsolete
if (targetGroup == BuildTargetGroup.Unknown || targetGroup == BuildTargetGroup.GameCoreScarlett)
@@ -142,7 +140,8 @@ namespace Kamgam.UGUIParticles
try
{
#if UNITY_2023_1_OR_NEWER
string currentDefineSymbols = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(targetGroup));
var currentDefineSymbols =
PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(targetGroup));
#else
string currentDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
#endif
@@ -151,7 +150,8 @@ namespace Kamgam.UGUIParticles
{
currentDefineSymbols = currentDefineSymbols.Replace(";" + Define, "");
#if UNITY_2023_1_OR_NEWER
PlayerSettings.SetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(targetGroup), currentDefineSymbols);
PlayerSettings.SetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(targetGroup),
currentDefineSymbols);
#else
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, currentDefineSymbols);
#endif
@@ -162,20 +162,19 @@ namespace Kamgam.UGUIParticles
{
// There are many obsolete defines in the enum, skip them silently.
}
}
}
static void showWelcomeMessage()
private static void showWelcomeMessage()
{
bool openExample = EditorUtility.DisplayDialog(
AssetName,
"Thank you for choosing " + AssetName + ".\n\n" +
"Please start by reading the manual.\n\n" +
"If you can find the time I would appreciate your feedback in the form of a review.\n\n" +
"I have prepared some examples for you.",
"Open Example", "Open manual (web)"
);
var openExample = EditorUtility.DisplayDialog(
AssetName,
"Thank you for choosing " + AssetName + ".\n\n" +
"Please start by reading the manual.\n\n" +
"If you can find the time I would appreciate your feedback in the form of a review.\n\n" +
"I have prepared some examples for you.",
"Open Example", "Open manual (web)"
);
if (openExample)
OpenExample();
@@ -193,7 +192,7 @@ namespace Kamgam.UGUIParticles
[MenuItem("Tools/" + AssetName + "/Open Example Scene", priority = 103)]
public static void OpenExample()
{
EditorApplication.delayCall += () =>
EditorApplication.delayCall += () =>
{
var scene = AssetDatabase.LoadAssetAtPath<SceneAsset>(ExamplePath);
EditorGUIUtility.PingObject(scene);