diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ca5bcb9..1501286 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,14 +10,14 @@ stages: # 发布 job_deploy: only: - - 02.InformationSave + - 00.StaryEvo stage: deploy tags: - staryEvo before_script: - echo '开始发布' script: - - cd Assets/02.InformationSave + - cd Assets/00.StaryEvo # 获取当前版本 - CURRENT_VERSION=$(node -p "require('./package.json').version") # - echo " ProjectID ${CI_SERVER_HOST}" diff --git a/Assets/02.InformationSave.meta b/Assets/00.StaryEvo.meta similarity index 77% rename from Assets/02.InformationSave.meta rename to Assets/00.StaryEvo.meta index 632c625..db0d15c 100644 --- a/Assets/02.InformationSave.meta +++ b/Assets/00.StaryEvo.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: dc0c6a9a74c33bb45b7529d86d820e2e +guid: c96ccfb3a14425d4e81a3d31ba25bede folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/00.StaryEvo/Editor.meta b/Assets/00.StaryEvo/Editor.meta new file mode 100644 index 0000000..1e9d269 --- /dev/null +++ b/Assets/00.StaryEvo/Editor.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 426d0ca955a34a89853bcd019777299a +timeCreated: 1625564841 \ No newline at end of file diff --git a/Assets/02.InformationSave/Editor.meta b/Assets/00.StaryEvo/Editor/BuildAsset.meta similarity index 77% rename from Assets/02.InformationSave/Editor.meta rename to Assets/00.StaryEvo/Editor/BuildAsset.meta index 310bf4b..07c920b 100644 --- a/Assets/02.InformationSave/Editor.meta +++ b/Assets/00.StaryEvo/Editor/BuildAsset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a832a8c4833f01744bb484de1af54c37 +guid: 71921b49d6fa2df40bcb9538075ce8fb folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetDataSetting.cs b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetDataSetting.cs new file mode 100644 index 0000000..5177f33 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetDataSetting.cs @@ -0,0 +1,241 @@ +using System; +using System.Collections.Generic; +using Sirenix.OdinInspector; +using UnityEditor; +using UnityEngine; +using YooAsset; +using YooAsset.Editor; + +namespace Stary.Evo.Editor +{ + [CreateAssetMenu(fileName = "BuildAssetDataSetting", menuName = "Evo/BuildAssetDataSetting")] + public class BuildAssetDataSetting : SerializedScriptableObject + { + public void OnEnable() + { + buildTarget = EditorUserBuildSettings.activeBuildTarget.ToString(); + GetPackageVersion(); + oldVersionX = packageVersionX; + oldVersionY = packageVersionY; + oldVersionZ = packageVersionZ; + } + + [HideInInspector] public string packageName; + [HideInInspector]public int packageVersionX = 1; + [HideInInspector]public int packageVersionY; + [HideInInspector]public int packageVersionZ; + private int oldVersionX = 1; + private int oldVersionY; + private int oldVersionZ; + + [Title("目标环境", titleAlignment: TitleAlignments.Centered)] + [HorizontalGroup("BuildSetting"), HideLabel] + [OnValueChanged("SetEnvironmentType")] + public EnvironmentType environmentType; + + [Title("当前打包平台", titleAlignment: TitleAlignments.Centered)] + [ReadOnly] + [HorizontalGroup("BuildSetting"), HideLabel] + public string buildTarget; + + private const string VerSersionMessage = "(小版本由打包叠加,中版本、大版本更新会重置小版本,如误操作,点击重置按钮即可)"; + + [TitleGroup("当前打包版本号", alignment: TitleAlignments.Centered)] + [ReadOnly] + [HorizontalGroup("当前打包版本号/PackageVersion"), HideLabel] + public string packageVersion; + + [HorizontalGroup("当前打包版本号/PackageVersion"), HideLabel, EnumToggleButtons] + [HideIf("environmentType", EnvironmentType.Debug)] + public VersionPosType VersionType; + + + [HorizontalGroup("当前打包版本号/PackageVersion"), HideLabel, Button(Icon = SdfIconType.Plus)] + [HideIf("environmentType", EnvironmentType.Debug)] + public void AddBigVersion() + { + if (VersionType == VersionPosType.X) + { + packageVersionX++; + } + else if (VersionType == VersionPosType.Y) + { + packageVersionY++; + } + + if (packageVersionZ > 0) + packageVersionZ = 0; + GetPackageVersion(); + } + + [HorizontalGroup("当前打包版本号/PackageVersion"), HideLabel, Button(Icon = SdfIconType.Dash)] + [HideIf("environmentType", EnvironmentType.Debug)] + public void SubBigVersion() + { + if (VersionType == VersionPosType.X) + { + packageVersionX--; + } + else if (VersionType == VersionPosType.Y) + { + packageVersionY--; + } + + if (packageVersionZ > 0) + packageVersionZ = 0; + GetPackageVersion(); + } + + [HorizontalGroup("当前打包版本号/PackageVersion"), HideLabel, Button(Icon = SdfIconType.ArrowRepeat)] + [HideIf("environmentType", EnvironmentType.Debug)] + public void RepeatVersion() + { + packageVersionX = oldVersionX; + packageVersionY = oldVersionY; + packageVersionZ = oldVersionZ; + GetPackageVersion(); + } + + [Title("构建列表", titleAlignment: TitleAlignments.Centered)] + [HorizontalGroup("BuildPipeline"), HideLabel] + [OnValueChanged("SetBuildPipelines")] + public EBuildPipeline selectedBuildPipelines; + + [Title("加密列表", titleAlignment: TitleAlignments.Centered)] + [HorizontalGroup("BuildPipeline"), HideLabel] + [ValueDropdown("GetEncryptionServices")] + [OnValueChanged("SetEncryptionServices")] + public Type encryption; + + [HideLabel] public AbstractBuildPipelineViewer viewer; + + [HideLabel] private Dictionary _viewers; + + public void SetEnvironmentType() + { + GetPackageVersion(); + } + + public string GetBuildPackageVersion(bool isUpdate = false) + { + if (environmentType == EnvironmentType.Debug) + { + return "Simulate"; + } + + if (environmentType == EnvironmentType.Release) + { + string version = + $"{packageVersionX}.{packageVersionY}.{packageVersionZ}"; + + if (isUpdate) + packageVersionZ++; + + packageVersion = $"{packageVersionX}.{packageVersionY}.{packageVersionZ}"; + return version; + } + + return null; + } + + public void GetPackageVersion() + { + SetBuildPipelines(); + if (environmentType == EnvironmentType.Debug) + { + viewer.clearBuildCacheToggle = true; + selectedBuildPipelines = EBuildPipeline.EditorSimulateBuildPipeline; + packageVersion = "Simulate"; + + } + else if (environmentType == EnvironmentType.Release) + { + viewer.clearBuildCacheToggle = false; + selectedBuildPipelines = EBuildPipeline.BuiltinBuildPipeline; + + packageVersionX = packageVersionX > 1 ? packageVersionX : 1; + packageVersionY = + packageVersionY > 0 ? packageVersionY : 0; + + packageVersion = + $"{packageVersionX}.{packageVersionY}.{packageVersionZ}"; + } + + viewer.SetBuildCacheToggle(); + + AssetDatabase.SaveAssets(); + //BuildServerPath(); + } + + /// + /// 设置当前构建管线 + /// + /// + private void SetBuildPipelines() + { + BuildPipelineViewer(); + } + + /// + /// 生成打包实例 + /// + public void BuildPipelineViewer() + { + if (_viewers == null) + _viewers = new Dictionary(); + if (_viewers.ContainsKey(selectedBuildPipelines)) + { + viewer = _viewers[selectedBuildPipelines]; + } + else + { + switch (selectedBuildPipelines) + { + case EBuildPipeline.EditorSimulateBuildPipeline: + viewer = new SimulateBuildPipelineViewer(this); + break; + case EBuildPipeline.BuiltinBuildPipeline: + viewer = new BuiltinBuildPipelineViewer(this); + break; + case EBuildPipeline.ScriptableBuildPipeline: + viewer = new ScriptableBuildPipelineViewer(this); + break; + case EBuildPipeline.RawFileBuildPipeline: + viewer = new RawfileBuildpipelineViewer(this); + break; + } + + _viewers.Add(selectedBuildPipelines, viewer); + } + } + + private List GetEncryptionServices() + { + var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices)); + if (encryption.IsNull()) + { + encryption = encryptionClassTypes[0]; + } + + return encryptionClassTypes; + } + + private void SetEncryptionServices() + { + AssetBundleBuilderSetting.SetPackageEncyptionClassName(packageName, selectedBuildPipelines, + encryption.FullName); + } + } + + public enum VersionPosType + { + X, + Y, + } + + public enum EnvironmentType + { + Debug, + Release, + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetDataSetting.cs.meta b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetDataSetting.cs.meta new file mode 100644 index 0000000..3679f01 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetDataSetting.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 39a67460f559484da2b52def8ff05571 +timeCreated: 1741844184 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetEntity.cs b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetEntity.cs new file mode 100644 index 0000000..233fd0f --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetEntity.cs @@ -0,0 +1,60 @@ +using System; +using Sirenix.OdinInspector; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + [Serializable] + public class BuildAssetEntity + { + public BuildAssetEntity(string HorizontalGroupName,string ButtonName ,Action OnClickAction ) + { + this.HorizontalGroupName = HorizontalGroupName; + this.ButtonName = ButtonName; + this.OnClickAction = OnClickAction; + } + + + private Color messageColor = Color.white; + private string messageText = "点击开始进程!!!!!"; + private bool showInfoBox = true; + private string HorizontalGroupName; + private string ButtonName; + private Action OnClickAction; + [HorizontalGroup("@ HorizontalGroupName")] + [Button("@ ButtonName", ButtonSizes.Large)] + [InfoBox("@ messageText", InfoMessageType.Error, "@ showInfoBox==false")] + [InfoBox("@ messageText", InfoMessageType.Info, "@ showInfoBox==true")] + private void CopyDll() + { + try + { + OnClickAction?.Invoke(); + showInfoBox = true; + messageColor = Color.green; + messageText = "进程结束!!!!!"; + } + catch (Exception e) + { + Debug.LogError(e); + showInfoBox = false; + messageText =$"进程存在异常,异常信息为:【{e.Message}】" ; + messageColor = Color.red; + } + } + + [HorizontalGroup("@ HorizontalGroupName", Width = 68)] + [Button(ButtonSizes.Large, Icon = SdfIconType.CheckCircleFill, IconAlignment = IconAlignment.RightEdge, + ButtonHeight = 68), + GUIColor("@messageColor")] + private void CopyDll1() + { + } + + + public void SetButtonName(string ButtonName) + { + this.ButtonName = ButtonName; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetEntity.cs.meta b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetEntity.cs.meta new file mode 100644 index 0000000..d84dfd4 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetEntity.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 689d3c7b06e841668647fc00ff0a3dd8 +timeCreated: 1741593629 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetWindow.cs b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetWindow.cs new file mode 100644 index 0000000..a0c9007 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetWindow.cs @@ -0,0 +1,281 @@ +/**************************************************** + 文件:BuildAssetWindow.cs + 作者:xosmo_ + 邮箱: + 日期:2025/3/10 10:43:20 + 功能: +*****************************************************/ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using EditorFramework; +using HybridCLR.Editor; +using HybridCLR.Editor.Commands; +using Sirenix.OdinInspector; +using Sirenix.OdinInspector.Editor; +using UnityEditor; +using UnityEditorInternal; +using UnityEngine; +using UnityEngine.Serialization; +using YooAsset; +using YooAsset.Editor; + +namespace Stary.Evo.Editor +{ + public class BuildAssetWindow : OdinEditorWindow + { + + private static BuildAssetWindow window; + [MenuItem("Evo/资源打包工具")] + static void ShowWindows() + { + if (CreatAssetWindow.GetCreatDomainAll().Count <= 0) + { + EditorUtility.DisplayDialog("提示", "不存在Domain元素,无法打开此面板,请先创建Domain元素", "确定" ); + return; + } + window = (BuildAssetWindow)EditorWindow.GetWindow(typeof(BuildAssetWindow)); + window.Show(); + } + + + + protected override void Initialize() + { + base.Initialize(); + GetBuildPackageNames(); + } + + public static void RemoveBuildAssetWindow() + { + if(window != null) + window.Close(); + } + protected void OnSelectionChange() + { + EditorUtility.SetDirty(BuildAssetDataSetting); + AssetDatabase.SaveAssets(); + //AssetDatabase.Refresh(); + } + + [Title("包裹列表", titleAlignment: TitleAlignments.Centered)] + [HorizontalGroup("BuildPipeline"), HideLabel] + [ValueDropdown("GetBuildPackageNames")] + [OnValueChanged("SetBuildPackageNames")] + public string selectedPackageNames; + + public static string packageName; + #region HyBridCLRBuild + + [Title("HyBridCLRBuild", titleAlignment: TitleAlignments.Centered)] [HideLabel] + public BuildAssetEntity hyBridClrBuildEntity = + new BuildAssetEntity("HyBridCLRBuild", "DllBuildTarget", () => + { + //PrebuildCommand.GenerateAll(); + CompileDllCommand.CompileDllActiveBuildTarget(); + }); + #endregion + + + #region MarkAsset + + [Title("MarkAsset", titleAlignment: TitleAlignments.Centered)] [HideLabel] + public BuildAssetEntity markAssetEntity = + new BuildAssetEntity("MarkAsset", "MarkAsset", MarkAdressable.AddMark); + + #endregion + + #region BuildAsset + + + + [InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)] + [HideLabel] public BuildAssetDataSetting BuildAssetDataSetting; + + /// + /// 检测当前所有包裹 + /// + /// + private List GetBuildPackageNames() + { + List result = new List(); + foreach (var name in CreatAssetWindow.GetCreatDomainAllName()) + { + result.Add(name); + } + + if (selectedPackageNames.IsNullOrEmpty()) + { + // string buildPackageName = DataSetting.packageName; + // if (result.Exists(p => p == buildPackageName)) + // { + // selectedPackageNames = buildPackageName; + // } + // else + // { + selectedPackageNames = result[0]; + //} + + + } + SetBuildPackageNames(); + return result; + } + + /// + /// 设置当前包裹 + /// + /// + private void SetBuildPackageNames() + { + //PlayerPrefs.SetString("BuildPackageNames", selectedPackageNames); + // DataSetting.packageName = selectedPackageNames; + packageName = selectedPackageNames; + // DataSetting = Resources.Load("BuildAssetDataSetting"); + string buildAssetDataSettingPath = $"Assets/Domain/{selectedPackageNames}/Conf/BuildAssetDataSetting.asset"; + BuildAssetDataSetting buildAssetDataSetting = + AssetDatabase.LoadAssetAtPath(buildAssetDataSettingPath); + if (buildAssetDataSetting != null) + { + BuildAssetDataSetting = buildAssetDataSetting; + Init(); + } + else + { + Debug.LogError($"UnityEvo:BuildAssetDataSetting 不存在,请检查路径{buildAssetDataSettingPath}"); + } + } + /// + /// 获取当前包裹 + /// + /// + public static string GetBuildPackageName() + { + return packageName; + } + #endregion + + #region Update + + [Title("BuildAssetButton", titleAlignment: TitleAlignments.Centered)] [HideLabel] + public BuildAssetEntity onBuildPipelineEntity; + + [FormerlySerializedAs("UpdateServerPath")] + [TitleGroup("UpdateAssetButton", alignment: TitleAlignments.Centered)][ShowIf("@ BuildAssetDataSetting.environmentType== EnvironmentType.Release",true)] + [ReadOnly] + [InfoBox("服务器资源盘位未存在", InfoMessageType.Error, "@ _isCheckDriveExist==false")] + [InfoBox("1、映射网络驱动器\n2、添加http://192.168.31.100:5005/alist/HotRefresh地址\n3、设置盘符为Z盘", InfoMessageType.Info, + "@ _isCheckDriveExist==false")] + public string updateServerPath; + + private bool _isCheckDriveExist; + + [TitleGroup("UpdateAssetButton", alignment: TitleAlignments.Centered)] [HideLabel][ShowIf("@ _isCheckDriveExist&&BuildAssetDataSetting.environmentType== EnvironmentType.Release",true)] + public BuildAssetEntity onUpdateBuildPipelineEntity; + + + private void OnBuildPipeline() + { + if (EditorUtility.DisplayDialog("提示", $"开始构建资源包[{selectedPackageNames}]!", "Yes", "No")) + { + EditorTools.ClearUnityConsole(); + EditorApplication.delayCall += BuildAssetDataSetting.viewer.ExecuteBuild; + } + else + { + Debug.LogWarning("[Build] 打包已经取消"); + } + } + + private void OnUpdateBuildPipeline() + { + + if (EditorUtility.DisplayDialog("提示", $"开始上传至服务器[{selectedPackageNames}]!", "Yes", "No")) + { + Stary.Evo.Editor.FileUtility.CopyDirectory( + $"{AssetBundleBuilderHelper.GetDefaultBuildOutputRoot()}/{EditorUserBuildSettings.activeBuildTarget}/{BuildAssetDataSetting.packageName}/{BuildAssetDataSetting.packageVersion}", + updateServerPath); + CreatePackageVersionJson(); + + + BuildAssetDataSetting.GetBuildPackageVersion(true); + + EditorUtility.DisplayDialog("提示", $"上传服务器完成!", "确定"); + } + else + { + Debug.LogWarning("[Update] 上传已经取消"); + } + } + + #endregion + + protected void Init() + { + //Update + //检测Z盘 + _isCheckDriveExist = Stary.Evo.Editor.FileUtility.CheckDriveExists("Z"); + + onBuildPipelineEntity = + new BuildAssetEntity("打包", $"打包资源包【版本:{BuildAssetDataSetting.packageVersion}】", OnBuildPipeline); + onUpdateBuildPipelineEntity = + new BuildAssetEntity("更新", $"更新至服务器【版本:{BuildAssetDataSetting.packageVersion}】", OnUpdateBuildPipeline); + + } + + private Vector2 scroll; + + protected override void DrawEditor(int index) + { + scroll = GUILayout.BeginScrollView(scroll); + { + base.DrawEditor(index); + BuildServerPath(); + } + GUILayout.EndScrollView(); + } + + + /// + /// 生成服务器路径 + /// + private void BuildServerPath() + { + if (!_isCheckDriveExist) + { + return; + } + updateServerPath = + $"Z:/{Application.productName}/{BuildAssetDataSetting.packageName}/{EditorUserBuildSettings.activeBuildTarget}/{BuildAssetDataSetting.packageVersion}"; + if (!Directory.Exists(updateServerPath)) + Directory.CreateDirectory(updateServerPath); + + //更新Button文字 + onBuildPipelineEntity.SetButtonName($"打包资源包【版本:{BuildAssetDataSetting.packageVersion}】"); + onUpdateBuildPipelineEntity.SetButtonName($"更新至服务器【版本:{BuildAssetDataSetting.packageVersion}】"); + } + + private void CreatePackageVersionJson() + { + string mainResDomainPath = $"Assets/Domain/{selectedPackageNames}/Conf/HotfixMainResDomain.asset"; + HotfixMainResDomain mainResDomain = + AssetDatabase.LoadAssetAtPath(mainResDomainPath); + + if (mainResDomain != null) + { + mainResDomain.hotfixMainResDomainEntity.packageVersion = BuildAssetDataSetting.packageVersion; + mainResDomain.hotfixMainResDomainEntity.pathconfig = + $"{Application.productName}/{BuildAssetDataSetting.packageName}/{EditorUserBuildSettings.activeBuildTarget}/{BuildAssetDataSetting.packageVersion}"; + } + + AssetDatabase.Refresh(); + // 保存更改 + AssetDatabase.SaveAssets(); + string serverPath = $"Z:/HybridclrConfigData/{BuildAssetDataSetting.packageName}/{EditorUserBuildSettings.activeBuildTarget}/"; + //直接保存服务器路径下,本地不保存 + EditorFrameworkUtils.SaveJson(mainResDomain.hotfixMainResDomainEntity, serverPath, Application.productName); + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Abstract/AbstractInformation.cs.meta b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetWindow.cs.meta similarity index 83% rename from Assets/02.InformationSave/RunTime/Abstract/AbstractInformation.cs.meta rename to Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetWindow.cs.meta index 80af3b7..cc19cd3 100644 --- a/Assets/02.InformationSave/RunTime/Abstract/AbstractInformation.cs.meta +++ b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetWindow.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0f5b94406351c9c4984472ef696d4888 +guid: 80143df6d596f664f97e7139d7811d2d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/BuiltinBuildPipelineViewer.cs b/Assets/00.StaryEvo/Editor/BuildAsset/BuiltinBuildPipelineViewer.cs new file mode 100644 index 0000000..402f309 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/BuiltinBuildPipelineViewer.cs @@ -0,0 +1,49 @@ +using System; +using UnityEditor; +using YooAsset; +using YooAsset.Editor; + +namespace Stary.Evo.Editor +{ + [Serializable] + public class BuiltinBuildPipelineViewer :AbstractBuildPipelineViewer + { + public BuiltinBuildPipelineViewer(BuildAssetDataSetting packageName) : base(packageName) + { + } + + public override void ExecuteBuild() + { + var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(dataSetting.packageName, dataSetting.selectedBuildPipelines); + + BuiltinBuildParameters buildParameters = new BuiltinBuildParameters(); + buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); + buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot(); + buildParameters.BuildPipeline = dataSetting.selectedBuildPipelines.ToString(); + buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle; + buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget; + buildParameters.PackageName = dataSetting.packageName; + buildParameters.PackageVersion =dataSetting.GetBuildPackageVersion(); + buildParameters.EnableSharePackRule = true; + buildParameters.VerifyBuildingResult = true; + buildParameters.FileNameStyle = fileNameStyle; + buildParameters.BuildinFileCopyOption = buildinFileCopyOption; + buildParameters.BuildinFileCopyParams = buildinFileCopyParams; + buildParameters.CompressOption = compressOption; + buildParameters.ClearBuildCacheFiles = clearBuildCache; + buildParameters.UseAssetDependencyDB = useAssetDependencyDB; + buildParameters.EncryptionServices = CreateEncryptionInstance(); + + BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline(); + var buildResult = pipeline.Run(buildParameters, true); + if (buildResult.Success) + EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory); + base.ExecuteBuild(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/BuiltinBuildPipelineViewer.cs.meta b/Assets/00.StaryEvo/Editor/BuildAsset/BuiltinBuildPipelineViewer.cs.meta new file mode 100644 index 0000000..cb15ac9 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/BuiltinBuildPipelineViewer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ac3d61d6f0744f02a2f038fdeed98b75 +timeCreated: 1741830306 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/CreatAssetWindow.cs b/Assets/00.StaryEvo/Editor/BuildAsset/CreatAssetWindow.cs new file mode 100644 index 0000000..e540115 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/CreatAssetWindow.cs @@ -0,0 +1,272 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using EditorFramework; +using HybridCLR.Editor; +using HybridCLR.Editor.Settings; +using Sirenix.OdinInspector; +using Sirenix.OdinInspector.Editor; +using Sirenix.Utilities; +using UnityEditor; +using UnityEditorInternal; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + public class CreatAssetWindow : OdinEditorWindow + { + [MenuItem("Evo/创建Domain作用域")] + static void Init() + { + // Get existing open window or if none, make a new one: + CreatAssetWindow window = (CreatAssetWindow)EditorWindow.GetWindow(typeof(CreatAssetWindow)); + window.Show(); + } + + [TitleGroup("创建Domain作用域")] public string domain; + + [TitleGroup("创建Domain作用域")] + [Button("创建Domain", ButtonSizes.Large)] + public async void CreatDomain() + { + if (GetCreatDomainAll().Count>0) + { + EditorUtility.DisplayDialog("错误!", "Domain仅可以创建一个,请在下方删除存在的Domain", "确定"); + return; + } + + if (string.IsNullOrEmpty(domain)) + { + EditorUtility.DisplayDialog("错误!", "请输入将要创建Domain的编号", "确定"); + return; + } + + string domainPath = $"{Application.dataPath}/Domain/{domain}"; + if (Directory.Exists(domainPath+"/AddressableRes/Config/DomainConfig.asset")) + { + EditorUtility.DisplayDialog("错误!", $"\"{domain}\"已经存在,无法创建", "确定"); + return; + } + + Directory.CreateDirectory(domainPath); + + //美术资源存放文件夹 + string resPath = $"{domainPath}/AddressableRes"; + Directory.CreateDirectory(resPath); + //创建音频文件夹 + Directory.CreateDirectory(resPath + "/Audios"); + //创建Config文件夹 + Directory.CreateDirectory(resPath + "/Config"); + //创建Dll文件夹 + Directory.CreateDirectory(resPath + "/Dll"); + //创建Prefabs文件夹 + Directory.CreateDirectory(resPath + "/Prefabs"); + //创建Scenes文件夹 + Directory.CreateDirectory(resPath + "/Scenes"); + //创建SpriteAtlas文件夹 + Directory.CreateDirectory(resPath + "/SpriteAtlas"); + //创建Sprites文件夹 + Directory.CreateDirectory(resPath + "/Sprites"); + //创建Video文件夹 + Directory.CreateDirectory(resPath + "/Video"); + + await File.WriteAllTextAsync($"{resPath}/这里放所有参与热更的资源.hint", ""); + + //主入口预制件 + GameObject gameObj = new GameObject(domain); + gameObj.transform.position = Vector3.zero; + gameObj.transform.rotation = Quaternion.identity; + gameObj.name = domain; + Directory.CreateDirectory($"{resPath}/Prefabs"); + string rootPfbFilePath = $"Assets/Domain/{domain}/AddressableRes/Prefabs/{domain}.prefab"; + var localPath = AssetDatabase.GenerateUniqueAssetPath(rootPfbFilePath); + PrefabUtility.SaveAsPrefabAsset(gameObj, localPath); + + //存放脚本文件夹 + string scriptsPath = $"{domainPath}/HotUpdate"; + Directory.CreateDirectory(scriptsPath); + await File.WriteAllTextAsync($"{scriptsPath}/这里放所有参与热更的脚本文件.hint", "该文件夹中的程序集定义文件,请勿删除,非常重要。"); + + //创建配置文件夹 + string confPath = $"{domainPath}/Conf"; + Directory.CreateDirectory(confPath); + + + //程序集配置资源 + + string hotfixDomain = $"HotUpdate_{domain}"; + + string hotfixDomainAsmdef = $"{scriptsPath}/{hotfixDomain}.asmdef"; + await using (var writer = new StreamWriter(hotfixDomainAsmdef)) + { + string body = Resources.Load("AssemblyDefinitionTemplate").text; + body = body.Replace("MODULE_IDENT", hotfixDomain); + body = body.Replace("ROOT_NAMESPACE", hotfixDomain); + await writer.WriteAsync(body); + } + + // await File.WriteAllTextAsync($"{scriptsPath}/{hotfixDomain}.asmdef", body); + + + // string architectureClassName = $"{domain}Architecture"; + // string architectureClassPath = $"{scriptsPath}/{architectureClassName}.txt"; + // //await File.WriteAllTextAsync($"{scriptsPath}/{architectureClassName}.cs", architectureTemplate); + // + // await using (var writer = new StreamWriter(architectureClassPath)) + // { + // + // string architectureTemplate = Resources.Load("ArchitectureTemplate").text; + // architectureTemplate = architectureTemplate.Replace("XXXX", architectureClassName); + // await writer.WriteAsync(architectureTemplate); + // } + //模块化脚本生成配置 + string domainClassName = $"{domain}Domain"; + string architectureClassName = $"{domain}Architecture"; + + //模块配置资源 + DomainConfig moduleConfig = CreateInstance(); + moduleConfig.domain = domain; + moduleConfig.className = domainClassName; + moduleConfig.mainPrefab = "Prefabs_" + gameObj.name; + moduleConfig.@namespace = domain; + AssetDatabase.CreateAsset(moduleConfig, $"Assets/Domain/{domain}/AddressableRes/Config/DomainConfig.asset"); + // + //模块服务器配置资源 + + HotfixMainResDomain hotfixMainResDomain = CreateInstance(); + hotfixMainResDomain.hotfixMainResDomainEntity = new HotfixMainResDomainEntity(); + hotfixMainResDomain.hotfixMainResDomainEntity.domain = domain; + AssetDatabase.CreateAsset(hotfixMainResDomain, $"Assets/Domain/{domain}/Conf/HotfixMainResDomain.asset"); + + //编辑器配置资源 + BuildAssetDataSetting buildAssetDataSetting = CreateInstance(); + buildAssetDataSetting.packageName = domain; + AssetDatabase.CreateAsset(buildAssetDataSetting, + $"Assets/Domain/{domain}/Conf/BuildAssetDataSetting.asset"); + + AssetDatabase.Refresh(); + + + string configPath = $"Assets/Domain/{domain}/HotUpdate/{hotfixDomain}.asmdef"; + AssemblyDefinitionAsset assemblyDefinitionAsset = + AssetDatabase.LoadAssetAtPath(configPath); + // 将程序集定义添加到 HybridCLR 热更列表 + var settings = SettingsUtil.HybridCLRSettings; + if (!settings.hotUpdateAssemblyDefinitions.Contains(assemblyDefinitionAsset)) + { + var assemblyList = settings.hotUpdateAssemblyDefinitions.ToList(); + assemblyList.Add(assemblyDefinitionAsset); + SettingsUtil.HybridCLRSettings.hotUpdateAssemblyDefinitions = assemblyList.ToArray(); + + } + + + List assemblies = new List(); + for (int i = 0; i < settings.hotUpdateAssemblyDefinitions.Length; i++) + { + if (settings.hotUpdateAssemblyDefinitions[i] != null) + { + assemblies.Add(settings.hotUpdateAssemblyDefinitions[i]); + } + } + + HybridCLRSettings.Instance.hotUpdateAssemblyDefinitions = assemblies.ToArray(); + HybridCLRSettings.Save(); + + AssetDatabase.SaveAssets(); + + + string domainClassPath = $"{scriptsPath}/{domainClassName}.cs"; + //await File.WriteAllTextAsync($"{scriptsPath}/{domainClassName}.cs", domainTemplate); + await using (var writer = new StreamWriter(domainClassPath)) + { + string domainTemplate = Resources.Load("DomainTemplate").text; + domainTemplate = domainTemplate.Replace("ClassNameXX", domainClassName) + .Replace("ReturnArchitecture", architectureClassName) + .Replace("ArchitectureX", architectureClassName) + .Replace("NamespaceX", domain); + await writer.WriteAsync(domainTemplate); + } + } + + public void CreateDomainClass() + { + } + + public void CreateArchitectureClass() + { + } + + [TitleGroup("预览Domain作用域")] public List domainList; + + protected override void Initialize() + { + base.Initialize(); + domainList = GetCreatDomainAll(); + } + /// + /// 获取全部作用域 + /// + public static string[] GetCreatDomainAllName() + { + string domainPath = $"{Application.dataPath}/Domain"; + string[] domains; + // 新增目录获取代码 + if (Directory.Exists(domainPath)) + { + var dirInfo = new DirectoryInfo(domainPath); + // 获取直接子目录(不递归) + domains = dirInfo.GetDirectories("*", SearchOption.TopDirectoryOnly) + .Select(d => d.Name) + .ToArray(); + } + else + { + domains = Array.Empty(); + } + + + + return domains; + } + /// + /// 获取全部作用域 + /// + public static List GetCreatDomainAll() + { + string domainPath = $"{Application.dataPath}/Domain"; + string[] domains; + // 新增目录获取代码 + if (Directory.Exists(domainPath)) + { + var dirInfo = new DirectoryInfo(domainPath); + // 获取直接子目录(不递归) + domains = dirInfo.GetDirectories("*", SearchOption.TopDirectoryOnly) + .Select(d => d.Name) + .ToArray(); + } + else + { + domains = Array.Empty(); + } + + List domainList = new List(); + foreach (var item in domains) + { + if (File.Exists($"{domainPath}/{item}/AddressableRes/Config/DomainConfig.asset")) + { + CreatDomainEntity domainEntity = new CreatDomainEntity(domainList) + { + DomainName = item, + domainPath = $"{domainPath}/{item}" + }; + domainList.Add(domainEntity); + } + } + + return domainList; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/CreatAssetWindow.cs.meta b/Assets/00.StaryEvo/Editor/BuildAsset/CreatAssetWindow.cs.meta new file mode 100644 index 0000000..9d79e74 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/CreatAssetWindow.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7d162e11fd4c47ee9f6995ad7bb6bac1 +timeCreated: 1742377890 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/Entity.meta b/Assets/00.StaryEvo/Editor/BuildAsset/Entity.meta new file mode 100644 index 0000000..0689b91 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/Entity.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7380165adc3342dbacef4abe80ac2bb7 +timeCreated: 1742867444 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/Entity/CreatDomainEntity.cs b/Assets/00.StaryEvo/Editor/BuildAsset/Entity/CreatDomainEntity.cs new file mode 100644 index 0000000..57b87e4 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/Entity/CreatDomainEntity.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.IO; +using EditorFramework; +using Sirenix.OdinInspector; +using UnityEditor; + +namespace Stary.Evo.Editor +{ + [Serializable] + public class CreatDomainEntity + { + private List domainList; + + [HorizontalGroup] [ReadOnly] public string DomainName; + [ReadOnly] + public string domainPath; + + + public CreatDomainEntity(List domainList) + { + this.domainList = domainList; + } + [HorizontalGroup(Width = 60)] + [Button("", Icon = SdfIconType.XCircle, IconAlignment = IconAlignment.RightEdge)] + public void CloseDomain() + { + bool isOk = EditorUtility.DisplayDialog("提示", "是否删除此Domain", "是", "否"); + if (isOk) + { + BuildAssetWindow.RemoveBuildAssetWindow(); + EditorFrameworkUtils.DeleteAllChild(domainPath, FileAttributes.Normal); + domainList.Clear(); + AssetDatabase.Refresh(); + AssetDatabase.SaveAssets(); + } + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/Entity/CreatDomainEntity.cs.meta b/Assets/00.StaryEvo/Editor/BuildAsset/Entity/CreatDomainEntity.cs.meta new file mode 100644 index 0000000..9463e8d --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/Entity/CreatDomainEntity.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b99d72d55efd48e099adf77d4608689d +timeCreated: 1742867433 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/IBuildPipelineViewer.cs b/Assets/00.StaryEvo/Editor/BuildAsset/IBuildPipelineViewer.cs new file mode 100644 index 0000000..1b8cf75 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/IBuildPipelineViewer.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using Sirenix.OdinInspector; +using Stary.Evo.Editor; +using UnityEditor; +using UnityEngine; +using YooAsset; +using YooAsset.Editor; + +namespace Stary.Evo.Editor +{ + [Serializable] + public class AbstractBuildPipelineViewer + { + protected BuildAssetDataSetting dataSetting; + + protected bool isSimulate; + protected bool isRaw; + + [Title("清理构建缓存", titleAlignment: TitleAlignments.Centered)] + [HorizontalGroup("BuildCache")] + [InfoBox("当不勾选此项的时候,引擎会开启增量打包模式,会极大提高构建速度!")] + [OnValueChanged("SetBuildCacheToggle")] + [HideIf("isSimulate", true)] + public bool clearBuildCacheToggle; + + [Title("依赖数据库", titleAlignment: TitleAlignments.Centered)] + [HorizontalGroup("BuildCache")] + [InfoBox("当开启此项的时候,会极大提高构建速度!")] + [OnValueChanged("SetUseAssetDependencyDB")] + [HideIf("isSimulate", true)] + public bool useAssetDependencyDBToggle; + + [Title("资源包的压缩方式", titleAlignment: TitleAlignments.Centered)] + [HorizontalGroup("FileStyle"), HideLabel] + [OnValueChanged("SetCompression")] + [HideIf("@isSimulate==true || isRaw==true")] + public ECompressOption compression; + + [Title("资源包文件名称样式", titleAlignment: TitleAlignments.Centered)] + [HorizontalGroup("FileStyle"), HideLabel] + [OnValueChanged("SetFileNameStyle")] + [HideIf("isSimulate", true)] + public EFileNameStyle fileNameStyle; + + [Title("首包资源文件的拷贝方式", titleAlignment: TitleAlignments.Centered)] + [HorizontalGroup("FileStyle"), HideLabel] + [OnValueChanged("SetCopyBuildinFileOption")] + [HideIf("isSimulate", true)] + public EBuildinFileCopyOption copyBuildinFileOption; + + [Title("首包资源文件的拷贝参数", titleAlignment: TitleAlignments.Centered)] + [HideLabel] + [OnValueChanged("SetCopyBuildinFileParams")] + [ShowIf( + "@copyBuildinFileOption==EBuildinFileCopyOption.ClearAndCopyByTags||copyBuildinFileOption==EBuildinFileCopyOption.OnlyCopyByTags ")] + public string copyBuildinFileParams; + + public AbstractBuildPipelineViewer(BuildAssetDataSetting dataSetting) + { + this.dataSetting = dataSetting; + useAssetDependencyDBToggle = true; + clearBuildCacheToggle = false; + compression = ECompressOption.LZ4; + fileNameStyle = EFileNameStyle.BundleName; + copyBuildinFileOption = EBuildinFileCopyOption.ClearAndCopyAll; + } + + #region AssetBuild + + private void SetCompression() + { + AssetBundleBuilderSetting.SetPackageCompressOption(dataSetting.packageName, dataSetting.selectedBuildPipelines, + compression); + } + + private void SetFileNameStyle() + { + + AssetBundleBuilderSetting.SetPackageFileNameStyle(dataSetting.packageName, dataSetting.selectedBuildPipelines, + fileNameStyle); + } + + private void SetCopyBuildinFileOption() + { + + AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(dataSetting.packageName, + dataSetting.selectedBuildPipelines, copyBuildinFileOption); + + //PlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption); + } + + private void SetCopyBuildinFileParams() + { + + AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(dataSetting.packageName, + dataSetting.selectedBuildPipelines, copyBuildinFileParams); + //PlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption); + } + + public void SetBuildCacheToggle() + { + AssetBundleBuilderSetting.SetPackageClearBuildCache(dataSetting.packageName, dataSetting.selectedBuildPipelines, + clearBuildCacheToggle); + } + + private void SetUseAssetDependencyDB() + { + + AssetBundleBuilderSetting.SetPackageUseAssetDependencyDB(dataSetting.packageName, dataSetting.selectedBuildPipelines, + useAssetDependencyDBToggle); + } + + #endregion + + + + public virtual void ExecuteBuild() + { + // GetPackageVersion(); + } + + + /// + /// 创建加密类实例 + /// + protected IEncryptionServices CreateEncryptionInstance() + { + var encyptionClassName = + AssetBundleBuilderSetting.GetPackageEncyptionClassName(dataSetting.packageName, + dataSetting.selectedBuildPipelines); + var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices)); + var classType = encryptionClassTypes.Find(x => x.FullName.Equals(encyptionClassName)); + if (classType != null) + return (IEncryptionServices)Activator.CreateInstance(classType); + else + return null; + } + + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/IBuildPipelineViewer.cs.meta b/Assets/00.StaryEvo/Editor/BuildAsset/IBuildPipelineViewer.cs.meta new file mode 100644 index 0000000..b0707b9 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/IBuildPipelineViewer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7fdaadaf963047a098c8b4f46fec5619 +timeCreated: 1741835014 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/RawfileBuildpipelineViewer.cs b/Assets/00.StaryEvo/Editor/BuildAsset/RawfileBuildpipelineViewer.cs new file mode 100644 index 0000000..79a2b82 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/RawfileBuildpipelineViewer.cs @@ -0,0 +1,48 @@ +using System; +using UnityEditor; +using YooAsset; +using YooAsset.Editor; + +namespace Stary.Evo.Editor +{ + [Serializable] + public class RawfileBuildpipelineViewer:AbstractBuildPipelineViewer + { + public RawfileBuildpipelineViewer(BuildAssetDataSetting packageName) : base(packageName) + { + isRaw = true; + } + + + public override void ExecuteBuild() + { + var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(dataSetting.packageName, dataSetting.selectedBuildPipelines); + + RawFileBuildParameters buildParameters = new RawFileBuildParameters(); + buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); + buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot(); + buildParameters.BuildPipeline = dataSetting.selectedBuildPipelines.ToString(); + buildParameters.BuildBundleType = (int)EBuildBundleType.RawBundle; + buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget; + buildParameters.PackageName = dataSetting.packageName; + buildParameters.PackageVersion =dataSetting.GetBuildPackageVersion(); + buildParameters.VerifyBuildingResult = true; + buildParameters.FileNameStyle = fileNameStyle; + buildParameters.BuildinFileCopyOption = buildinFileCopyOption; + buildParameters.BuildinFileCopyParams = buildinFileCopyParams; + buildParameters.ClearBuildCacheFiles = clearBuildCache; + buildParameters.UseAssetDependencyDB = useAssetDependencyDB; + buildParameters.EncryptionServices = CreateEncryptionInstance(); + + RawFileBuildPipeline pipeline = new RawFileBuildPipeline(); + var buildResult = pipeline.Run(buildParameters, true); + if (buildResult.Success) + EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory); + base.ExecuteBuild(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/RawfileBuildpipelineViewer.cs.meta b/Assets/00.StaryEvo/Editor/BuildAsset/RawfileBuildpipelineViewer.cs.meta new file mode 100644 index 0000000..77a3636 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/RawfileBuildpipelineViewer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 06dda5f218054dee83d2a37d42bb2b9a +timeCreated: 1741830326 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/ScriptableBuildPipelineViewer.cs b/Assets/00.StaryEvo/Editor/BuildAsset/ScriptableBuildPipelineViewer.cs new file mode 100644 index 0000000..47f399e --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/ScriptableBuildPipelineViewer.cs @@ -0,0 +1,62 @@ +using System; +using UnityEditor; +using YooAsset; +using YooAsset.Editor; + +namespace Stary.Evo.Editor +{ + [Serializable] + public class ScriptableBuildPipelineViewer:AbstractBuildPipelineViewer + { + public ScriptableBuildPipelineViewer(BuildAssetDataSetting packageName) : base(packageName) + { + } + + public override void ExecuteBuild() + { + var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var builtinShaderBundleName = GetBuiltinShaderBundleName(); + + ScriptableBuildParameters buildParameters = new ScriptableBuildParameters(); + buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); + buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot(); + buildParameters.BuildPipeline = dataSetting.selectedBuildPipelines.ToString(); + buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle; + buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget; + buildParameters.PackageName = dataSetting.packageName; + buildParameters.PackageVersion = dataSetting.GetBuildPackageVersion(); + buildParameters.EnableSharePackRule = true; + buildParameters.VerifyBuildingResult = true; + buildParameters.FileNameStyle = fileNameStyle; + buildParameters.BuildinFileCopyOption = buildinFileCopyOption; + buildParameters.BuildinFileCopyParams = buildinFileCopyParams; + buildParameters.CompressOption = compressOption; + buildParameters.ClearBuildCacheFiles = clearBuildCache; + buildParameters.UseAssetDependencyDB = useAssetDependencyDB; + buildParameters.BuiltinShadersBundleName = builtinShaderBundleName; + buildParameters.EncryptionServices = CreateEncryptionInstance(); + + ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline(); + var buildResult = pipeline.Run(buildParameters, true); + if (buildResult.Success) + EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory); + base.ExecuteBuild(); + } + + /// + /// 内置着色器资源包名称 + /// 注意:和自动收集的着色器资源包名保持一致! + /// + private string GetBuiltinShaderBundleName() + { + var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName; + var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult(); + return packRuleResult.GetBundleName(dataSetting.packageName, uniqueBundleName); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/ScriptableBuildPipelineViewer.cs.meta b/Assets/00.StaryEvo/Editor/BuildAsset/ScriptableBuildPipelineViewer.cs.meta new file mode 100644 index 0000000..be18ae4 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/ScriptableBuildPipelineViewer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cb4c30ccb8294c92a7545fc05377d7bc +timeCreated: 1741830341 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/SimulateBuildPipelineViewer.cs b/Assets/00.StaryEvo/Editor/BuildAsset/SimulateBuildPipelineViewer.cs new file mode 100644 index 0000000..e753d9b --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/SimulateBuildPipelineViewer.cs @@ -0,0 +1,42 @@ +using System; +using UnityEditor; +using YooAsset; +using YooAsset.Editor; + +namespace Stary.Evo.Editor +{ + [Serializable] + public class SimulateBuildPipelineViewer:AbstractBuildPipelineViewer + { + public SimulateBuildPipelineViewer(BuildAssetDataSetting packageName) : base(packageName) + { + isSimulate = true; + } + + public override void ExecuteBuild() + { + var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(dataSetting.packageName, dataSetting.selectedBuildPipelines); + var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(dataSetting.packageName, dataSetting.selectedBuildPipelines); + + EditorSimulateBuildParameters buildParameters = new EditorSimulateBuildParameters(); + buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); + buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot(); + buildParameters.BuildPipeline = dataSetting.selectedBuildPipelines.ToString(); + buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle; + buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget; + buildParameters.PackageName = dataSetting.packageName; + buildParameters.PackageVersion = dataSetting.GetBuildPackageVersion(); + buildParameters.VerifyBuildingResult = true; + buildParameters.FileNameStyle = fileNameStyle; + buildParameters.BuildinFileCopyOption = buildinFileCopyOption; + buildParameters.BuildinFileCopyParams = buildinFileCopyParams; + buildParameters.EncryptionServices = CreateEncryptionInstance(); + + EditorSimulateBuildPipeline pipeline = new EditorSimulateBuildPipeline(); + var buildResult = pipeline.Run(buildParameters, true); + if (buildResult.Success) + EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/SimulateBuildPipelineViewer.cs.meta b/Assets/00.StaryEvo/Editor/BuildAsset/SimulateBuildPipelineViewer.cs.meta new file mode 100644 index 0000000..c53ff53 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/BuildAsset/SimulateBuildPipelineViewer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 501ea11982da4673b0bf8af90a805329 +timeCreated: 1741830160 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/ChangePlayerMode.meta b/Assets/00.StaryEvo/Editor/ChangePlayerMode.meta new file mode 100644 index 0000000..2e4ffd2 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/ChangePlayerMode.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7dfc7b6280e2426a81a5ead99db006f7 +timeCreated: 1741232911 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/ChangePlayerMode/ChangePlayerMode.cs b/Assets/00.StaryEvo/Editor/ChangePlayerMode/ChangePlayerMode.cs new file mode 100644 index 0000000..adc038e --- /dev/null +++ b/Assets/00.StaryEvo/Editor/ChangePlayerMode/ChangePlayerMode.cs @@ -0,0 +1,89 @@ +using System; +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + public class ChangePlayerMode + { + public static PLayerMode PLayerMode + { + get => _pLayerMode; + set => SetPlayerMode(value); + } + + private static PLayerMode _pLayerMode; + + private const string EditorSimulateMode = "Evo/ChangePlayerMode/EditorSimulateMode(编辑器调试模式)"; + private const string OfflinePlayMode = "Evo/ChangePlayerMode/OfflinePlayMode(本地运行模式)"; + private const string HostPlayMode = "Evo/ChangePlayerMode/HostPlayMode(服务器运行模式)"; + private const string WebPlayMode = "Evo/ChangePlayerMode/WebPlayMode(Web运行模式)"; + + [MenuItem(EditorSimulateMode)] + private static void SetEditorMode() => SetPlayerMode(PLayerMode.EDITOR_SIMULATEMODE); + + [MenuItem(OfflinePlayMode)] + private static void SetOfflineMode() => SetPlayerMode(PLayerMode.OFFLINE_PLAYMODE); + + [MenuItem(HostPlayMode)] + private static void SetHostMode() => SetPlayerMode(PLayerMode.HOST_PLAYMODE); + + [MenuItem(WebPlayMode)] + private static void SetWebMode() => SetPlayerMode(PLayerMode.WEB_PLAYMODE); + + [MenuItem(EditorSimulateMode, true)] + private static bool ValidateModeMenu() + { + string platform = EditorPrefs.GetString("ChangePLayerMode", PLayerMode.EDITOR_SIMULATEMODE.ToString()); + Menu.SetChecked(EditorSimulateMode, platform == PLayerMode.EDITOR_SIMULATEMODE.ToString()); + Menu.SetChecked(OfflinePlayMode, platform == PLayerMode.OFFLINE_PLAYMODE.ToString()); + Menu.SetChecked(HostPlayMode, platform == PLayerMode.HOST_PLAYMODE.ToString()); + Menu.SetChecked(WebPlayMode, platform == PLayerMode.WEB_PLAYMODE.ToString()); + Debug.LogError("CheckPlatform"); + return true; + } + + private static void SetPlayerMode(PLayerMode mode) + { + // 清除所有旧模式定义 + var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup; + if (currentTarget == BuildTargetGroup.Unknown) return; + + var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTarget) + .Split(';') + .Where(d => !Enum.GetNames(typeof(PLayerMode)).Contains(d)) + .ToList(); + + // 添加新模式 + defines.Add(mode.ToString()); + PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines)); + Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志 + _pLayerMode = mode; + EditorPrefs.SetString("ChangePLayerMode", _pLayerMode.ToString()); + AssetDatabase.Refresh(); + // 添加解决方案文件重新生成逻辑 + EditorApplication.delayCall += () => + { + EditorApplication.ExecuteMenuItem("Assets/Open C# Project"); + UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation(); + Debug.Log("已强制重新生成解决方案文件"); + }; + } + } + + public enum PLayerMode + { + //编辑仿真模式, + EDITOR_SIMULATEMODE, + + //单机运行模式 + OFFLINE_PLAYMODE, + + //联机运行模式 + HOST_PLAYMODE, + + //web运行模式 + WEB_PLAYMODE + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/ChangePlayerMode/ChangePlayerMode.cs.meta b/Assets/00.StaryEvo/Editor/ChangePlayerMode/ChangePlayerMode.cs.meta new file mode 100644 index 0000000..3fd397d --- /dev/null +++ b/Assets/00.StaryEvo/Editor/ChangePlayerMode/ChangePlayerMode.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 28520dd6a62c460d93fe8bb524b6a159 +timeCreated: 1741232924 \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime.meta b/Assets/00.StaryEvo/Editor/Create.meta similarity index 77% rename from Assets/02.InformationSave/RunTime.meta rename to Assets/00.StaryEvo/Editor/Create.meta index 618ad91..ecde285 100644 --- a/Assets/02.InformationSave/RunTime.meta +++ b/Assets/00.StaryEvo/Editor/Create.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: dd58efb7f9e1b0c4f9d07e84827f357d +guid: d2b63bce95e26de40814079b9e215865 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/02.InformationSave/RunTime/Abstract.meta b/Assets/00.StaryEvo/Editor/Create/ChangeScriptTemplates.meta similarity index 77% rename from Assets/02.InformationSave/RunTime/Abstract.meta rename to Assets/00.StaryEvo/Editor/Create/ChangeScriptTemplates.meta index 5645ab5..81be761 100644 --- a/Assets/02.InformationSave/RunTime/Abstract.meta +++ b/Assets/00.StaryEvo/Editor/Create/ChangeScriptTemplates.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3e0efc3ec4ae1fe458358558357e78fb +guid: 10cd38fccc1db684d9a576da1f9dc85e folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/00.StaryEvo/Editor/Create/ChangeScriptTemplates/ChangeScriptTemplates.cs b/Assets/00.StaryEvo/Editor/Create/ChangeScriptTemplates/ChangeScriptTemplates.cs new file mode 100644 index 0000000..c6123e9 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Create/ChangeScriptTemplates/ChangeScriptTemplates.cs @@ -0,0 +1,40 @@ +using System; +using System.IO; + +namespace Stary.Evo.Editor +{ + public class ChangeScriptTemplates : UnityEditor.AssetModificationProcessor + { + // 要添加的注释的内容 + private static string annotationStr = + "/**************************************************** \r\n" + + " 文件:#Filename\r\n" + + " 作者:#CreateAuthor#\r\n" + + " 邮箱:\r\n" + + " 日期:#CreateTime#\r\n" + + " 功能:\r\n" + + "*****************************************************/\r\n\n"; + + public static void OnWillCreateAsset(string path) + { + //将.meta后缀屏蔽 + path = path.Replace(".meta", ""); + //只对.cs脚本作操作 + if (path.EndsWith(".cs")) + { + //读取该路径下的.cs文件中的所有文本. + //注意,此时Unity已经对脚本完成了模版内容的替换,包括#SCRIPTNAME#也已经被替换为文件名了,读取到的是替换后的文本内容. + annotationStr += File.ReadAllText(path); + //获取用户名和当前系统时间并替换对应位置内容 + annotationStr = annotationStr.Replace("#CreateAuthor#", Environment.UserName) + .Replace("#CreateTime#", string.Concat(DateTime.Now.Year, "/", DateTime.Now.Month, "/", + DateTime.Now.Day, " ", DateTime.Now.Hour, ":", DateTime.Now.Minute, ":", DateTime.Now.Second)) + .Replace("#Filename", Path.GetFileName(path)); + if (!File.ReadAllText(path).Contains("文件") && !File.ReadAllText(path).Contains("作者") && !File.ReadAllText(path).Contains("邮箱") && !File.ReadAllText(path).Contains("日期") && !File.ReadAllText(path).Contains("功能")) + //重新将文本写入.cs文件 + File.WriteAllText(path, annotationStr); + } + + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/AnchoredPosition.cs.meta b/Assets/00.StaryEvo/Editor/Create/ChangeScriptTemplates/ChangeScriptTemplates.cs.meta similarity index 83% rename from Assets/02.InformationSave/RunTime/AnchoredPosition.cs.meta rename to Assets/00.StaryEvo/Editor/Create/ChangeScriptTemplates/ChangeScriptTemplates.cs.meta index 3fdcc7c..31f4239 100644 --- a/Assets/02.InformationSave/RunTime/AnchoredPosition.cs.meta +++ b/Assets/00.StaryEvo/Editor/Create/ChangeScriptTemplates/ChangeScriptTemplates.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f5c3a514df208eb4cb4a15721b54f849 +guid: 46fd7b74d162e9042a93085169ef025f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject.meta b/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject.meta new file mode 100644 index 0000000..a3284a6 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cf3097de0b145f944931508c9e1a0bcd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/CreatScriptableObject.cs b/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/CreatScriptableObject.cs new file mode 100644 index 0000000..55e47fa --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/CreatScriptableObject.cs @@ -0,0 +1,51 @@ +/**************************************************** + 文件:CreatScriptableObject.cs + 作者:张铮 + 邮箱:834207172@qq.com + 日期:2022/3/7 18:26:10 + 功能: +*****************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; +using Sirenix.OdinInspector.Editor; +using Sirenix.Utilities; +using UnityEditor; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + + + public class CreatScriptableObject : OdinMenuEditorWindow + { + [MenuItem("Evo/Utility/ScriptObject/查找", false, 3)] + //[MenuItem("Assets/Create Scriptable Object", priority = -1000)] + private static void ShowDialog() + { + GetWindow().Show(); + } + + /// + /// 获取继承 ScriptableObject 且不是Editor相关的所有自定义类(也就是自己编写的类) + /// + // static HashSet scriptableObjectTypes = AssemblyUtilities.GetTypes(AssemblyTypeFlags.CustomTypes) + // .Where(t => + // t.IsClass && + // typeof(ScriptableObject).IsAssignableFrom(t) && + // !typeof(EditorWindow).IsAssignableFrom(t) && + // !typeof(Editor).IsAssignableFrom(t) && t.GetCustomAttribute() != null) + // .ToHashSet(); + protected override OdinMenuTree BuildMenuTree() + { + OdinMenuTree tree = new OdinMenuTree(false); //不支持多选 + tree.Selection.SupportsMultiSelect = false; + + + tree.AddAllAssetsAtPath("预览ScriptableObject", "Assets/Domain", typeof(ScriptableObject), true, true); + // tree.AddAllAssetsAtPath("预览ScriptableObject", "Assets/~Resources", typeof(ScriptableObject), true, true); + return tree; + } + } +} \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/Base/CustomEditorBase.cs.meta b/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/CreatScriptableObject.cs.meta similarity index 83% rename from Assets/02.InformationSave/RunTime/Base/CustomEditorBase.cs.meta rename to Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/CreatScriptableObject.cs.meta index 21d2148..da4c785 100644 --- a/Assets/02.InformationSave/RunTime/Base/CustomEditorBase.cs.meta +++ b/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/CreatScriptableObject.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 00771a0cc2a1d7a42bb8d06ae6dce935 +guid: ef650bd595ac650469971d45500a96ea MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/ScriptableObjectCreator.cs b/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/ScriptableObjectCreator.cs new file mode 100644 index 0000000..cf5451c --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/ScriptableObjectCreator.cs @@ -0,0 +1,204 @@ +// /**************************************************** +// 文件:ScriptableObjectCreator.cs +// 作者:张铮 +// 邮箱:834207172@qq.com +// 日期:2022/3/7 18:24:58 +// 功能: +// *****************************************************/ +// +// using System; +// using System.Collections.Generic; +// using System.IO; +// using System.Linq; +// using EditorFramework; +// using Sirenix.OdinInspector.Editor; +// using Sirenix.Utilities; +// using Sirenix.Utilities.Editor; +// using UnityEditor; +// using UnityEngine; +// using WVDFramework; +// +// public class ScriptableObjectCreator : OdinMenuEditorWindow +// { +// [MenuItem("Utility/ScriptObject/创建",false,2)] +// //[MenuItem("Assets/Create Scriptable Object", priority = -1000)] +// private static void ShowDialog() +// { +// var path = "Assets"; +// var obj = Selection.activeObject; //当前鼠标选中的 Object +// if (obj && AssetDatabase.Contains(obj)) +// { +// path = AssetDatabase.GetAssetPath(obj); +// if (!Directory.Exists(path)) //主要用来判断所选的是文件还是文件夹 +// { +// path = Path.GetDirectoryName(path); //如果是文件则获取对应文件夹的全名称 +// } +// } +// +// //设置窗口对应属性 +// var window = CreateInstance(); +// window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 500); //设置窗口的宽和高 +// window.titleContent = new GUIContent(path); +// window.targetFolder = path.Trim('/'); //避免出现 / 造成路径不对 +// window.ShowUtility(); +// } +// +// /// +// /// 获取继承 ScriptableObject 且不是Editor相关的所有自定义类(也就是自己编写的类) +// /// +// private static HashSet scriptableObjectTypes = AssemblyUtilities.GetTypes(AssemblyTypeFlags.CustomTypes) +// .Where(t => +// t.IsClass && +// typeof(ScriptableObject).IsAssignableFrom(t) && +// !typeof(EditorWindow).IsAssignableFrom(t) && +// !typeof(Editor).IsAssignableFrom(t) && t.GetCustomAttribute() != null) +// .ToHashSet(); +// /// +// /// 选中的 ScriptableObject(等待创建) +// /// +// private ScriptableObject previewObject; +// +// /// +// /// 创建 ScriptableObject 时文件存储的目标文件夹 +// /// +// private string targetFolder; +// +// private Vector2 scroll; +// +// private Type SelectedType +// { +// get +// { +// var m = MenuTree.Selection.LastOrDefault(); //因为可以多选,所以返回选中的是一个列表,这里返回的是列表的最后一个Object +// return m == null ? null : m.Value as Type; +// } +// } +// +// protected override OdinMenuTree BuildMenuTree() +// { +// mFolderField = new FolderField(); +// OdinMenuTree tree = new OdinMenuTree(false); //不支持多选 +// MenuWidth = 300; //菜单的宽度 +// WindowPadding = Vector4.zero; +// tree.Config.DrawSearchToolbar = true; //开启搜索状态 +// tree.DefaultMenuStyle = OdinMenuStyle.TreeViewStyle; //菜单设置成树形模式 +// //筛选所有非抽象的类 并获取对应的路径 +// tree.AddRange(scriptableObjectTypes.Where(x => !x.IsAbstract), GetMenuPathForType).AddThumbnailIcons(); +// tree.SortMenuItemsByName(); +// tree.Selection.SelectionConfirmed += x => +// { +// Debug.Log($"双击确认并创建:{x}"); +// this.CreateAsset(); +// }; +// tree.Selection.SelectionChanged += e => +// { +// //每当选择发生更改时发生进行回调2次,一次SelectionCleared 一次是ItemAdded +// if (this.previewObject && !AssetDatabase.Contains(this.previewObject)) +// { +// DestroyImmediate(previewObject); +// } +// +// if (e != SelectionChangedType.ItemAdded) +// { +// return; +// } +// +// var t = SelectedType; +// if (t != null && !t.IsAbstract) +// { +// previewObject = CreateInstance(t) as ScriptableObject; +// } +// }; +// return tree; +// } +// +// private string GetMenuPathForType(Type t) +// { +// if (t != null && scriptableObjectTypes.Contains(t)) +// { +// var name = t.Name.Split('`').First() +// .SplitPascalCase(); //主要是为了去除泛型相关 例如:Sirenix.Utilities.GlobalConfig`1[Sirenix.Serialization.GlobalSerializationConfig] +// return GetMenuPathForType(t.BaseType) + "/" + name; +// } +// +// return ""; +// } +// +// protected override IEnumerable GetTargets() +// { +// yield return previewObject; +// } +// +// private FolderField mFolderField; +// +// // private void OnEnable() +// // { +// // mFolderField = new FolderField(); +// // } +// +// private string filename = default; +// +// protected override void DrawEditor(int index) +// { +// //scroll 内容滑动条的XY坐标 +// scroll = GUILayout.BeginScrollView(scroll); +// { +// base.DrawEditor(index); +// } +// GUILayout.EndScrollView(); +// +// if (this.previewObject) +// { +// GUILayout.FlexibleSpace(); //插入一个空隙 +// SirenixEditorGUI.HorizontalLineSeparator(5); //插入一个水平分割线 +// GUILayout.BeginHorizontal(); +// { +// GUILayout.Label("选择要创建到的路径"); +// var rect = EditorGUILayout.GetControlRect(GUILayoutOptions.Height(20)); +// mFolderField.OnGUI(rect); +// } +// GUILayout.EndHorizontal(); +// SirenixEditorGUI.HorizontalLineSeparator(5); //插入一个水平分割线 +// GUILayout.BeginHorizontal(); +// { +// GUILayout.Label("请输入要创建的文件名字"); +// filename = GUILayout.TextField(filename); +// GUILayout.Label(".asset", GUILayout.MaxWidth(40)); +// } +// GUILayout.EndHorizontal(); +// +// SirenixEditorGUI.HorizontalLineSeparator(5); //插入一个水平分割线 +// if (GUILayout.Button("Create Asset", GUILayoutOptions.Height(30))) +// { +// if (mFolderField.Path == "Assets") +// { +// if (EditorUtility.DisplayDialog("创建", ".asset文件创建在Assets目录下,是否确定创建", "是", "否")) //显示对话框 +// { +// CreateAsset(); +// } +// } +// else +// { +// CreateAsset(); +// } +// } +// } +// } +// +// private void CreateAsset() +// { +// if (previewObject) +// { +// if (filename == default) +// filename = MenuTree.Selection.First().Name.Replace(" ",""); +// var dest = mFolderField.Path + filename + ".asset"; +// dest = AssetDatabase.GenerateUniqueAssetPath(dest); //创建唯一路径 重名后缀 +1 +// Debug.Log($"要创建的为{previewObject}"); +// AssetDatabase.CreateAsset(previewObject, dest); +// AssetDatabase.SaveAssets(); +// AssetDatabase.Refresh(); +// Selection.activeObject = previewObject; +// EditorApplication.delayCall += Close; //如不需要创建后自动关闭可将本行注释 +// } +// } +// } \ No newline at end of file diff --git a/Assets/02.InformationSave/Editor/CustomEditorBaseEditor.cs.meta b/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/ScriptableObjectCreator.cs.meta similarity index 83% rename from Assets/02.InformationSave/Editor/CustomEditorBaseEditor.cs.meta rename to Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/ScriptableObjectCreator.cs.meta index cc331c7..5212596 100644 --- a/Assets/02.InformationSave/Editor/CustomEditorBaseEditor.cs.meta +++ b/Assets/00.StaryEvo/Editor/Create/CreatScriptableObject/ScriptableObjectCreator.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2da8df4f2ba04494a90eec6fda524a49 +guid: 814d860f258b17945ba74463d9d00144 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer.meta b/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer.meta new file mode 100644 index 0000000..f09b529 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 20d2d1f263e3b9c4fb90d17963276af4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/StringToLayer.cs b/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/StringToLayer.cs new file mode 100644 index 0000000..21eb913 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/StringToLayer.cs @@ -0,0 +1,77 @@ +/**************************************************** + 文件:StringToLayer.cs + 作者:张铮 + 邮箱:834207172@qq.com + 日期:2022/3/3 17:53:52 + 功能: +*****************************************************/ + +using System.IO; +using System.Text; +using UnityEditor; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + public class StringToLayer + { + [MenuItem("Evo/Utility/Layer和Tag转换")] + private static void Layer() + { + var sb = new StringBuilder(); //准备模板生成 + sb.AppendLine("public class _Const"); + sb.AppendLine("{"); + + for (int i = 0; i < 32; i++) //遍历所有Layer + { + var name = LayerMask.LayerToName(i); //通过Unity的接口拿到Layer名称 + name = name + .Replace(" ", "_") + .Replace("&", "_") + .Replace("/", "_") + .Replace(".", "_") + .Replace(",", "_") + .Replace(";", "_") + .Replace("-", "_"); //对常见的特殊字符进行过滤 + if (!string.IsNullOrEmpty(name)) + sb.AppendFormat("\tpublic const int LAYER_{0} = {1};\n", name.ToUpper(), i); + } + + sb.AppendLine("\tpublic const string " + ("Tag_Untagged".ToUpper() + " = " + + "\"Untagged\";")); + sb.AppendLine("\tpublic const string " + ("Tag_Respawn".ToUpper() + " = " + + "\"Respawn\";")); + sb.AppendLine("\tpublic const string " + ("Tag_Finish".ToUpper() + " = " + + "\"Finish\";")); + sb.AppendLine("\tpublic const string " + ("Tag_EditorOnly".ToUpper() + "= " + "\"EditorOnly\";")); + sb.AppendLine("\tpublic const string " + ("Tag_MainCamera".ToUpper() + "= " + "\"MainCamera\";")); + sb.AppendLine("\tpublic const string " + ("Tag_Player".ToUpper() + " = " + + "\"Player\";")); + sb.AppendLine("\tpublic const string " + ("Tag_GameController".ToUpper() + + " = " + "\"GameController\";")); //把一部分内置Tag先写死 + var asset = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset"); //取得自定义Tag + if ((asset != null) && (asset.Length > 0)) + { + for (int i = 0; i < asset.Length; i++) + { + //创建序列化对象 + var so = new UnityEditor.SerializedObject(asset[i]); + var tags = so.FindProperty("tags"); //读取具体字段 + for (int j = 0; j < tags.arraySize; ++j) + { + var item = tags.GetArrayElementAtIndex(j).stringValue; + sb.AppendFormat("\tpublic const string TAG_{0} = \"{1}\";\n", + item.ToUpper(), item); + } //添加到模板 + } + } + + sb.AppendLine("}"); + File.WriteAllText("Assets/HotUpdate/GeneratedConst.cs", sb.ToString()); //写入硬盘 + UnityEditor.AssetDatabase.Refresh(); //通知Unity刷新 + + + ///可新增BudSetting中场景 + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/StringToLayer.cs.meta b/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/StringToLayer.cs.meta new file mode 100644 index 0000000..67b901b --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/StringToLayer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42faa98f2e9e23546949a21ac1629c83 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/EditorFont.meta b/Assets/00.StaryEvo/Editor/EditorFont.meta new file mode 100644 index 0000000..2389c5a --- /dev/null +++ b/Assets/00.StaryEvo/Editor/EditorFont.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2dc5aefff23b02742aaa9aafd3ceb4e7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/EditorFont/ChangeFont.cs b/Assets/00.StaryEvo/Editor/EditorFont/ChangeFont.cs new file mode 100644 index 0000000..10965d5 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/EditorFont/ChangeFont.cs @@ -0,0 +1,47 @@ +using System; +using UnityEngine; +using UnityEditor; +using UnityEngine.UI; + +namespace Stary.Evo.Editor +{ + public class ChangeFont :IFontChange + { + Font toChange; + static Font toChangeFont; + FontStyle toFontStyle; + static FontStyle toChangeFontStyle; + public void Creat() + { + EditorGUILayout.Space(); + toChange = (Font) EditorGUILayout.ObjectField(toChange, typeof(Font), true, GUILayout.MinWidth(100),GUILayout.MinHeight(30)); + toChangeFont = toChange; + EditorGUILayout.Space(); + toFontStyle = (FontStyle) EditorGUILayout.EnumPopup(toFontStyle, GUILayout.MinWidth(100f),GUILayout.MinHeight(30)); + toChangeFontStyle = toFontStyle; + EditorGUILayout.Space(); + GUI.color = Color.green; + if (GUILayout.Button("更换",GUILayout.MinWidth(200), GUILayout.MinHeight(50))) + { + Change(); + } + } + private void Change() + { + var tArray = Resources.FindObjectsOfTypeAll(typeof(Text)); + for (int i = 0; i < tArray.Length; i++) + { + Text t = tArray[i] as Text; + //这个很重要,博主发现如果没有这个代码,unity是不会察觉到编辑器有改动的,自然设置完后直接切换场景改变是不被保存的 + //如果不加这个代码,在做完更改后,自己随便手动修改下场景里物体的状态,在保存就好了 + Undo.RecordObject(t, t.gameObject.name); + t.font = toChangeFont; + t.fontStyle = toChangeFontStyle; + //相当于让他刷新下 不然unity显示界面还不知道自己的东西被换掉了,还会呆呆的显示之前的东西 + EditorUtility.SetDirty(t); + } + + Debug.Log("Succed"); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/EditorFont/ChangeFont.cs.meta b/Assets/00.StaryEvo/Editor/EditorFont/ChangeFont.cs.meta new file mode 100644 index 0000000..54c3b59 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/EditorFont/ChangeFont.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4c8ea60d514c51142a7ede6495a50981 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/EditorFont/CreatWindowFont.cs b/Assets/00.StaryEvo/Editor/EditorFont/CreatWindowFont.cs new file mode 100644 index 0000000..87f025f --- /dev/null +++ b/Assets/00.StaryEvo/Editor/EditorFont/CreatWindowFont.cs @@ -0,0 +1,49 @@ +/**************************************************** + 文件:CreatWindowFont.cs + 作者:张铮 + 邮箱:834207172@qq.com + 日期:2022/3/6 16:31:29 + 功能:对更换字体功能进行重构 +*****************************************************/ + +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + + public class CreatWindowFont : EditorWindow + { + private FontMode fontMode; + private IFontChange fontChange = new ChangeFont(); + private IFontChange defaultfontChange = new DefaultFontEditor(); + + [MenuItem("Evo/Utility/字体设置", false, 1)] + static void Create() + { + GetWindow().Show(); + } + void OnGUI() + { + fontMode = (FontMode) GUILayout.Toolbar((int) fontMode, Enum.GetNames(typeof(FontMode))); + switch (fontMode) + { + case FontMode.更换字体: + fontChange.Creat(); + break; + case FontMode.默认字体: + defaultfontChange.Creat(); + break; + } + } + } + + enum FontMode + { + 更换字体, + 默认字体 + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/EditorFont/CreatWindowFont.cs.meta b/Assets/00.StaryEvo/Editor/EditorFont/CreatWindowFont.cs.meta new file mode 100644 index 0000000..79c9f25 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/EditorFont/CreatWindowFont.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e553dbbd76141cb43a861b229a57d619 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/EditorFont/DefaultFontEditor.cs b/Assets/00.StaryEvo/Editor/EditorFont/DefaultFontEditor.cs new file mode 100644 index 0000000..c7a0aba --- /dev/null +++ b/Assets/00.StaryEvo/Editor/EditorFont/DefaultFontEditor.cs @@ -0,0 +1,186 @@ +using UnityEditor; +using UnityEngine; +using UnityEngine.UI; +using System; +using System.IO; +using EditorFramework; +using UnityEngine.SceneManagement; + +namespace Stary.Evo.Editor +{ + /// + /// 设置字体面板 + /// + public class DefaultFontEditor : IFontChange + { + private static Font m_font; + + public void Creat() + { + EditorGUILayout.Space(); + EditorGUILayout.LabelField("选择默认字体"); + EditorGUILayout.Space(); + m_font = (Font) EditorGUILayout.ObjectField(m_font, typeof(Font), true,GUILayout.MinWidth(100f),GUILayout.MinHeight(30)); + EditorGUILayout.Space(); + GUI.color = Color.green; + if (GUILayout.Button("确定",GUILayout.MinWidth(200), GUILayout.MinHeight(50))) + { + ToolCacheManager.SaveFont(m_font); + } + } + [MenuItem("GameObject/UI/DefaultText")] + static void CreatImage() + { + Text text = CreateComponent(); + if (text!=null) + { + text.font = ToolCacheManager.GetFont(); + } + } + private static T CreateComponent() where T : Component + { + string name = typeof(T).Name; + GameObject go = new GameObject(name); + Transform parent = GetUIParent(); + go.transform.SetParent(parent, false); + T com = go.AddComponent(); + return com; + } + private static Transform GetUIParent() + { + Transform select = Selection.activeTransform; + if (select) + { + if (select.GetComponentInParent()) + { + return select; + } + else + { + Canvas canvas = select.GetComponentInChildren(); + if (canvas == null) + { + canvas = InstanceCanvas(select); + } + return canvas.transform; + } + } + else + { + Canvas canvas = GetCanvasInScene(); + if (canvas == null) + { + canvas = InstanceCanvas(); + } + return canvas.transform; + } + } + /// + /// 参考PrefabStageUtility.HandleUIReparentingIfNeeded + /// + /// + static Canvas GetCanvasInScene() + { + Scene scene = SceneManager.GetActiveScene(); + foreach (GameObject go in scene.GetRootGameObjects()) + { + var canvas = go.GetComponentInChildren(); + if (canvas != null) + return canvas; + } + return null; + } + /// + /// 参考PrefabStageUtility.HandleUIReparentingIfNeeded + /// + /// + private static Canvas InstanceCanvas(Transform parent = null) + { + const string kUILayerName = "UI"; + GameObject root = EditorUtility.CreateGameObjectWithHideFlags("Canvas", HideFlags.DontSave); + root.layer = LayerMask.NameToLayer(kUILayerName); + Canvas canvas = root.AddComponent(); + canvas.renderMode = RenderMode.ScreenSpaceOverlay; + root.AddComponent(); + root.AddComponent(); + if (parent) + { + canvas.transform.SetParent(parent, false); + } + return canvas; + } + } + + /// + /// 缓存管理类 + /// + public class ToolCacheManager + { + private static string mFontDataPath = "Assets/Main/Tools/Font/FontData.asset"; + + private static string FontDataFolderPath + { + get { return Application.dataPath + "/Main/Tools/Font"; } + } + + /// + /// 保存设置的字体 + /// + /// + public static void SaveFont(Font font) + { + CheckFontDataFolderExist(); + EditorFrameworkUtils.DeleteFile(FontDataFolderPath, "FontData.asset"); + FontData data = ScriptableObject.CreateInstance(); + data.defaultFont = font; + AssetDatabase.CreateAsset(data, mFontDataPath); + EditorUtility.SetDirty(data); + } + + /// + /// 从FontData.asset获取字体 + /// + /// + public static Font GetFont() + { + FontData fontData = AssetDatabase.LoadAssetAtPath(mFontDataPath); + if (fontData != null) + return fontData.defaultFont; + else + return null; + } + + /// + /// 确保存放FontData.asset文件夹存在 + /// + private static void CheckFontDataFolderExist() + { + if (!Directory.Exists(FontDataFolderPath)) + { + Directory.CreateDirectory(FontDataFolderPath); + AssetDatabase.Refresh(); + } + } + } + [InitializeOnLoad] + /// + /// + /// + public class UnityUIEvent + { + static UnityUIEvent() + { + ObjectFactory.componentWasAdded += ComponentWasAdded; + } + + private static void ComponentWasAdded(Component obj) + { + Text text= obj.gameObject.GetComponent(); + if (text!=null) + { + text.font = ToolCacheManager.GetFont(); + } + } + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/EditorFont/DefaultFontEditor.cs.meta b/Assets/00.StaryEvo/Editor/EditorFont/DefaultFontEditor.cs.meta new file mode 100644 index 0000000..9104344 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/EditorFont/DefaultFontEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2e800f1227426ad4ea0fd607689bf25e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/EditorFont/FontData.cs b/Assets/00.StaryEvo/Editor/EditorFont/FontData.cs new file mode 100644 index 0000000..cf58686 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/EditorFont/FontData.cs @@ -0,0 +1,10 @@ +using UnityEngine; + +namespace Stary.Evo.Editor +{ + [System.Serializable] + public class FontData : ScriptableObject + { + [SerializeField] public Font defaultFont; + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/EditorFont/FontData.cs.meta b/Assets/00.StaryEvo/Editor/EditorFont/FontData.cs.meta new file mode 100644 index 0000000..4b1b257 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/EditorFont/FontData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 95cd4753d6d6804499cc0a96c91cdecc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/EditorFont/IFontChange.cs b/Assets/00.StaryEvo/Editor/EditorFont/IFontChange.cs new file mode 100644 index 0000000..cbfce73 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/EditorFont/IFontChange.cs @@ -0,0 +1,19 @@ +/**************************************************** + 文件:IFontChange.cs + 作者:zz + 邮箱: + 日期:2022/3/6 16:34:36 + 功能: +*****************************************************/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + interface IFontChange + { + void Creat(); + } +} diff --git a/Assets/00.StaryEvo/Editor/EditorFont/IFontChange.cs.meta b/Assets/00.StaryEvo/Editor/EditorFont/IFontChange.cs.meta new file mode 100644 index 0000000..6658acd --- /dev/null +++ b/Assets/00.StaryEvo/Editor/EditorFont/IFontChange.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 601a6ca5b11bb6c489a238de6bfb56d1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FixPanelScript.cs b/Assets/00.StaryEvo/Editor/FixPanelScript.cs new file mode 100644 index 0000000..3ea024f --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FixPanelScript.cs @@ -0,0 +1,444 @@ +/**************************************************** + 文件:FixPanelScript.cs + 作者:张铮 + 邮箱:834207172@qq.com + 日期:2022/3/3 17:53:52 + 功能: +*****************************************************/ + +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System.IO; +using System.Text; + +namespace Stary.Evo +{ + namespace AssetEditor + { + public enum Mode + { + 创建, + 以关键字更新, + 指定更新 + } + + enum RuleKey + { + Txt, + Btn, + Img + } + + public class FixPanelScript : EditorWindow + { + static Dictionary childrenNames; //对象子物体列表 + + static Dictionary Rules = new Dictionary() + { + { "Txt", "Text" }, { "Btn", "Button" }, { "Img", "Image" } + }; //命名规则 + + static Transform SelTran; //选择的对象 + static List names; //重名的子物体 + static List btnNames; //所有按钮 + TextAsset txt; //Fix选择的脚本 + private RuleKey ruleKey; + string input; //Fix规则 + private Mode mode; + static Dictionary FixChilderNames; //fix新加的子物体 + static List FixBtnNames; //fix新加的按钮 + + const string FixDef = "//FixStartDefiened"; + const string FixFind = "//FixStartFind"; + const string FixAddEvent = "//FixStartAddEvent"; + const string FixEvent = "//FixStartEvent"; + + private bool isHelp = false; + + [MenuItem("Evo/Utility/获取子对象")] + static void Fix() + { + FixPanelScript window = + GetWindow(true, "获取所有子对象"); + window.Show(); + } + + private void OnEnable() + { + isHelp = false; + } + + private void OnGUI() + { + mode = (Mode)GUILayout.Toolbar((int)mode, Enum.GetNames(typeof(Mode))); + switch (mode) + { + case Mode.创建: + Create(); + break; + case Mode.以关键字更新: + FixKeyUpdate(); + break; + case Mode.指定更新: + FixNameUpdate(); + break; + } + } + + public void Create() + { + EditorGUILayout.Space(10); + SelTran = EditorGUILayout.ObjectField("父物体", SelTran, typeof(Transform), true) as Transform; + EditorGUILayout.Space(10); + CreateButton("Create", CreateFile); + EditorGUILayout.Space(10); + } + + public void FixKeyUpdate() + { + EditorGUILayout.Space(10); + txt = EditorGUILayout.ObjectField("脚本", txt, typeof(TextAsset), true) as TextAsset; + EditorGUILayout.Space(10); + SelTran = EditorGUILayout.ObjectField("父物体", SelTran, typeof(Transform), true) as Transform; + EditorGUILayout.Space(10); + ruleKey = (RuleKey)EditorGUILayout.EnumPopup("选择关键字进行更新", ruleKey); + input = ruleKey.ToString(); + EditorGUILayout.Space(10); + CreateButton("FixKeyUpdate", FixScripts); + } + + + public void FixNameUpdate() + { + EditorGUILayout.Space(10); + txt = EditorGUILayout.ObjectField("脚本", txt, typeof(TextAsset), true) as TextAsset; + EditorGUILayout.Space(10); + SelTran = EditorGUILayout.ObjectField("父物体", SelTran, typeof(Transform), true) as Transform; + EditorGUILayout.Space(10); + input = EditorGUILayout.TextField("输入名字指定更新", input); + EditorGUILayout.Space(10); + CreateButton("FixNameUpdate", FixScripts); + } + + public void CreateButton(string name, Action action) + { + GUI.color = Color.green; + if (GUILayout.Button(name, GUILayout.MinWidth(200), GUILayout.MinHeight(50))) + { + isHelp = false; + action?.Invoke(); + } + + GUI.color = Color.white; + if (isHelp) + { + EditorGUILayout.HelpBox("未筛选到物体", MessageType.Warning); + } + } + + void FixScripts() + { + FixChilderNames = new Dictionary(); + FixBtnNames = new List(); + names = new List(); + string path = AssetDatabase.GetAssetPath(txt); //获取选定脚本的路径 + Debug.Log(path); + if (string.IsNullOrEmpty(input)) + { + Debug.LogError("Error!!!"); + return; + } + + GetChildren(SelTran, string.Empty, input); + + StreamReader sr = new StreamReader(path, Encoding.UTF8); + string msg = sr.ReadToEnd(); + FixDealScript(ref msg); + sr.Close(); + StreamWriter sw = new StreamWriter(path, false, Encoding.UTF8); + sw.Write(msg); + sw.Close(); + AssetDatabase.Refresh(); + Debug.Log("fix ok------"); + } + + + void FixDealScript(ref string msg) + { + StringBuilder sbDef = new StringBuilder(); + Debug.Log(FixChilderNames.Count); + foreach (KeyValuePair item in FixChilderNames) + { + Debug.Log(item.Key); + } + + var dic = FixChilderNames.GetEnumerator(); + while (dic.MoveNext()) + { + string[] names = dic.Current.Key.Split('/'); + string name = names[names.Length - 1]; + string value = dic.Current.Value; + if (!msg.Contains(name)) + { + sbDef.AppendFormat("\tprivate {0} {1};", value, name); + sbDef.AppendLine(); + } + } + + sbDef.AppendLine("\t" + FixDef); + Debug.Log(sbDef.ToString()); + + + StringBuilder sbFind = new StringBuilder(); + dic = FixChilderNames.GetEnumerator(); + while (dic.MoveNext()) + { + string[] names = dic.Current.Key.Split('/'); + string name = names[names.Length - 1]; + string value = dic.Current.Value; + string path = dic.Current.Key; + path = path.Substring(SelTran.name.Length + 1); + if (!msg.Contains(name)) + { + sbFind.AppendFormat("\t\t{0} = transform.Find<{2}>(\"{1}\");", name, path, value); + sbFind.AppendLine(); + } + + if (value == Rules["Btn"]) FixBtnNames.Add(name); + } + + sbFind.AppendLine("\t\t" + FixFind); + + StringBuilder sbAddEvent = new StringBuilder(); + for (int i = 0; i < FixBtnNames.Count; i++) + { + if (!msg.Contains(FixBtnNames[i])) + { + sbAddEvent.AppendFormat("\t\tEventTriggerListener.Get({0}.gameObject).onClick = BtnClicked;", + FixBtnNames[i]); + sbAddEvent.AppendLine(); + } + } + + sbAddEvent.AppendLine("\t\t" + FixAddEvent); + + StringBuilder sbEvent = new StringBuilder(); + for (int i = 0; i < FixBtnNames.Count; i++) + { + if (!msg.Contains(FixBtnNames[i])) + { + sbEvent.AppendFormat("\t\telse if({0}.gameObject==go)", FixBtnNames[i]); + CreatEvent(sbEvent, i); + } + } + + sbEvent.AppendLine("\t\t" + FixEvent); + Debug.Log(msg); + msg = msg.Replace(FixDef, sbDef.ToString()).Replace(FixFind, sbFind.ToString()) + .Replace(FixAddEvent, sbAddEvent.ToString()).Replace(FixEvent, sbEvent.ToString()); + Debug.Log(msg); + } + + void CreateFile() + { + childrenNames = new Dictionary(); + names = new List(); + btnNames = new List(); + GetChildren(SelTran); + CreateScript(Application.dataPath + "/" + SelTran.name.Replace(" ", "") + ".cs", + DealScript().ToString()); + } + + void GetChildren(Transform tran, string name = "", string rule = "") + { + if (string.IsNullOrEmpty(name)) name = tran.name; + int childNum = tran.childCount; + if (string.IsNullOrEmpty(rule)) //Create + { + Debug.Log(AddName(tran.name) + "进入1"); + string value = AddName(tran.name); + if (!string.IsNullOrEmpty(value)) + { + Debug.Log("进入" + tran.name); + childrenNames.Add(name, value); //符合规则,加入列表 + } + } + else //fix + { + string valuefix = AddName(tran.name, rule); + if (!string.IsNullOrEmpty(valuefix)) FixChilderNames.Add(name, valuefix); + } + + if (childNum == 0) + { + return; + } + else + { + string temp = name; + for (int i = 0; i < childNum; i++) + { + temp = name; + temp = temp + "/" + tran.GetChild(i).name; + GetChildren(tran.GetChild(i), temp, rule); + } + } + } + + /// + ///检测关键字是否包含返回字段 + /// + /// 新增的物体 + /// 关键字段 + /// + string AddName(string name, string rule = "") + { + if (names.Contains(name)) + { + Debug.LogError(name + "重名!!!!"); + } + + foreach (KeyValuePair item in Rules) + { + if (name.Contains(item.Key)) + { + if (string.IsNullOrEmpty(rule)) //Create + { + return item.Value; + } + else //fix + { + Debug.Log(item + "----------------"); + Debug.Log(name + "----------------" + rule); + + if (name.Contains(rule) && mode == Mode.以关键字更新) return item.Value; + else if (name.Equals(rule) && mode == Mode.指定更新) return item.Value; + else + { + isHelp = true; + } + } + } + } + + return string.Empty; + } + + + StringBuilder DealScript() + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine("using UnityEngine;"); + sb.AppendLine("using UnityEngine.UI;"); + sb.AppendLine("using System.Text;"); + sb.AppendLine("using WFramework;"); + sb.AppendLine(); + sb.AppendLine(); + + sb.AppendFormat("public class {0} : MonoBehaviour ", SelTran.name.Replace(" ", "")); + sb.AppendLine(); + sb.AppendLine("{"); + + var dic = childrenNames.GetEnumerator(); + while (dic.MoveNext()) + { + string[] names = dic.Current.Key.Split('/'); + string name = names[names.Length - 1]; + string value = dic.Current.Value; + sb.AppendFormat("\tprivate {0} {1};", value, name); + sb.AppendLine(); + } + + sb.AppendLine("\t" + FixDef); + + sb.AppendLine("\tvoid Awake() {"); + sb.AppendLine("\t\tInit();"); + sb.AppendLine("\t}"); + + sb.AppendLine(); + sb.AppendLine("\tvoid Init() {"); + sb.AppendLine(); + + dic = childrenNames.GetEnumerator(); + Debug.Log(childrenNames.Count); + while (dic.MoveNext()) + { + string[] names = dic.Current.Key.Split('/'); + string name = names[names.Length - 1]; + string value = dic.Current.Value; + string path = dic.Current.Key; + path = path.Substring(SelTran.name.Length + 1); + + + sb.AppendFormat("\t\t{0} =transform.Find<{2}>(\"{1}\");", name, path, value); + sb.AppendLine(); + if (value == Rules["Btn"]) btnNames.Add(name); + } + + sb.AppendLine("\t\t" + FixFind); + sb.AppendLine(); + + for (int i = 0; i < btnNames.Count; i++) + { + sb.AppendFormat("\t\tEventTriggerListener.Get({0}.gameObject).onClick = BtnClicked;", btnNames[i]); + sb.AppendLine(); + } + + sb.AppendLine("\t\t" + FixAddEvent); + sb.AppendLine(); + + sb.AppendLine("\t}"); + + sb.AppendLine(); + sb.AppendLine("\tvoid BtnClicked(GameObject go)"); + sb.AppendLine("\t{"); + for (int i = 0; i < btnNames.Count; i++) + { + if (i == 0) + { + sb.AppendFormat("\t\tif({0}.gameObject==go)", btnNames[i]); + } + else + { + sb.AppendFormat("\t\telse if({0}.gameObject==go)", btnNames[i]); + } + + CreatEvent(sb, i); + } + + sb.AppendLine("\t\t" + FixEvent); + sb.AppendLine("\t}"); + sb.AppendLine(); + sb.AppendLine("}"); + + return sb; + } + + /// + /// 创建方法里的Event + /// + /// + /// + private void CreatEvent(StringBuilder sb, int index = 0) + { + sb.AppendLine(); + sb.AppendLine("\t\t{"); + sb.AppendFormat("\t\t\tDebug.Log({0}+\"Clicked\");", btnNames[index]); + sb.AppendLine(); + sb.AppendLine("\t\t}"); + } + + void CreateScript(string path, string msg) + { + StreamWriter sw = new StreamWriter(path, false, Encoding.UTF8); + sw.Write(msg); + sw.Flush(); + sw.Close(); + Debug.Log("ok----------"); + AssetDatabase.Refresh(); + } + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FixPanelScript.cs.meta b/Assets/00.StaryEvo/Editor/FixPanelScript.cs.meta new file mode 100644 index 0000000..ade963f --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FixPanelScript.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6a023dc093dd405418446c92e00b05a3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor.meta new file mode 100644 index 0000000..f4177d2 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2c5e04b21f8f7d043aaa07c4cc6d146c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools.meta new file mode 100644 index 0000000..dbf409f --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 970f1a3c8d566a24492b32b7f48efde4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/DragAndDropTool.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/DragAndDropTool.meta new file mode 100644 index 0000000..9643a88 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/DragAndDropTool.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a232ea6e9816b4d4d9d694d8901e4f95 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/DragAndDropTool/DragAndDropTool.cs b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/DragAndDropTool/DragAndDropTool.cs new file mode 100644 index 0000000..6c04663 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/DragAndDropTool/DragAndDropTool.cs @@ -0,0 +1,71 @@ +using System; +using UnityEditor; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace Stary.Evo.Editor +{ + public static class DragAndDropTool + { + public class DragInfo + { + public bool Dragging; + public bool EnterArea; + public bool Complete; + public Object[] ObjectReferences => DragAndDrop.objectReferences; + public string[] Paths => DragAndDrop.paths; + public DragAndDropVisualMode VisualMode => DragAndDrop.visualMode; + public int ActiveControlID => DragAndDrop.activeControlID; + } + + private static DragInfo mDragInfo = new DragInfo(); + + private static bool mDragging;//拖拽进区域为ture + private static bool mEnterArea;//拖拽进content区域为ture + private static bool mComplete; + /// + /// 拖拽通用方法 + /// + /// 检测区域 + /// 完成后的时间,利用泛型传进详细的DragInfo + /// + public static void Drag(Rect content,Action onComplete=null, DragAndDropVisualMode mode = DragAndDropVisualMode.Generic) + { + + Event e=Event.current; + if (e.type == EventType.DragUpdated) + { + mComplete = false; + mDragging = true; + mEnterArea = content.Contains(e.mousePosition); + if (mEnterArea) + { + DragAndDrop.visualMode = DragAndDropVisualMode.Generic; + e.Use(); + } + } + else if (e.type == EventType.DragPerform) + { + mComplete = true; + mDragging = false; + mEnterArea = content.Contains(e.mousePosition); + DragAndDrop.AcceptDrag(); + e.Use(); + } + else if (e.type == EventType.DragExited) + { + mComplete = true; + mDragging = false; + mEnterArea = content.Contains(e.mousePosition); + } + + mDragInfo.Complete = mComplete && e.type == EventType.Used; + mDragInfo.EnterArea = mEnterArea; + mDragInfo.Dragging = mDragging; + if (mDragInfo.EnterArea && mDragInfo.Complete && !mDragInfo.Dragging) + { + onComplete?.Invoke(mDragInfo); + } + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/DragAndDropTool/DragAndDropTool.cs.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/DragAndDropTool/DragAndDropTool.cs.meta new file mode 100644 index 0000000..d93216c --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/DragAndDropTool/DragAndDropTool.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5a676d8ce2e354573ae2984b51cff3b4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/EditorWindowLayout.cs b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/EditorWindowLayout.cs new file mode 100644 index 0000000..9cf67a9 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/EditorWindowLayout.cs @@ -0,0 +1,31 @@ +/**************************************************** + 文件:EditorWindowLayout.cs + 作者:张铮 + 邮箱:834207172@qq.com + 日期:2022/3/3 17:53:52 + 功能: +*****************************************************/ +using UnityEditor; +using UnityEngine; +namespace Stary.Evo.Editor +{ + public class EditorWindowLayout : UnoEditorLayout + { + public EditorWindowLayout(EditorWindow win) + { + _win = win; + Margin = new Vector4(2, 2, 2, 2); + IndentSize = 12; + } + + private readonly EditorWindow _win; + + public Vector4 Margin { get; set; } + + public void Begin() + { + var rect = new Rect(Margin.x, Margin.y, _win.position.width - Margin.x - Margin.z, _win.position.height - Margin.y - Margin.w); + Begin(rect); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/EditorWindowLayout.cs.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/EditorWindowLayout.cs.meta new file mode 100644 index 0000000..5b0ba34 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/EditorWindowLayout.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a7321934936ed334d81018ca35edf12e +timeCreated: 1511574046 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField.meta new file mode 100644 index 0000000..db2e3bd --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 807050751fc48ec498b43b37bf3d883f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/FolderField.cs b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/FolderField.cs new file mode 100644 index 0000000..432fa08 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/FolderField.cs @@ -0,0 +1,68 @@ +using UnityEditor; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + public class FolderField : GUIBase + { + public FolderField(string path = "Assets/", string folder = "Assets", string title = "Select Folder", + string defaultName = "") + { + mPath = path; + Title = title; + Folder = folder; + DefaultName = defaultName; + } + + protected string mPath; + + + public string Path => mPath; + public string Title; + public string Folder; + public string DefaultName; + + public void SetPath(string path) + { + mPath = path; + } + + public override void OnGUI(Rect position) + { + base.OnGUI(position); + + var rects = position.VerticalSplit(position.width - 30); + var leftRect = rects[0]; + var rightRect = rects[1]; + + var currentGUIEnabled = GUI.enabled; + GUI.enabled = false; + EditorGUI.TextField(leftRect, mPath); // 左边的 rect width - 30 + GUI.enabled = currentGUIEnabled; + + if (GUI.Button(rightRect,GUIContents.Folder)) // 右边的 rect 30 + { + var path = EditorUtility.OpenFolderPanel(Title, Folder, DefaultName); + + if (!string.IsNullOrEmpty(path) && path.IsDirectory()) + { + mPath = path.ToAssetsPath()+"/"; + } + } + + DragAndDropTool.Drag(leftRect, OnComplete); + + } + private void OnComplete(DragAndDropTool.DragInfo info) + { + if (info.Paths[0].IsDirectory()) + { + mPath = info.Paths[0]+"/"; + } + } + protected override void OnDispose() + { + + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/FolderField.cs.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/FolderField.cs.meta new file mode 100644 index 0000000..a3c8c89 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/FolderField.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 40b6b51b847f2bd41a6547694b94611f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIBase.cs b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIBase.cs new file mode 100644 index 0000000..f85d59c --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIBase.cs @@ -0,0 +1,24 @@ +using System; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + public abstract class GUIBase :IDisposable + { + public bool mDisposed { get; protected set; } + public Rect mPosition { get; protected set; } + + public virtual void OnGUI(Rect position) + { + mPosition = position; + } + public void Dispose() + { + if(mDisposed) return; + OnDispose(); + mDisposed = true; + } + + protected abstract void OnDispose(); + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIBase.cs.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIBase.cs.meta new file mode 100644 index 0000000..edf8201 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0bfad764209a8ea469e5934f7cfae937 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIContents.cs b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIContents.cs new file mode 100644 index 0000000..4a9d22d --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIContents.cs @@ -0,0 +1,12 @@ +using UnityEditor; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + public class GUIContents + { + public static GUIContent Folder = EditorGUIUtility.IconContent("Folder Icon"); + public static GUIContent FolderEmpty = EditorGUIUtility.IconContent("FolderEmpty Icon"); + // 等等 + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIContents.cs.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIContents.cs.meta new file mode 100644 index 0000000..6263db9 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/FolderField/GUIContents.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 314d1168ba299ae488188c679eabf657 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/RectExtension.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/RectExtension.meta new file mode 100644 index 0000000..a103ae9 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/RectExtension.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0a3caea4dd7e911429081fb9c65e995c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/RectExtension/RectExtension.cs b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/RectExtension/RectExtension.cs new file mode 100644 index 0000000..82be643 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/RectExtension/RectExtension.cs @@ -0,0 +1,123 @@ +using UnityEngine; + +namespace Stary.Evo.Editor +{ + public enum AnchorType + { + UpperLeft = 0, + UpperCenter = 1, + UpperRight = 2, + MiddleLeft = 3, + MiddleCenter = 4, + MiddleRight = 5, + LowerLeft = 6, + LowerCenter = 7, + LowerRight = 8 + } + + public static class RectExtension + { + /// + ///根据外层窗口缩放 + /// + /// + /// 描点位置 + /// 缩放大小 + /// + public static Rect Zoom(this Rect rect, AnchorType type, float pixel) + { + return Zoom(rect, type, new Vector2(pixel, pixel)); + } + + public static Rect Zoom(this Rect rect, AnchorType type, Vector2 pixelOffset) + { + float tempW = rect.width + pixelOffset.x; + float tempH = rect.height + pixelOffset.y; + switch (type) + { + case AnchorType.UpperLeft: + break; + case AnchorType.UpperCenter: + rect.x -= (tempW - rect.width) / 2; + break; + case AnchorType.UpperRight: + rect.x -= tempW - rect.width; + break; + case AnchorType.MiddleLeft: + rect.y -= (tempH - rect.height) / 2; + break; + case AnchorType.MiddleCenter: + rect.x -= (tempW - rect.width) / 2; + rect.y -= (tempH - rect.height) / 2; + break; + case AnchorType.MiddleRight: + rect.y -= (tempH - rect.height) / 2; + rect.x -= tempW - rect.width; + break; + case AnchorType.LowerLeft: + rect.y -= tempH - rect.height; + break; + case AnchorType.LowerCenter: + rect.y -= tempH - rect.height; + rect.x -= (tempW - rect.width) / 2; + break; + case AnchorType.LowerRight: + rect.y -= tempH - rect.height; + rect.x -= tempW - rect.width; + break; + } + + rect.width = tempW; + rect.height = tempH; + return rect; + } + + + public static Rect MoveDown(this Rect r, float pixels = 1) + { + r.y += pixels; + return r; + } + + public static Rect CutRight(this Rect r, float pixels) + { + r.xMax -= pixels; + return r; + } + + public static Rect CutLeft(this Rect r, float pixels) + { + r.xMin += pixels; + return r; + } + + public static Rect Cut(this Rect r, float pixels) + { + return r.Margin(-pixels); + } + + public static Rect Margin(this Rect r, float pixels) + { + r.xMax += pixels; + r.xMin -= pixels; + r.yMax += pixels; + r.yMin -= pixels; + return r; + } + + public static Rect[] VerticalSplit(this Rect r, float width, float padding = 0, bool justMid = true) + { + if (justMid) + return new Rect[2] + { + r.CutRight((int) (r.width - width)).CutRight(padding).CutRight(-Mathf.CeilToInt(padding / 2f)), + r.CutLeft(width).CutLeft(padding).CutLeft(-Mathf.FloorToInt(padding / 2f)) + }; + return new Rect[2] + { + r.CutRight((int) (r.width - width)).Cut(padding).CutRight(-Mathf.CeilToInt(padding / 2f)), + r.CutLeft(width).Cut(padding).CutLeft(-Mathf.FloorToInt(padding / 2f)) + }; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/RectExtension/RectExtension.cs.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/RectExtension/RectExtension.cs.meta new file mode 100644 index 0000000..28d0891 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/RectExtension/RectExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 38c8aee9816a74cb4ae2151017cfe040 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/ScriptBuilder.cs b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/ScriptBuilder.cs new file mode 100644 index 0000000..113dbf3 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/ScriptBuilder.cs @@ -0,0 +1,73 @@ +/**************************************************** + 文件:EditorWindowLayout.cs + 作者:张铮 + 邮箱:834207172@qq.com + 日期:2022/3/3 17:53:52 + 功能: +*****************************************************/ +using System; +using System.Text; +namespace Stary.Evo.Editor +{ + public class ScriptBuilder + { + private readonly string NEW_LINE = Environment.NewLine; + + public ScriptBuilder() + { + builder = new StringBuilder(); + } + + private StringBuilder builder; + public int Indent { get; set; } + + private int currentCharIndex; + + public void Write(string val, bool noAutoIndent = false) + { + if (!noAutoIndent) + val = GetIndents() + val; + if (currentCharIndex == builder.Length) + builder.Append(val); + else + builder.Insert(currentCharIndex, val); + currentCharIndex += val.Length; + } + + public void WriteLine(string val, bool noAutoIndent = false) + { + Write(val + NEW_LINE); + } + + public int WriteCurlyBrackets(bool increaseIndent = false) + { + var openBracket = GetIndents() + "{" + NEW_LINE; + var closeBracket = GetIndents() + "}" + NEW_LINE; + Write(openBracket + closeBracket, true); + currentCharIndex -= closeBracket.Length; + if(increaseIndent) + Indent++; + return closeBracket.Length; + } + + public void GetOutOfCurlyBrackets(int lastCurlyBracketSize, bool decreaseIndent = false) + { + currentCharIndex += lastCurlyBracketSize; + if (decreaseIndent) + Indent--; + } + + public string GetIndents() + { + var str = ""; + for (var i = 0; i < Indent; i++) + str += " "; + return str; + } + + public override string ToString() + { + return builder.ToString(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/ScriptBuilder.cs.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/ScriptBuilder.cs.meta new file mode 100644 index 0000000..46c9855 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/ScriptBuilder.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4a700812e31c5d849b411e1d044687ef +timeCreated: 1582186171 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/StringExtension.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/StringExtension.meta new file mode 100644 index 0000000..f5b8171 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/StringExtension.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cbc5b07d3d5937e4698c9518edf90bc7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/StringExtension/StringExtension.cs b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/StringExtension/StringExtension.cs new file mode 100644 index 0000000..d948df0 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/StringExtension/StringExtension.cs @@ -0,0 +1,30 @@ +using System.IO; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + public static class StringExtension + { + /// + /// 是否是一个文件夹 + /// + /// + /// + public static bool IsDirectory(this string self) + { + var fileInfo = new FileInfo(self); + if ((fileInfo.Attributes & FileAttributes.Directory) != 0) + { + return true; + } + + return false; + } + public static string ToAssetsPath(this string self) + { + var assetsFullPath = Path.GetFullPath(Application.dataPath); + + return "Assets" + Path.GetFullPath(self).Substring(assetsFullPath.Length).Replace("\\", "/"); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/StringExtension/StringExtension.cs.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/StringExtension/StringExtension.cs.meta new file mode 100644 index 0000000..f930ed8 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/StringExtension/StringExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: abbb0ff31d684ebfb0b17b80691110af +timeCreated: 1635478967 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UnoEditorLayout.cs b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UnoEditorLayout.cs new file mode 100644 index 0000000..a7f25d4 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UnoEditorLayout.cs @@ -0,0 +1,448 @@ +/**************************************************** + 文件:UnoEditorLayout.cs + 作者:张铮 + 邮箱:834207172@qq.com + 日期:2022/3/3 17:53:52 + 功能: +*****************************************************/ +using UnityEditor; +using UnityEngine; +using System; +namespace Stary.Evo.Editor +{ + public class UnoEditorLayout + { + public float LineSpacing = 2; + public int IndentCount { get; set; } + public float IndentSize = 15; + + private float _originX; + + private Rect _rootRect; + + public Rect RootRect + { + get + { + var rect = new Rect(_rootRect); + rect.x = _originX + IndentSize * IndentCount; + return rect; + } + } + + public void Begin(Rect rect) + { + IndentCount = 0; + _rootRect = rect; + _originX = _rootRect.x; + } + + /// + /// 移至新的一行 + /// + /// + /// 返回前一行的Rect + public Rect NextLine(float height = 0, float lineSpacing = -1) + { + if (height <= 0) + height = EditorGUIUtility.singleLineHeight; + if (lineSpacing < 0) + lineSpacing = LineSpacing; + var rect = new Rect(RootRect); + rect.height = height; + var delta = height + lineSpacing; + _rootRect.y += delta; + _rootRect.height -= delta; + return rect; + } + + public Rect SingleLine(float height = 0f) + { + return CreateRow(new[] { LayoutDef.Any() }, height)[0]; + } + + public Rect[] CreateRow(LayoutDef[] lDefs, float height = 0f, float gap = 4f, Rect? rect = null, Rect[] result = null) + { + if (height <= 0) + height = EditorGUIUtility.singleLineHeight; + return CreateRects(lDefs, false, height, gap, rect, result); + } + + public static Rect[] CreateRow(LayoutDef[] lDefs, Rect rect, float height = 0f, float gap = 4f, Rect[] result = null) + { + return CreateRects(lDefs, rect, false, height, gap, result); + } + + public Rect[] CreateColum(LayoutDef[] lDefs, float width = 0f, float gap = 4f, Rect? rect = null, Rect[] result = null) + { + return CreateRects(lDefs, true, width, gap, rect, result); + } + + public static Rect[] CreateColum(LayoutDef[] lDefs, Rect rect, float width = 0f, float gap = 4f, Rect[] result = null) + { + return CreateRects(lDefs, rect, true, width, gap, result); + } + + private Rect[] CreateRects(LayoutDef[] lDefs, bool isVertical, float otherEdgeLength = 0f, float gap = 4, Rect? rect = null, Rect[] result = null) + { + rect = rect ?? RootRect; + return CreateRects(lDefs, rect.Value, isVertical, otherEdgeLength, gap, result); + } + + public static Rect[] CreateRects(LayoutDef[] lDefs, Rect r, bool isVertical, float otherEdgeLength = 0f, float gap = 4, Rect[] result = null) + { + if (result != null && result.Length != lDefs.Length) + throw new ArgumentException("the length of result does not match to length of lDefs"); + if (otherEdgeLength <= 0) + { + if (isVertical) + otherEdgeLength = r.width; + else + otherEdgeLength = r.height; + } + + var totalSpace = isVertical ? r.height : r.width; + var spaceLeft = totalSpace; + var currentPos = isVertical ? r.y : r.x; + var anyCount = lDefs.Length; + result = result ?? new Rect[lDefs.Length]; + for (var i = 0; i < lDefs.Length; i++) + { + var ld = lDefs[i]; + float val = 0; + if (!ld.IsAny) + { + val = ld.RatioWise ? GetPercentageVal(ld, totalSpace, lDefs.Length, gap) : ld.Value; + val = ClampValueFromVector2(val, ld.MinSize, ld.MaxSize, isVertical); + spaceLeft -= val; + anyCount--; + } + else if (ld.Value > 0) + { + val = ld.Value + gap; + spaceLeft -= val; + anyCount--; + } + + if (isVertical) + { + result[i].height = val; + result[i].width = otherEdgeLength; + result[i].x = r.x; + } + else + { + result[i].width = val; + result[i].height = otherEdgeLength; + result[i].y = r.y; + } + + spaceLeft -= gap; + } + + spaceLeft += gap; + + var anySize = spaceLeft / anyCount; + for (var i = 0; i < lDefs.Length; i++) + { + var ld = lDefs[i]; + if (!ld.IsAny || !ld.MinSize.HasValue) + continue; + var size = 0f; + var minSize = isVertical ? ld.MinSize.Value.y : ld.MinSize.Value.x; + if (anySize < minSize) + size = minSize; + if (size <= 0) + continue; + + anyCount--; + spaceLeft -= size; + lDefs[i].Value = size; + if (isVertical) + result[i].height = size; + else + result[i].width = size; + } + + anySize = spaceLeft / anyCount; + + for (var i = 0; i < lDefs.Length; i++) + { + var ld = lDefs[i]; + if (!ld.IsAny || !ld.MaxSize.HasValue) + continue; + var size = 0f; + + var maxSize = isVertical ? ld.MaxSize.Value.y : ld.MaxSize.Value.x; + if (anySize > maxSize) + size = maxSize; + + if (size <= 0) + continue; + + anyCount--; + spaceLeft -= size; + lDefs[i].Value = size; + if (isVertical) + result[i].height = size; + else + result[i].width = size; + } + + anySize = spaceLeft / anyCount; + for (var i = 0; i < lDefs.Length; i++) + { + var ld = lDefs[i]; + float val; + if (isVertical) + { + if (ld.IsAny) + { + result[i].height = anySize; + val = anySize; + } + else + val = result[i].height; + + result[i].y = currentPos; + } + else + { + if (ld.IsAny) + { + result[i].width = anySize; + val = anySize; + } + else + val = result[i].width; + + result[i].x = currentPos; + } + + currentPos += val + gap; + //Debug.Log(result[i].x + ", " + result[i].width); + } + + return result; + } + + public Rect[][] CreateGrid(LayoutDef[] hlDefs, LayoutDef[] vlDefs, float gap = 4, Rect? rect = null) + { + rect = rect ?? RootRect; + return CreateGrid(hlDefs, vlDefs, rect.Value, gap); + } + + public static Rect[][] CreateGrid(LayoutDef[] hlDefs, LayoutDef[] vlDefs, Rect rect, float gap = 4) + { + var result = new Rect[vlDefs.Length][]; + var row = CreateRects(hlDefs, rect, false, 0, gap); + result[0] = row; + for (var i = 1; i < vlDefs.Length; i++) + { + result[i] = new Rect[row.Length]; + for (var j = 0; j < row.Length; j++) + { + result[i][j] = row[j]; + } + } + + var col = CreateRects(vlDefs, rect, true, 0, gap); + for (var i = 0; i < vlDefs.Length; i++) + { + for (var j = 0; j < result[i].Length; j++) + { + result[i][j].height = col[i].height; + result[i][j].y = col[i].y; + } + } + + return result; + } + + /// + /// + /// + /// + /// + /// + /// + /// result[i] represents a row + public Rect[][] CreateGridUnevenColum(LayoutDef[][] hlDefs, LayoutDef[] vlDefs, float gap = 4, Rect? rect = null) + { + rect = rect ?? RootRect; + + return CreateGridUnevenColum(hlDefs, vlDefs, rect.Value, gap); + } + + /// + /// + /// + /// + /// + /// + /// + /// result[i] represents a row + public static Rect[][] CreateGridUnevenColum(LayoutDef[][] hlDefs, LayoutDef[] vlDefs, Rect rect, float gap = 4) + { + if (hlDefs.Length != vlDefs.Length) + throw new ArgumentException("the length of hlDefs must match with the length of vlDefs"); + + var result = new Rect[vlDefs.Length][]; + for (var i = 0; i < vlDefs.Length; i++) + { + result[i] = CreateRects(hlDefs[i], rect, false, 0, gap); + } + + var col = CreateRects(vlDefs, rect, true, 0, gap); + for (var i = 0; i < vlDefs.Length; i++) + { + var row = result[i]; + for (var j = 0; j < row.Length; j++) + { + row[j].height = col[i].height; + row[j].y = col[i].y; + } + } + + return result; + } + + /// + /// + /// + /// + /// + /// + /// + /// result[i] represents a colum + public Rect[][] CreateGridUnevenRow(LayoutDef[] hlDefs, LayoutDef[][] vlDefs, float gap = 4, Rect? rect = null) + { + rect = rect ?? RootRect; + return CreateGridUnevenRow(hlDefs, vlDefs, rect.Value, gap); + } + + /// + /// + /// + /// + /// + /// + /// + /// result[i] represents a colum + public static Rect[][] CreateGridUnevenRow(LayoutDef[] hlDefs, LayoutDef[][] vlDefs, Rect rect, float gap = 4) + { + if (hlDefs.Length != vlDefs.Length) + throw new ArgumentException("the length of hlDefs must match with the length of vlDefs"); + var result = new Rect[vlDefs.Length][]; + for (var i = 0; i < vlDefs.Length; i++) + { + result[i] = CreateRects(vlDefs[i], rect, true, 0, gap); + } + + var row = CreateRects(hlDefs, rect, false, 0, gap); + for (var i = 0; i < row.Length; i++) + { + for (var j = 0; j < result[i].Length; j++) + { + result[i][j].width = row[i].width; + result[i][j].x = row[i].x; + } + } + + return result; + } + + public static Vector2 EvaluateTextSize(GUIContent text, GUIStyle guiStyle = null) + { + if (guiStyle == null) + guiStyle = EditorStyles.label; + + return guiStyle.CalcSize(text); + } + + public static Vector2 EvaluateTextSize(string text, GUIStyle guiStyle = null) + { + return EvaluateTextSize(new GUIContent(text), guiStyle); + } + + private static float ClampValueFromVector2(float val, Vector2? min, Vector2? max, bool byY) + { + if (byY) + { + return Mathf.Clamp(val, + min.HasValue ? min.Value.y : float.MinValue, + max.HasValue ? max.Value.y : float.MaxValue); + } + else + { + return Mathf.Clamp(val, + min.HasValue ? min.Value.x : float.MinValue, + max.HasValue ? max.Value.x : float.MaxValue); + } + } + + private static float GetPercentageVal(LayoutDef ld, float totalSpace, int numChildren, float gap) + { + return (totalSpace - (numChildren - 1) * gap) * ld.Value * .01f; + } + } + + public struct LayoutDef + { + public static LayoutDef Any() + { + return new LayoutDef(); + } + + public static LayoutDef Val(float value) + { + return new LayoutDef { Value = value }; + } + + public static LayoutDef Percentage(float percentage) + { + return new LayoutDef { Value = percentage, RatioWise = true }; + } + + public static LayoutDef[] EquallyDivide(int num) + { + var arr = new LayoutDef[num]; + //default(LayoutDef) == LayoutDef.Any() + return arr; + } + + public float Value { get; set; } + public bool RatioWise { get; set; } + public Vector2? MinSize { get; private set; } + public Vector2? MaxSize { get; private set; } + + public LayoutDef WithMinSize(Vector2 minSize) + { + MinSize = minSize; + return this; + } + + public LayoutDef WithMaxSize(Vector2 maxSize) + { + MaxSize = maxSize; + return this; + } + + public LayoutDef WithMinSize(float x, float y) + { + MinSize = new Vector2(x, y); + return this; + } + + public LayoutDef WithMaxSize(float x, float y) + { + MaxSize = new Vector2(x, y); + return this; + } + + public bool IsAny + { + get { return Value == 0; } + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UnoEditorLayout.cs.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UnoEditorLayout.cs.meta new file mode 100644 index 0000000..59e0259 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UnoEditorLayout.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6fa325b0a38cdb84bb0d9125492a3211 +timeCreated: 1597995623 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UtilityEditor.cs b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UtilityEditor.cs new file mode 100644 index 0000000..1962dfc --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UtilityEditor.cs @@ -0,0 +1,292 @@ +/**************************************************** + 文件:UtilityEditor.cs + 作者:张铮 + 邮箱:834207172@qq.com + 日期:2022/3/3 17:53:52 + 功能: +*****************************************************/ +using UnityEngine; +using UnityEditor; +using System.IO; +using System.Collections.Generic; +namespace Stary.Evo.Editor +{ + public class UtilityEditor + { + + [MenuItem("Evo/Utility/优化/检查模型/一键压缩模型的mesh")] + static void 一键压缩所有模型的mesh() + { + AssetDatabase.StartAssetEditing(); + int count = 0; + foreach (var guid in AssetDatabase.FindAssets("t:Model")) + { + var assetPath = AssetDatabase.GUIDToAssetPath(guid); + var textureImporter = AssetImporter.GetAtPath(assetPath) as ModelImporter; + if (textureImporter == null) + continue; + if (textureImporter.meshCompression != ModelImporterMeshCompression.Off) + { + textureImporter.meshCompression = ModelImporterMeshCompression.Off; + textureImporter.SaveAndReimport(); + count++; + } + } + Debug.Log("压缩了:" + count + "个模型"); + AssetDatabase.StopAssetEditing(); + AssetDatabase.Refresh(); + } + + [MenuItem("Evo/Utility/优化/检查模型/选择文件夹压缩模型mesh")] + static void 选择文件夹压缩模型mesh() + { + if (Selection.objects.Length != 1) + { + Debug.LogError("选择一个文件夹"); + return; + } + + string path = AssetDatabase.GetAssetPath(Selection.objects[0]); + if (!Directory.Exists(path)) + { + Debug.Log(path); + return; + } + + AssetDatabase.StartAssetEditing(); + int count = 0; + string[] filePath = GetFilePath(Selection.objects); + foreach (var guid in AssetDatabase.FindAssets("t:Model", filePath)) + { + + var assetPath = AssetDatabase.GUIDToAssetPath(guid); + var textureImporter = AssetImporter.GetAtPath(assetPath) as ModelImporter; + if (textureImporter == null) + continue; + if (textureImporter.meshCompression != ModelImporterMeshCompression.Off) + { + Debug.Log(assetPath); + textureImporter.meshCompression = ModelImporterMeshCompression.Off; + textureImporter.SaveAndReimport(); + count++; + } + } + + Debug.Log("处理了:" + count + "个模型"); + AssetDatabase.StopAssetEditing(); + AssetDatabase.Refresh(); + } + + [MenuItem("Evo/Utility/优化/检查模型/去除文件夹内模型的ReadWrite")] + static void 去除文件夹内模型的ReadWrite() + { + if (Selection.objects.Length != 1) + { + Debug.LogError("选择一个文件夹"); + return; + } + + string path = AssetDatabase.GetAssetPath(Selection.objects[0]); + if (!Directory.Exists(path)) + { + Debug.Log(path); + return; + } + + AssetDatabase.StartAssetEditing(); + int count = 0; + string[] filePath = GetFilePath(Selection.objects); + foreach (var guid in AssetDatabase.FindAssets("t:Model", filePath)) + { + var assetPath = AssetDatabase.GUIDToAssetPath(guid); + var textureImporter = AssetImporter.GetAtPath(assetPath) as ModelImporter; + if (textureImporter == null) + continue; + if (textureImporter.isReadable) + { + Debug.Log(assetPath); + textureImporter.isReadable = false; + textureImporter.SaveAndReimport(); + count++; + } + } + + Debug.Log("处理了:" + count + "个模型"); + AssetDatabase.StopAssetEditing(); + AssetDatabase.Refresh(); + } + + public static string[] GetFilePath(Object[] targets) + { + var folders = new List(); + for (int i = 0; i < targets.Length; i++) + { + string assetPath = AssetDatabase.GetAssetPath(targets[i]); + if (Directory.Exists(assetPath)) + folders.Add(assetPath); + } + + return folders.ToArray(); + } + + [MenuItem("Evo/Utility/优化/检查模型/一键压缩模型的动画为Optimal")] + static void 一键压缩模型的动画() + { + AssetDatabase.StartAssetEditing(); + int count = 0; + foreach (var guid in AssetDatabase.FindAssets("t:Model")) + { + var assetPath = AssetDatabase.GUIDToAssetPath(guid); + var textureImporter = AssetImporter.GetAtPath(assetPath) as ModelImporter; + if (textureImporter == null) + continue; + if (textureImporter.animationCompression != ModelImporterAnimationCompression.Optimal) + { + Debug.Log(assetPath); + textureImporter.animationCompression = ModelImporterAnimationCompression.Optimal; + textureImporter.SaveAndReimport(); + count++; + } + } + + Debug.Log("处理了:" + count + "个模型"); + AssetDatabase.StopAssetEditing(); + AssetDatabase.Refresh(); + } + + [MenuItem("Evo/Utility/优化/检查图片/去除文件夹内图片的ReadWrite")] + static void 去除文件夹内图片的ReadWrite() + { + if (Selection.objects.Length != 1) + { + Debug.LogError("选择一个文件夹"); + return; + } + + string path = AssetDatabase.GetAssetPath(Selection.objects[0]); + if (!Directory.Exists(path)) + { + Debug.Log(path); + return; + } + + AssetDatabase.StartAssetEditing(); + int count = 0; + string[] filePath = GetFilePath(Selection.objects); + foreach (var guid in AssetDatabase.FindAssets("t:Texture", filePath)) + { + var assetPath = AssetDatabase.GUIDToAssetPath(guid); + var textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; + if (textureImporter == null) + continue; + if (textureImporter.isReadable) + { + Debug.Log(assetPath); + textureImporter.isReadable = false; + textureImporter.SaveAndReimport(); + count++; + } + } + + Debug.Log("处理了:" + count + "个图片"); + AssetDatabase.StopAssetEditing(); + AssetDatabase.Refresh(); + } + + [MenuItem("Evo/Utility/优化/检查图片/去除文件夹内图片的mipmap")] + static void 去除文件夹内图片的mipmap() + { + if (Selection.objects.Length != 1) + { + Debug.LogError("选择一个文件夹"); + return; + } + + string path = AssetDatabase.GetAssetPath(Selection.objects[0]); + if (!Directory.Exists(path)) + { + Debug.Log(path); + return; + } + + AssetDatabase.StartAssetEditing(); + int count = 0; + string[] filePath = GetFilePath(Selection.objects); + foreach (var guid in AssetDatabase.FindAssets("t:Texture", filePath)) + { + var assetPath = AssetDatabase.GUIDToAssetPath(guid); + var textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; + if (textureImporter == null) + continue; + if (textureImporter.mipmapEnabled) + { + Debug.Log(assetPath); + textureImporter.mipmapEnabled = false; + textureImporter.SaveAndReimport(); + count++; + } + } + + Debug.Log("处理了:" + count + "个图片"); + AssetDatabase.StopAssetEditing(); + AssetDatabase.Refresh(); + } + private static void DeleteEmptyDirectory(DirectoryInfo directory) + { + DirectoryInfo[] childDirectory = directory.GetDirectories(); + + if (childDirectory.Length > 0) + { + for (int i = 0; i < childDirectory.Length; i++) + { + DeleteEmptyDirectory(childDirectory[i]); + } + } + + if (directory.GetFileSystemInfos().Length == 0) + { + string path = directory.FullName; + int index = path.IndexOf("Assets"); + path = path.Remove(0, index); + directory.Delete(); + } + } + + /// + /// 打开文件夹 + /// + /// + public static void OpenDirectory(string path) + { +#if UNITY_EDITOR + if (string.IsNullOrEmpty(path)) return; + path = path.Replace("/", "\\"); + if (!Directory.Exists(path)) + { + Debug.LogError("No Directory: " + path); + return; + } + + System.Diagnostics.Process.Start("explorer.exe", path); +#endif + } + + /// + /// 获取文件夹下所有文件路径 + /// + /// + /// "*.mp3" + /// + public static string[] GetFiles(string path, string extension = "*") + { + if (File.Exists(path)) + { + return Directory.GetFiles(path, extension, SearchOption.AllDirectories); + } + else + { + return null; + } + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UtilityEditor.cs.meta b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UtilityEditor.cs.meta new file mode 100644 index 0000000..12f3a99 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/FrameWorkEditor/Tools/UtilityEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 58460c25029e7b84c87ff61ae21746a1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/MarkAdressable.meta b/Assets/00.StaryEvo/Editor/MarkAdressable.meta new file mode 100644 index 0000000..c2bfbe6 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/MarkAdressable.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 10ee8c5ac230cb44eaee119b39fde575 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/MarkAdressable/MarkAdressable.cs b/Assets/00.StaryEvo/Editor/MarkAdressable/MarkAdressable.cs new file mode 100644 index 0000000..aa9bd92 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/MarkAdressable/MarkAdressable.cs @@ -0,0 +1,560 @@ +using System; +using System.Collections.Generic; +using System.IO; +using HybridCLR.Editor; +using HybridCLR.Editor.Commands; +using UnityEditor; +using UnityEditor.U2D; +using UnityEngine; +using UnityEngine.U2D; +using YooAsset.Editor; + +namespace Stary.Evo.Editor +{ + public class MarkAdressable : MonoBehaviour + { + private static AssetBundleCollectorPackage package; + private static string packageName; + + private static string[] configNames = new[] { "DomainConfig" }; + + + public static string DomainRoot + { + get { return Application.dataPath + "/Domain"; } + } + // public static string AtlasRemotedRoot + // { + // get { return Application.dataPath + "/AddressableRes/Sprites"; } + // } + // + // public static string SpriteRemotedAtlas + // { + // get { return Application.dataPath + "/AddressableRes/SpriteAtlas"; } + // } + + + //[MenuItem("Evo/Hotfix/BuildAll")] + public static void BuildAll() + { + PrebuildCommand.GenerateAll(); + Debug.Log("UnityEvo:Build【GenerateAll】完成"); + AddHotfixAddressableDll(); + Debug.Log("UnityEvo:Build【CopyHotfixAddressableDll】完成"); + AddMark(); + Debug.Log("UnityEvo:Build【MarkAsset】完成"); + } + + + //[MenuItem("Evo/Hotfix/Addressable")] + public static void AddHotfixAddressableDll() + { + CopyDllHotUpdateAssembly(BuildAssetWindow.GetBuildPackageName(), $"{DomainRoot}/{BuildAssetWindow.GetBuildPackageName()}/AddressableRes"); + CopyDllStrippedAOTDllOutputRootDir($"{DomainRoot}/{BuildAssetWindow.GetBuildPackageName()}/AddressableRes"); + + + //EditorUtility.DisplayDialog("自动标记", "自动Hotfix成功", "确定"); + } + + private static void CopyDllHotUpdateAssembly(string domain, string target) + { + //读取打包dll位置 + string hotUpdateDir = + $"{SettingsUtil.HybridCLRSettings.hotUpdateDllCompileOutputRootDir}/{EditorUserBuildSettings.activeBuildTarget}"; + foreach (var dll in SettingsUtil.HybridCLRSettings.hotUpdateAssemblyDefinitions) + { + if (dll.name.Contains(domain)) + { + string hotfixDllPath = $"{hotUpdateDir}/{dll.name}.dll"; + string hotfixDllPathTarget = + $"{target}/Dll/{EditorUserBuildSettings.activeBuildTarget}/{dll.name}.dll.bytes"; + string hotfixDllPathPdb = $"{hotUpdateDir}/{dll.name}.pdb"; + string hotfixDllPathPdbTarget = + $"{target}/Dll/{EditorUserBuildSettings.activeBuildTarget}/{dll.name}.pdb.bytes"; + FileUtility.Copy(hotfixDllPath, hotfixDllPathTarget, true); + FileUtility.Copy(hotfixDllPathPdb, hotfixDllPathPdbTarget, true); + } + } + + foreach (var dll in SettingsUtil.HybridCLRSettings.hotUpdateAssemblies) + { + if (dll.Contains(domain)) + { + string hotfixDllPath = $"{hotUpdateDir}/{dll}.dll"; + string hotfixDllPathTarget = + $"{target}/Dll/{EditorUserBuildSettings.activeBuildTarget}/{dll}.dll.bytes"; + string hotfixDllPathPdb = $"{hotUpdateDir}/{dll}.pdb"; + string hotfixDllPathPdbTarget = + $"{target}/Dll/{EditorUserBuildSettings.activeBuildTarget}/{dll}.pdb.bytes"; + FileUtility.Copy(hotfixDllPath, hotfixDllPathTarget, true); + FileUtility.Copy(hotfixDllPathPdb, hotfixDllPathPdbTarget, true); + } + } + } + + private static void CopyDllStrippedAOTDllOutputRootDir(string target) + { + //读取打包dll位置 + string hotUpdateDir = + $"{SettingsUtil.HybridCLRSettings.strippedAOTDllOutputRootDir}/{EditorUserBuildSettings.activeBuildTarget}"; + foreach (var dll in SettingsUtil.HybridCLRSettings.patchAOTAssemblies) + { + string hotfixDllPath = $"{hotUpdateDir}/{dll}"; + string hotfixDllPathTarget = + $"{target}/Dll/{EditorUserBuildSettings.activeBuildTarget}/{dll}.bytes"; + FileUtility.Copy(hotfixDllPath, hotfixDllPathTarget, true); + } + } + + //[MenuItem("Evo/Hotfix/标记资源")] + public static void AddMark() + { + //copydll + AddHotfixAddressableDll(); + //清空旧数据 + YooAsset.Editor.AssetBundleCollectorSettingData.ClearAll(); + + + packageName = ""; + package = null; + string configPath = + $"Assets/Domain/{BuildAssetWindow.GetBuildPackageName()}/Conf/HotfixMainResDomain.asset"; + HotfixMainResDomain hotfixMainResDomain = AssetDatabase.LoadAssetAtPath(configPath); + packageName = hotfixMainResDomain.hotfixMainResDomainEntity.domain; + Mark(); + CreateRes(packageName, + $"{DomainRoot}/{BuildAssetWindow.GetBuildPackageName()}/AddressableRes", + $"{DomainRoot}/{BuildAssetWindow.GetBuildPackageName()}/HotUpdate"); + + EditorUtility.DisplayDialog("自动标记", "自动标记成功", "确定"); + } + + + // [MenuItem("Evo/Hotfix/一键Res")] + public static void CreateRes(string domain, string resPath, string outputPath) + { + FileGet.CreateClass("Res", domain, outputPath, + (a) => { FileGet.CreateContent(a, resPath, "\t"); }); + } + + #region 自动标记 + + public static Dictionary addressDic = new Dictionary(); + + public static Dictionary collectorGroupDic = + new Dictionary(); + + public static void Mark() + { + addressDic.Clear(); + collectorGroupDic.Clear(); + + ///创建分组 + string remotedRoot = $"{DomainRoot}/{packageName}/AddressableRes"; + DirectoryInfo[] dirs = new DirectoryInfo(remotedRoot).GetDirectories(); + + var setting = YooAsset.Editor.AssetBundleCollectorSettingData.Setting; + setting.ShowPackageView = true; + setting.UniqueBundleName = true; + //创建Package文件 + package = YooAsset.Editor.AssetBundleCollectorSettingData.CreatePackage(packageName); + + //检测Packages是否存在TestPackage + package.PackageName = packageName; + package.EnableAddressable = true; + package.IncludeAssetGUID = true; + package.AutoCollectShaders = true; + package.IgnoreRuleName = "NormalIgnoreRule"; + + + //检测Packages是否存在Group + foreach (var info in dirs) + { + string groupName = info.Name; + + if (info.Name != "Atlas") + { + AssetBundleCollectorGroup collectorGroup = + YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(package, groupName); + collectorGroup.AssetTags = groupName; + if (!collectorGroupDic.ContainsKey(groupName)) + { + collectorGroupDic.Add(groupName, collectorGroup); + } + else + { + Debug.LogError("分组 : " + groupName + "已存在,请检查资源目录,避免重复"); + } + } + + AutoMarkRootAddress(info); + // if (info.Name != "SpriteAtlas" && info.Name != "Atlas") + // AutoMark(info.Name); + } + + + ///自动创建图集 + Debug.Log("开始创建图集"); + AutoCreateSpriteAtlas(remotedRoot); + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + MarkStatus(); + YooAsset.Editor.AssetBundleCollectorSettingData.FixFile(); + + // CreateRes(); + Debug.Log("MarkAsset Successful"); + } + + public static void AutoMarkRootAddress(DirectoryInfo dir) + { + List fileInfos = new List(); + FilesUtils.GetFiles(dir.FullName, ref fileInfos); + + //检测用户config下是否存在config文件 + if (dir.Name == "Config") + { + List fileNewInfos = new List(); + foreach (var file in fileInfos) + { + if (Path.GetExtension(file) != ".meta") + { + fileNewInfos.Add(file); + } + } + + //不存在的配置对象名称 + List configNonentity = new List(); + //查找不存在的配置文件 + for (int i = 0; i < configNames.Length; i++) + { + bool exists = false; + foreach (var filePath in fileNewInfos) + { + // 使用Path获取文件名 + string fileName = Path.GetFileNameWithoutExtension(filePath); + if (fileName == configNames[i]) + { + exists = true; + break; + } + } + + if (!exists) + { + configNonentity.Add(configNames[i]); + } + } + + string remotedRoot = Application.dataPath + "/Main/Config"; + List mainConfigInfos = new List(); + FilesUtils.GetFiles(remotedRoot, ref mainConfigInfos); + //从main文件里拿取指定配置文件 + foreach (var config in configNonentity) + { + foreach (var mainConfigInfo in mainConfigInfos) + { + // 使用Path获取文件名 + string fileName = Path.GetFileNameWithoutExtension(mainConfigInfo); + if (Path.GetExtension(mainConfigInfo) != ".meta" && fileName.Equals(config)) + { + fileInfos.Add(mainConfigInfo); + Debug.LogWarning($"用户资源目录不存在【{config}】文件,从Main目录下复制,此操作可能导致配置文件不完成,请在用户目录配置"); + break; + } + } + } + } + + if (fileInfos != null && fileInfos.Count > 0) + { + foreach (var file in fileInfos) + { + if (Path.GetExtension(file) != ".meta" && Path.GetExtension(file) != ".spriteatlas") + { + // string[] dirSplit = file.Split(new string[] { $"AddressableRes\\{dir.Name}\\" }, + // StringSplitOptions.RemoveEmptyEntries); + // string address = (dirSplit[dirSplit.Length - 1]).Replace("\\", "/"); + // Debug.Log("address:" + address); + string groupName = dir.Name; + string assetPath = FilesUtils.AbsoluteToRelativePath("Assets", file); //Asset到文件的路径 + var guid = AssetDatabase.AssetPathToGUID(assetPath); + var group = collectorGroupDic[groupName]; + if (group != null) + { + AssetBundleCollector collector = new AssetBundleCollector() + { + CollectPath = assetPath, + CollectorGUID = guid, + CollectorType = ECollectorType.MainAssetCollector, + AddressRuleName = nameof(AddressByFolderAndFileName), + AssetTags = groupName, + }; + //如果是video目录,设置 + if (groupName == "Video") + { + collector.PackRuleName = nameof(PackVideoFile); + } + + YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector); + Debug.Log("GetAssetAddress:" + GetAssetAddress(file)); + AddAddressInfo(file, GetAssetAddress(file)); + } + else + { + Debug.LogError("分组 = " + groupName + "不存在"); + } + } + } + } + } + + #region 图集 + + public static void AutoCreateSpriteAtlas(string domainRootRes) + { + string AtlasRemotedRoot = domainRootRes + "/SpriteAtlas"; + string SpriteRemotedAtlas = domainRootRes + "/Sprites"; + DirectoryInfo[] remotedirs = new DirectoryInfo(SpriteRemotedAtlas).GetDirectories(); + foreach (var info in remotedirs) + { + AddSpriteAtlas(SpriteRemotedAtlas + "/" + info.Name, SpriteRemotedAtlas, + AtlasRemotedRoot, info); + } + } + + /// + /// 自动创建图集 + /// + /// 路径 + /// 文件夹 + private static void AddSpriteAtlas(string path, string atlasRoot, string spriteAtlas, DirectoryInfo dir) + { + var groupname = "SpriteAtlas"; + var dirs = dir.GetDirectories(); + if (dirs == null || dirs.Length == 0) + { + string name = path.Replace(atlasRoot + "/", string.Empty).Replace("/", "_"); + string filePath = $"{spriteAtlas}/{name}.spriteatlas"; + // string[] dirSplit = + // filePath.Split(new string[] { $"AddressableRes/{Path.GetFileName(spriteAtlas)}" }, + // StringSplitOptions.RemoveEmptyEntries); + // string address = (dirSplit[dirSplit.Length - 1]).Substring(1).Replace("\\", "/"); + // Debug.Log("spriteatlasaddress:" + address); + int assetIndex = filePath.IndexOf("Assets"); + string guidPath = filePath.Remove(0, assetIndex); + if (!File.Exists(filePath)) + { + SpriteAtlas atlas = new SpriteAtlas(); + //设置打包参数 + SpriteAtlasPackingSettings packSetting = new SpriteAtlasPackingSettings() + { + blockOffset = 1, + enableRotation = true, + enableTightPacking = false, + padding = 2, + }; + atlas.SetPackingSettings(packSetting); + + //设置打包后Texture图集信息 + SpriteAtlasTextureSettings textureSettings = new SpriteAtlasTextureSettings() + { + readable = false, + generateMipMaps = false, + sRGB = true, + filterMode = FilterMode.Bilinear, + }; + atlas.SetTextureSettings(textureSettings); + + //设置平台图集大小压缩等信息 + TextureImporterPlatformSettings platformSettings = new TextureImporterPlatformSettings() + { + maxTextureSize = 4096, + format = TextureImporterFormat.Automatic, + crunchedCompression = true, + textureCompression = TextureImporterCompression.Compressed, + compressionQuality = 50, + }; + atlas.SetPlatformSettings(platformSettings); + AssetDatabase.CreateAsset(atlas, guidPath); + int pathIndex = path.IndexOf("Assets"); + string spritePath = path.Remove(0, pathIndex); + UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(spritePath, typeof(UnityEngine.Object)); + atlas.Add(new[] { obj }); + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + } + + var guid = AssetDatabase.AssetPathToGUID(guidPath); + + var group = collectorGroupDic[groupname]; + if (group != null) + { + AssetBundleCollector collector = new AssetBundleCollector() + { + CollectPath = guidPath, + CollectorGUID = guid, + CollectorType = ECollectorType.MainAssetCollector, + AddressRuleName = nameof(AddressByFolderAndFileName), + AssetTags = groupname, + }; + YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector); + + + AddAddressInfo(path, GetAssetAddress(path)); + } + else + { + Debug.LogError("分组 = " + GetAssetAddress(path) + "不存在"); + } + + AssetDatabase.Refresh(); + } + else + { + if (dirs.Length > 0) + { + foreach (var info in dirs) + { + AddSpriteAtlas(path + "/" + info.Name, atlasRoot, spriteAtlas, info); + } + } + } + } + + #endregion + + private static void AddAddressInfo(string assetPath, string address) + { + if (addressDic.ContainsKey(assetPath)) + { + Debug.LogError("命名重复,已经存在:" + assetPath); + } + else + { + addressDic.Add(assetPath, address); + } + } + + private static string GetAssetAddress(string assetPath) + { + string fileName = Path.GetFileNameWithoutExtension(assetPath); + FileInfo fileInfo = new FileInfo(assetPath); + return $"{fileInfo.Directory.Name}_{fileName}"; + } + + #endregion + + + // /// + // /// 标记是否有打包报错信息 + // /// + // private static bool _isBuildSuccess = true; + // + // [MenuItem("Evo/BuildTools/BuildAdressable")] + // private static void BuildByStatus() + // { + // InitAssetData(); + // _isBuildSuccess = true; + // //BuildTools.ClearConsole(); + // Application.logMessageReceived += OnLogMessage; + // + // AssetDatabase.Refresh(); + // AssetDatabase.Refresh(); + // MarkStatus(); + // //SetMD5Info(); + // AssetDatabase.Refresh(); + // Application.logMessageReceived -= OnLogMessage; + // if (!_isBuildSuccess) + // { + // if (EditorUtility.DisplayDialog("打包失败", "请检测报错信息", "确定")) + // { + // // EditorUtility.RevealInFinder(BuildTools.OutPath); + // // BuildTools.OutPath = string.Empty; + // } + // } + // } + + + /// + /// 标记为资源分组 + /// + private static void MarkStatus() + { + List deleteList = new List(); + for (int i = 0; i < package.Groups.Count; i++) + { + var group = package.Groups[i]; + if (group.GroupName != "Default Local Group" && group.GroupName != "Built In Data") + { + if (group.Collectors.Count <= 0) + { + ///删除没有资源的分组 + deleteList.Add(group); + } + } + } + + for (int i = 0; i < deleteList.Count; i++) + { + package.Groups.Remove(deleteList[i]); + } + } + + // private static Dictionary _md5Files = new Dictionary(); + // + // private static void SetMD5Info() + // { + // _md5Files.Clear(); + // + // string path = Application.dataPath.Replace("Assets", + // $"ServerData/{Application.platform}/Release"); + // if (Directory.Exists(path)) + // { + // DirectoryInfo dir = new DirectoryInfo(path); + // MD5File(dir); + // } + // + // AssetDatabase.Refresh(); + // } + // + // private static void MD5File(DirectoryInfo info) + // { + // FileInfo[] files = info.GetFiles(); + // if (files.Length > 0) + // { + // for (int i = 0; i < files.Length; i++) + // { + // var file = files[i]; + // if (file == null || file.Extension == ".meta") + // { + // continue; + // } + // + // string filePath = file.FullName.Replace(@"\", "/"); + // MD5Info md5 = new MD5Info(); + // md5.AssetPath = filePath; + // md5.MD5 = FilesUtils.CalculateMD5(file.FullName); + // _md5Files.Add(md5.AssetPath, md5); + // } + // } + // + // DirectoryInfo[] dirs = info.GetDirectories(); + // if (dirs != null && dirs.Length > 0) + // { + // for (int i = 0; i < dirs.Length; i++) + // { + // MD5File(dirs[i]); + // } + // } + // } + + // private static void OnLogMessage(string condition, string stackTrace, LogType type) + // { + // if (type == LogType.Error) + // { + // if (condition != "EndLayoutGroup: BeginLayoutGroup must be called first.") + // _isBuildSuccess = false; + // } + // } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/MarkAdressable/MarkAdressable.cs.meta b/Assets/00.StaryEvo/Editor/MarkAdressable/MarkAdressable.cs.meta new file mode 100644 index 0000000..3376475 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/MarkAdressable/MarkAdressable.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c4bdee1290d71f34b9346c345de976a3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/OdinTool.meta b/Assets/00.StaryEvo/Editor/OdinTool.meta new file mode 100644 index 0000000..aa0b4ca --- /dev/null +++ b/Assets/00.StaryEvo/Editor/OdinTool.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7ace33a2ab95bdd4183bedd0eb176ab4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/OdinTool/MyMenuEditorWindow.cs b/Assets/00.StaryEvo/Editor/OdinTool/MyMenuEditorWindow.cs new file mode 100644 index 0000000..7af0605 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/OdinTool/MyMenuEditorWindow.cs @@ -0,0 +1,25 @@ +using Sirenix.OdinInspector.Editor; +using UnityEditor; + +namespace Stary.Evo.Editor +{ + + + public class MyMenuEditorWindow : OdinMenuEditorWindow + { + [MenuItem("Evo/Utility/优化/一键优化工具")] + private static void OpenWindow() + { + GetWindow().Show(); + } + + protected override OdinMenuTree BuildMenuTree() + { + var tree = new OdinMenuTree(); + tree.Selection.SupportsMultiSelect = false; + tree.Add("一键批量更改Raycast Target选项", new OneKeyChangeRaycastTarget()); + tree.Add("一键查找重复文件", new OneKeySearchDuplicateFiles()); + return tree; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/OdinTool/MyMenuEditorWindow.cs.meta b/Assets/00.StaryEvo/Editor/OdinTool/MyMenuEditorWindow.cs.meta new file mode 100644 index 0000000..03bd91b --- /dev/null +++ b/Assets/00.StaryEvo/Editor/OdinTool/MyMenuEditorWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6f9dc9117e7bf144b83022ae0e269d99 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/OdinTool/OneKeyChangeRaycastTarget.cs b/Assets/00.StaryEvo/Editor/OdinTool/OneKeyChangeRaycastTarget.cs new file mode 100644 index 0000000..2c7a64d --- /dev/null +++ b/Assets/00.StaryEvo/Editor/OdinTool/OneKeyChangeRaycastTarget.cs @@ -0,0 +1,127 @@ +/**************************************************** + 文件:OneKeySearchDuplicateFiles.cs + 作者:张铮 + 邮箱:834207172@qq.com + 日期:2022/3/7 18:28:50 + 功能: +*****************************************************/ +using Sirenix.OdinInspector; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; +using UnityEngine.UI; + +namespace Stary.Evo.Editor +{ + + + [TypeInfoBox("批量选中或者取消对应UI上的Raycast")] + public class OneKeyChangeRaycastTarget : SerializedScriptableObject + { + + private bool selectRaycastComplete = false; + private bool cancelRaycastComplete = false; + + [PreviewField(50)] + [OnValueChanged("SelectRaycastListValueChangeCallBack")] + [HorizontalGroup("Raycast")] + [PropertySpace(10, 10)] + [BoxGroup("Raycast/Left", false)] + [LabelText("需要选中Raycast拖入进来")] + public List SelectRaycastList = new List(); + + public void SelectRaycastListValueChangeCallBack() + { + selectRaycastComplete = false; + } + + + [PreviewField(50)] + [OnValueChanged("CancelRaycastListValueChangeCallBack")] + [PropertySpace(10, 10)] + [BoxGroup("Raycast/Right", false)] + [LabelText("需要取消Raycast拖入进来")] + public List CancelRaycastList = new List(); + + public void CancelRaycastListValueChangeCallBack() + { + cancelRaycastComplete = false; + } + + [HideIf("@selectRaycastComplete==true||SelectRaycastList.Count==0")] + [BoxGroup("Raycast/Left")] + [Button("勾选所有射线检测", ButtonSizes.Large, ButtonStyle.FoldoutButton)] + public void SelectRaycast() + { + for (int i = 0; i < SelectRaycastList.Count; i++) + { + if (SelectRaycastList[i] == null) + { + continue; + } + + Graphic[] graphicArray = SelectRaycastList[i].GetComponentsInChildren(); + for (int k = 0; k < graphicArray.Length; k++) + { + graphicArray[k].raycastTarget = true; + EditorUtility.SetDirty(graphicArray[k]); + } + + GameObject tempObject = SelectRaycastList[i]; + bool isPrefabInstance = PrefabUtility.IsPartOfPrefabInstance(tempObject); + bool isPrefabAsset = PrefabUtility.IsPartOfPrefabAsset(tempObject); + if (isPrefabAsset) + { + PrefabUtility.SavePrefabAsset(SelectRaycastList[i]); + } + + if (isPrefabInstance) + { + PrefabUtility.ApplyPrefabInstance(SelectRaycastList[i], InteractionMode.UserAction); + } + } + + selectRaycastComplete = true; + AssetDatabase.Refresh(); + } + + + [HideIf("@cancelRaycastComplete==true||CancelRaycastList.Count==0")] + [BoxGroup("Raycast/Right")] + [Button("取消所有射线检测", ButtonSizes.Large, ButtonStyle.FoldoutButton)] + public void CancelRaycast() + { + for (int i = 0; i < CancelRaycastList.Count; i++) + { + if (CancelRaycastList[i] == null) + { + continue; + } + + Graphic[] graphicArray = CancelRaycastList[i].GetComponentsInChildren(); + for (int k = 0; k < graphicArray.Length; k++) + { + graphicArray[k].raycastTarget = false; + EditorUtility.SetDirty(graphicArray[k]); + } + + GameObject tempObject = CancelRaycastList[i]; + bool isPrefabInstance = PrefabUtility.IsPartOfPrefabInstance(tempObject); + bool isPrefabAsset = PrefabUtility.IsPartOfPrefabAsset(tempObject); + + if (isPrefabAsset) + { + PrefabUtility.SavePrefabAsset(CancelRaycastList[i]); + } + + if (isPrefabInstance) + { + PrefabUtility.ApplyPrefabInstance(CancelRaycastList[i], InteractionMode.UserAction); + } + } + + cancelRaycastComplete = true; + AssetDatabase.Refresh(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/OdinTool/OneKeyChangeRaycastTarget.cs.meta b/Assets/00.StaryEvo/Editor/OdinTool/OneKeyChangeRaycastTarget.cs.meta new file mode 100644 index 0000000..85b4942 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/OdinTool/OneKeyChangeRaycastTarget.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0fd00bd6b055f134e8be6fb93a5b5ce4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/OdinTool/OneKeySearchDuplicateFiles.cs b/Assets/00.StaryEvo/Editor/OdinTool/OneKeySearchDuplicateFiles.cs new file mode 100644 index 0000000..e87b204 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/OdinTool/OneKeySearchDuplicateFiles.cs @@ -0,0 +1,186 @@ +/**************************************************** + 文件:OneKeySearchDuplicateFiles.cs + 作者:张铮 + 邮箱:834207172@qq.com + 日期:2022/3/7 18:28:50 + 功能: +*****************************************************/ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UnityEngine; +using UnityEngine.UI; +using Sirenix.OdinInspector; +using Sirenix.OdinInspector.Editor; +using UnityEditor; +using System.Threading; + +namespace Stary.Evo.Editor +{ + + + public class OneKeySearchDuplicateFiles : SerializedScriptableObject + { + private bool IsToggled; + private int maxCount; + private IEnumerator fileInfoIEnumerator; + + [PropertySpace(10)] + [Title("需要搜索的文件夹", "默认为Asset全目录", titleAlignment: TitleAlignments.Split)] + [FolderPath(ParentFolder = "Assets", RequireExistingPath = true, AbsolutePath = true)] + [LabelText("选择你要搜索的文件夹")] + public string targetSearchFolder; + + + [ShowInInspector] [DictionaryDrawerSettings(KeyLabel = "MD5值", ValueLabel = "文件名称列表")] + private Dictionary> sameMD5Group = new Dictionary>(); + + [ShowInInspector] [DictionaryDrawerSettings(KeyLabel = "文件名称", ValueLabel = "绝对路径列表")] + private Dictionary> sameNameGroup = new Dictionary>(); + + [ShowInInspector] + [TitleGroup("重复文件列表")] + [HorizontalGroup("重复文件列表/重复文件")] + [BoxGroup("重复文件列表/重复文件/MD5值相同", CenterLabel = true)] + [PropertyOrder(1000)] + [InfoBox("发现相同MD5值文件.", InfoMessageType.Error, "CheckSameMD5ResultGroup")] + [ShowIf("$CheckSameMD5ResultGroup")] + [DictionaryDrawerSettings(KeyLabel = "MD5值", ValueLabel = "相同MD5值文件名称")] + private Dictionary> sameMD5Result5Group = new Dictionary>(); + + + [BoxGroup("重复文件列表/重复文件/名称值相同", CenterLabel = true)] + [ShowInInspector] + [PropertyOrder(1000)] + [InfoBox("发现相同名称文件.", InfoMessageType.Error, "CheckSameNameResultGroup")] + [ShowIf("$CheckSameNameResultGroup")] + [DictionaryDrawerSettings(KeyLabel = "相同文件名称", ValueLabel = "对应绝对路径列表")] + private Dictionary> sameNameResultGroup = new Dictionary>(); + + public bool CheckSameMD5ResultGroup() + { + return sameMD5Result5Group.Count > 0; + } + + private bool CheckSameNameResultGroup() + { + return sameNameResultGroup.Count > 0; + } + + [PropertySpace(10, 20)] + [ShowIf("@ IsToggled== false")] + [Button("开始搜索", ButtonSizes.Large)] + public void StartSearch() + { + if (string.IsNullOrEmpty(targetSearchFolder)) + { + targetSearchFolder = Application.dataPath; + } + + ResetData(); + DirectoryInfo directoryInfo = new DirectoryInfo(targetSearchFolder); + var filesGroup = directoryInfo.EnumerateFiles("*", SearchOption.AllDirectories) + .Where(x => x.Extension != ".meta"); + + maxCount = filesGroup.Count(); + fileInfoIEnumerator = filesGroup.GetEnumerator(); + IsToggled = true; + EditorApplication.update += Updte; + } + + private void ResetData() + { + maxCount = 0; + MaxCount = 0; + sameMD5Group.Clear(); + sameNameGroup.Clear(); + sameMD5Result5Group.Clear(); + sameNameResultGroup.Clear(); + fileInfoIEnumerator = null; + } + + /// + /// 过滤掉没有重复文件的数据 + /// + private void FilterDictionary() + { + sameMD5Result5Group = sameMD5Group.Where(x => x.Value.Count > 1).ToDictionary(p => p.Key, p => p.Value); + sameNameResultGroup = sameNameGroup.Where(x => x.Value.Count > 1).ToDictionary(p => p.Key, p => p.Value); + } + + [ReadOnly] + [ProgressBar(0, "maxCount", DrawValueLabel = true, ValueLabelAlignment = TextAlignment.Left, + ColorGetter = "GetHealthBarColor", Height = 30)] + [ShowInInspector] + [HideLabel] + [ShowIf("@ IsToggled== true")] + public int MaxCount { get; set; } //绘制进度条 + + private Color GetHealthBarColor(int value) + { + maxCount = maxCount == 0 ? 1 : maxCount; + return Color.Lerp(Color.red, Color.green, Mathf.Pow((float)value / maxCount, 2)); + } + + public void Updte() + { + if (IsToggled) + { + if (fileInfoIEnumerator.MoveNext()) + { + //获取对应Hash值 + string hashValue = GetMD5HashFromFile(fileInfoIEnumerator.Current.FullName); + if (!sameMD5Group.ContainsKey(hashValue)) + { + sameMD5Group[hashValue] = new List(); + } + + sameMD5Group[hashValue].Add("名称为:" + fileInfoIEnumerator.Current.Name); + + //获取名称 + string fileName = fileInfoIEnumerator.Current.Name; + + if (!sameNameGroup.ContainsKey(fileName)) + { + sameNameGroup[fileName] = new List(); + } + + sameNameGroup[fileName].Add("路径为:" + fileInfoIEnumerator.Current.FullName); + + ++MaxCount; + } + else + { + EditorApplication.update -= Updte; + IsToggled = false; + FilterDictionary(); + Debug.Log("注销"); + } + } + } + + /// + /// 计算文件MD5值 + /// + /// + /// + public string GetMD5HashFromFile(string fileFullName) + { + try + { + FileStream file = new FileStream(fileFullName, FileMode.Open); + System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); + byte[] retVal = md5.ComputeHash(file); + file.Close(); + return BitConverter.ToString(retVal).ToLower().Replace("-", ""); + } + catch + { + throw; + } + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/OdinTool/OneKeySearchDuplicateFiles.cs.meta b/Assets/00.StaryEvo/Editor/OdinTool/OneKeySearchDuplicateFiles.cs.meta new file mode 100644 index 0000000..5ea107c --- /dev/null +++ b/Assets/00.StaryEvo/Editor/OdinTool/OneKeySearchDuplicateFiles.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 951c77f73e8aa2f47b895be4fe74da46 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Res.meta b/Assets/00.StaryEvo/Editor/Res.meta new file mode 100644 index 0000000..50619f4 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 267dfbf363f81234685a85fd18365dd0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Res/FileGet.cs b/Assets/00.StaryEvo/Editor/Res/FileGet.cs new file mode 100644 index 0000000..969e7a7 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/FileGet.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using UnityEditor; +using UnityEngine; + +namespace Stary.Evo.Editor +{ + public static class FileGet + { + public static void CreateContent(StringBuilder variable, string path, string tab) + { + tab += "\t\t"; + DirectoryInfo dir = new DirectoryInfo(path); + DirectoryInfo[] first = dir.GetDirectories(); + FileInfo[] fil = dir.GetFiles(); + if (first.Length > 0) + { + foreach (FileInfo f in fil) + { + CreateFile(variable, f, tab); + } + + foreach (DirectoryInfo f in first) + { + CreateFolder(variable, f, tab); + } + } + else + { + foreach (FileInfo f in fil) + { + CreateFile(variable, f, tab); + } + } + } + + /// + /// 生成脚本文件 + /// + /// 类名 + /// 字符串事件 + public static void CreateClass(string className, string package, string outputPath, + Action content = null) + { + string tdClassName = className; + StringBuilder variable = new StringBuilder(); + //variable.Append("using System;\n"); + variable.Append("namespace " + "R" + "\n"); + variable.Append("{\n"); + variable.Append("\tpublic class " + tdClassName + "\n"); + variable.Append("\t{\n"); + variable.Append("\t\tpublic class " + package + "\n"); + variable.Append("\t\t{\n"); + content?.Invoke(variable); + + variable.Append("\t\t}\n"); + variable.Append("\t}\n"); + variable.Append("}"); + + + outputPath = $"{outputPath}/{tdClassName}.cs"; + if (File.Exists(outputPath)) + { + File.Delete(outputPath); + } + FileHelper.WriteFile(outputPath, variable.ToString()); + + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + } + + /// + /// 文件夹生成 + /// + /// + private static void CreateFolder(StringBuilder variable, DirectoryInfo folderName, string tab) + { + string classname = FilesUtils.ChineseToPinYin(folderName.Name, false); + variable.Append(tab + " public static class " + classname + "\n"); + variable.Append(tab + "{\n"); + CreateContent(variable, folderName.FullName, tab); + + variable.Append(tab + "}\n"); + } + + /// + /// 文件生成 + /// + /// + private static void CreateFile(StringBuilder variable, FileInfo fileName, string tab) + { + var fullname =System.IO.Path.GetExtension(fileName.FullName); + if (fullname != ".meta"&&fullname!=".hint" ) + { + Debug.Log("FileInfo:" + fileName.Name); + string[] fileSplit = fileName.FullName.Split(new string[] { "AddressableRes\\" }, + StringSplitOptions.RemoveEmptyEntries); + string[] resSplit = fileSplit[fileSplit.Length - 1].Split('\\'); + // fileSplit = fileName.FullName.Split(new string[] { $"AddressableRes\\{resSplit[0]}\\" }, + // StringSplitOptions.RemoveEmptyEntries); + // string filepath = fileSplit[fileSplit.Length - 1].Replace("\\", "/"); + // // 删除文件后缀 + // filepath = Path.Combine( + // Path.GetDirectoryName(filepath), + // Path.GetFileNameWithoutExtension(filepath) + // ).Replace("\\", "/"); + // Debug.Log(filepath); + string filepath; + if (MarkAdressable.addressDic.ContainsKey(fileName.FullName)) + { + filepath = MarkAdressable.addressDic[fileName.FullName]; + } + else + { + Debug.LogError("未找到地址,请检查资源自动化标记逻辑:" + fileName.FullName); + filepath = ""; + } + + + string name = FilesUtils.ChineseToPinYin(fileName.Name.Replace(".", "_"), false) + .Replace(" ", "") + .Replace("-", "_") + .Replace(".", "_"); // 保留点号替换为下划线 + variable.Append(tab + "public const string " + name + " = \"" + filepath + "\";\n"); + } + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/Res/FileGet.cs.meta b/Assets/00.StaryEvo/Editor/Res/FileGet.cs.meta new file mode 100644 index 0000000..a2924e0 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/FileGet.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 17d52df7853411b46bc8e8ecf271db8a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Res/FileHelper.cs b/Assets/00.StaryEvo/Editor/Res/FileHelper.cs new file mode 100644 index 0000000..8914bd0 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/FileHelper.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace Stary.Evo.Editor +{ + /// + /// 文件辅助类 + /// + public static class FileHelper + { + /// + /// 编码方式 + /// + private static readonly Encoding Encoding = Encoding.UTF8; + + /// + /// 递归取得文件夹下文件 + /// + /// + /// + public static void GetFiles(string dir, List list) + { + GetFiles(dir, list, new List()); + } + /// + /// 递归取得文件夹下文件 + /// + /// + /// + /// + public static void GetFiles(string dir, List list, List fileExtsions) + { + //添加文件 + string[] files = Directory.GetFiles(dir); + if (fileExtsions.Count > 0) + { + foreach (string file in files) + { + string extension = Path.GetExtension(file); + if (extension != null && fileExtsions.Contains(extension)) + { + list.Add(file); + } + } + } + else + { + list.AddRange(files); + } + //如果是目录,则递归 + DirectoryInfo[] directories = new DirectoryInfo(dir).GetDirectories(); + foreach (DirectoryInfo item in directories) + { + GetFiles(item.FullName, list, fileExtsions); + } + } + + /// + /// 写入文件 + /// + /// 文件名 + /// 文件内容 + public static void WriteFile(string filePath, string content) + { + try + { + var fs = new FileStream(filePath, FileMode.Create); + Encoding encode = Encoding; + //获得字节数组 + byte[] data = encode.GetBytes(content); + //开始写入 + fs.Write(data, 0, data.Length); + //清空缓冲区、关闭流 + fs.Flush(); + fs.Close(); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + + /// + /// 读取文件 + /// + /// + /// + public static string ReadFile(string filePath) + { + return ReadFile(filePath, Encoding); + } + + /// + /// 读取文件 + /// + /// + /// + /// + public static string ReadFile(string filePath, Encoding encoding) + { + using (var sr = new StreamReader(filePath, encoding)) + { + return sr.ReadToEnd(); + } + } + + /// + /// 读取文件 + /// + /// + /// + public static List ReadFileLines(string filePath) + { + var str = new List(); + using (var sr = new StreamReader(filePath, Encoding)) + { + String input; + while ((input = sr.ReadLine()) != null) + { + str.Add(input); + } + } + return str; + } + + /// + /// 复制文件夹(及文件夹下所有子文件夹和文件) + /// + /// 待复制的文件夹路径 + /// 目标路径 + public static void CopyDirectory(String sourcePath, String destinationPath) + { + var info = new DirectoryInfo(sourcePath); + Directory.CreateDirectory(destinationPath); + foreach (FileSystemInfo fsi in info.GetFileSystemInfos()) + { + String destName = Path.Combine(destinationPath, fsi.Name); + + if (fsi is FileInfo) //如果是文件,复制文件 + File.Copy(fsi.FullName, destName); + else //如果是文件夹,新建文件夹,递归 + { + Directory.CreateDirectory(destName); + CopyDirectory(fsi.FullName, destName); + } + } + } + + /// + /// 删除文件夹(及文件夹下所有子文件夹和文件) + /// + /// + public static void DeleteFolder(string directoryPath) + { + foreach (string d in Directory.GetFileSystemEntries(directoryPath)) + { + if (File.Exists(d)) + { + var fi = new FileInfo(d); + if (fi.Attributes.ToString().IndexOf("ReadOnly", StringComparison.Ordinal) != -1) + fi.Attributes = FileAttributes.Normal; + File.Delete(d); //删除文件 + } + else + DeleteFolder(d); //删除文件夹 + } + Directory.Delete(directoryPath); //删除空文件夹 + } + + /// + /// 清空文件夹(及文件夹下所有子文件夹和文件) + /// + /// + public static void ClearFolder(string directoryPath) + { + foreach (string d in Directory.GetFileSystemEntries(directoryPath)) + { + if (File.Exists(d)) + { + var fi = new FileInfo(d); + if (fi.Attributes.ToString().IndexOf("ReadOnly", StringComparison.Ordinal) != -1) + fi.Attributes = FileAttributes.Normal; + File.Delete(d); //删除文件 + } + else + DeleteFolder(d); //删除文件夹 + } + } + + /// + /// 取得文件大小,按适当单位转换 + /// + /// + /// + public static string GetFileSize(string filepath) + { + string result = "0KB"; + if (File.Exists(filepath)) + { + var size = new FileInfo(filepath).Length; + int filelength = size.ToString().Length; + if (filelength < 4) + result = size + "byte"; + else if (filelength < 7) + result = Math.Round(Convert.ToDouble(size / 1024d), 2) + "KB"; + else if (filelength < 10) + result = Math.Round(Convert.ToDouble(size / 1024d / 1024), 2) + "MB"; + else if (filelength < 13) + result = Math.Round(Convert.ToDouble(size / 1024d / 1024 / 1024), 2) + "GB"; + else + result = Math.Round(Convert.ToDouble(size / 1024d / 1024 / 1024 / 1024), 2) + "TB"; + return result; + } + return result; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/Res/FileHelper.cs.meta b/Assets/00.StaryEvo/Editor/Res/FileHelper.cs.meta new file mode 100644 index 0000000..b349fbd --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/FileHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f7bb160f90922fc489ad0c7ccada23cc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Res/FilesUtils.cs b/Assets/00.StaryEvo/Editor/Res/FilesUtils.cs new file mode 100644 index 0000000..cc200bb --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/FilesUtils.cs @@ -0,0 +1,505 @@ +/**************************************************** + 文件:EditorFrameworkUtils.cs + 作者:张铮 + 邮箱: + 日期:2022/3/8 17:50:17 + 功能: +*****************************************************/ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using UnityEditor; +using UnityEngine; + +namespace Stary.Evo.Editor +{ +#if UNITY_EDITOR + /// + /// 文件辅助类 + /// + public static class FilesUtils + { + /// + /// 编码方式 + /// + private static readonly Encoding Encoding = Encoding.UTF8; + + /// + /// 递归取得文件夹下文件 + /// + /// + /// + /// + public static void GetFiles(string dir, ref List list) + { + //添加文件 + string[] files = Directory.GetFiles(dir); + //if (fileExtsions.Count > 0) + //{ + foreach (string file in files) + { + string extension = Path.GetExtension(file); + if (extension != null) + { + list.Add(file); + } + } + + // } + // else + // { + // list.AddRange(files); + // } + //如果是目录,则递归 + DirectoryInfo[] directories = new DirectoryInfo(dir).GetDirectories(); + foreach (DirectoryInfo item in directories) + { + GetFiles(item.FullName, ref list); + } + } + + /// + /// 创建文件夹 + /// + public static void CreateFolder() + { + // Directory.CreateDirectory();// + } + + /// + /// 写入文件 + /// + /// 文件名 + /// 文件内容 + public static void WriteFile(string filePath, string content) + { + try + { + var fs = new FileStream(filePath, FileMode.Create); + Encoding encode = Encoding; + //获得字节数组 + byte[] data = encode.GetBytes(content); + //开始写入 + fs.Write(data, 0, data.Length); + //清空缓冲区、关闭流 + fs.Flush(); + fs.Close(); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + + /// + /// 读取文件 + /// + /// + /// + public static string ReadFile(string filePath) + { + return ReadFile(filePath, Encoding); + } + + /// + /// 读取文件 + /// + /// + /// + /// + public static string ReadFile(string filePath, Encoding encoding) + { + using (var sr = new StreamReader(filePath, encoding)) + { + return sr.ReadToEnd(); + } + } + + /// + /// 读取文件 + /// + /// + /// + public static List ReadFileLines(string filePath) + { + var str = new List(); + using (var sr = new StreamReader(filePath, Encoding)) + { + String input; + while ((input = sr.ReadLine()) != null) + { + str.Add(input); + } + } + + return str; + } + + /// + /// 文件复制 + /// + /// + /// + public static void CopyFile(string filePath, string targetPath) + { + FileInfo file = new FileInfo(filePath); + if (!Directory.Exists(targetPath)) + { + Directory.CreateDirectory(targetPath); + } + + if (file != null) + { + string tempPath = Path.Combine(targetPath, file.Name); + file.CopyTo(tempPath, true); //如果文件存在则覆盖 + } + } + + /// + /// 复制文件夹(及文件夹下所有子文件夹和文件) + /// + /// 待复制的文件夹路径 + /// 目标路径 + public static void CopyDirectory(String sourcePath, String destinationPath) + { + var info = new DirectoryInfo(sourcePath); + Directory.CreateDirectory(destinationPath); + foreach (FileSystemInfo fsi in info.GetFileSystemInfos()) + { + String destName = Path.Combine(destinationPath, fsi.Name); + + if (fsi is FileInfo) //如果是文件,复制文件 + File.Copy(fsi.FullName, destName); + else //如果是文件夹,新建文件夹,递归 + { + Directory.CreateDirectory(destName); + CopyDirectory(fsi.FullName, destName); + } + } + } + + /// + /// 删除文件夹(及文件夹下所有子文件夹和文件) + /// + /// + public static void DeleteFolder(string directoryPath) + { + foreach (string d in Directory.GetFileSystemEntries(directoryPath)) + { + if (File.Exists(d)) + { + var fi = new FileInfo(d); + if (fi.Attributes.ToString().IndexOf("ReadOnly", StringComparison.Ordinal) != -1) + fi.Attributes = FileAttributes.Normal; + File.Delete(d); //删除文件 + } + else + DeleteFolder(d); //删除文件夹 + } + + Directory.Delete(directoryPath); //删除空文件夹 + } + + /// + /// 清空文件夹(及文件夹下所有子文件夹和文件) + /// + /// + public static void ClearFolder(string directoryPath) + { + foreach (string d in Directory.GetFileSystemEntries(directoryPath)) + { + if (File.Exists(d)) + { + var fi = new FileInfo(d); + if (fi.Attributes.ToString().IndexOf("ReadOnly", StringComparison.Ordinal) != -1) + fi.Attributes = FileAttributes.Normal; + File.Delete(d); //删除文件 + } + else + DeleteFolder(d); //删除文件夹 + } + } + + /// + /// 取得文件大小,按适当单位转换 + /// + /// + /// + public static string GetFileSize(string filepath) + { + string result = "0KB"; + if (File.Exists(filepath)) + { + var size = new FileInfo(filepath).Length; + int filelength = size.ToString().Length; + if (filelength < 4) + result = size + "byte"; + else if (filelength < 7) + result = Math.Round(Convert.ToDouble(size / 1024d), 2) + "KB"; + else if (filelength < 10) + result = Math.Round(Convert.ToDouble(size / 1024d / 1024), 2) + "MB"; + else if (filelength < 13) + result = Math.Round(Convert.ToDouble(size / 1024d / 1024 / 1024), 2) + "GB"; + else + result = Math.Round(Convert.ToDouble(size / 1024d / 1024 / 1024 / 1024), 2) + "TB"; + return result; + } + + return result; + } + + /// + /// 删除文件. + /// + /// 删除完整文件夹路径. + /// 删除文件的名称. + public static void DeleteFile(string path, string name) + { + File.Delete(path + name); + } + + /// + /// 删除文件夹下所有子文件夹与文件 + /// + public static void DeleteAllChild(string path, FileAttributes filter) + { + if (!Directory.Exists(path)) + return; + + DirectoryInfo dir = new DirectoryInfo(path); + FileInfo[] files = dir.GetFiles("*"); + for (int i = 0; i < files.Length; ++i) + { + if ((files[i].Attributes & filter) > 0) + continue; + if (File.Exists(files[i].FullName)) + File.Delete(files[i].FullName); + } + + DirectoryInfo[] dirs = dir.GetDirectories("*"); + for (int i = 0; i < dirs.Length; ++i) + { + if ((dirs[i].Attributes & filter) > 0) + continue; + + if (Directory.Exists(dirs[i].FullName)) + Directory.Delete(dirs[i].FullName, true); + } + } + + /// + /// 绝对路径转相对路径 + /// + public static string AbsoluteToRelativePath(string root_path, string absolute_path) + { + absolute_path = absolute_path.Replace('\\', '/'); + int last_idx = absolute_path.LastIndexOf(root_path); + if (last_idx < 0) + return absolute_path; + + int start = last_idx; + if (absolute_path[start] == '/') + start += 1; + + int length = absolute_path.Length - start; + return absolute_path.Substring(start, length); + } + + /// + /// 获得取除路径扩展名的路径 + /// + public static string GetPathWithoutExtension(this string full_name) + { + int last_idx = full_name.LastIndexOfAny(".".ToCharArray()); + if (last_idx < 0) + return full_name; + + return full_name.Substring(0, last_idx); + } + + /// + /// 将字符串转为大写或小写 + /// + /// + /// + /// + public static string GetUpperOrLower(this string tmp, bool isUpper = true) + { + if (isUpper) + return tmp.ToLower(); + else + return tmp.ToUpper(); + } + + /// + /// 判断是否有中文,有转为全拼 + /// + /// + /// + public static string ChineseToPinYin(string text, bool isfile = true) + { + if (HasChinese(text)) + { + return ConvertPinYin(text, isfile).GetUpperOrLower().Replace(" ", ""); + } + else + { + if (isfile) + text = String.Concat("_", text); + return text.GetUpperOrLower(); + } + } + + /// + /// 判断字符串中是否有中文 + /// + private static bool HasChinese(string s) + { + return Regex.IsMatch(s, "[\u4e00-\u9fbb]"); + } + + /// + /// 汉字转全拼 + /// + private static string ConvertPinYin(string text, bool isfile = true) + { + if (string.IsNullOrEmpty(text)) + return text; + + try + { + var sb = new StringBuilder(); + bool isfirstchinese = false; + if (HasChinese(text.ToList()[0].ToString())) + { + isfirstchinese = true; + Debug.Log(text.ToList()[0].ToString() + ":" + isfirstchinese); + } + + for (int i = 0; i < text.ToList().Count; i++) + { + if (text.ToList()[i] <= 127) + sb.Append(text.ToList()[i]); + else + sb.Append($"_{NPinyin.Pinyin.GetPinyin(text.ToList()[i])}_"); + } + + var name = sb.ToString().Replace("__", "_"); + if (!isfile) //裁剪首尾字符“_” + { + name = name.Trim('_'); + } + else + { + name = name.TrimEnd('_'); + if (!isfirstchinese) + name = String.Concat("_", name); + } + + return name; + } + catch (Exception e) + { + Debug.LogError($"拼音转换失败:{text} {e.Message}"); + } + + return text; + } + + /// + /// 删除指定字符后的字符串 + /// + /// 字符串 + /// 符号例如:“ .” + /// + public static string DeleteLastIndex(string fileName, string lastIndex) + { + int index = fileName.LastIndexOf(lastIndex); + if (index >= 0) + { + fileName = fileName.Substring(0, index); + } + + return fileName; + } + + /// + /// 带颜色的日志输出 + /// + public static void LogColor(string s, string path = null, Color color = default) + { + if (string.IsNullOrEmpty(path)) + Debug.Log($"{s}"); + else + { + string assetPath = s.Replace("\\", "/").Replace(Application.dataPath, "Assets"); + Debug.Log($"{assetPath}", + AssetDatabase.LoadAssetAtPath(assetPath)); + } + } + + /// + /// 过滤:去掉首尾空格和换行符【\n】 + /// + private static string FilterTo(string self) + { + self = self.TrimStart(); + self = self.TrimEnd(); + self = self.Replace("\n", ""); + return self; + } + + /// + /// 获取Assets下带.meta文件的资源的路径 + /// + /// 文件夹、资源 + private static string[] GetPathsOfAssetsObject(string objectName) + { + string[] guids = AssetDatabase.FindAssets(objectName); + string[] paths = new string[guids.Length]; + for (int i = 0; i < guids.Length; i++) + { + string path = AssetDatabase.GUIDToAssetPath(guids[i]); + if (path.Contains("Assets")) + paths[i] = path; + } + + return paths; + } + + /// 计算MD5 + public static string CalculateMD5(string file) + { + string result = ""; + FileStream fs = new FileStream(file, FileMode.Open); + try + { + System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); + byte[] retVal = md5.ComputeHash(fs); + fs.Close(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < retVal.Length; i++) + { + sb.Append(retVal[i].ToString("x2")); + } + + result = sb.ToString(); + } + catch (Exception e) + { + UnityEngine.Debug.Log("md5file() fail, error:" + e.Message); + } + finally + { + fs.Close(); + } + + return result; + } + } +#endif +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/Res/FilesUtils.cs.meta b/Assets/00.StaryEvo/Editor/Res/FilesUtils.cs.meta new file mode 100644 index 0000000..d742d94 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/FilesUtils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1c60a5396e9caa14db0afc2d11072688 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0.meta b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0.meta new file mode 100644 index 0000000..1e2ca44 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1956b6bfd54dc07419e22691e1304545 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/Pinyin.cs b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/Pinyin.cs new file mode 100644 index 0000000..fa8bf91 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/Pinyin.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NPinyin +{ + public static class Pinyin + { + /// + /// 取中文文本的拼音首字母 + /// + /// 编码为UTF8的文本 + /// 返回中文对应的拼音首字母 + + public static string GetInitials(string text) + { + text = text.Trim(); + StringBuilder chars = new StringBuilder(); + for (var i = 0; i < text.Length; ++i) + { + string py = GetPinyin(text[i]); + if (py != "") chars.Append(py[0]); + } + + return chars.ToString().ToUpper(); + } + + + /// + /// 取中文文本的拼音首字母 + /// + /// 文本 + /// 源文本的编码 + /// 返回encoding编码类型中文对应的拼音首字母 + public static string GetInitials(string text, Encoding encoding) + { + string temp = ConvertEncoding(text, encoding, Encoding.UTF8); + return ConvertEncoding(GetInitials(temp), Encoding.UTF8, encoding); + } + + + + /// + /// 取中文文本的拼音 + /// + /// 编码为UTF8的文本 + /// 返回中文文本的拼音 + + public static string GetPinyin(string text) + { + StringBuilder sbPinyin = new StringBuilder(); + for (var i = 0; i < text.Length; ++i) + { + string py = GetPinyin(text[i]); + if (py != "") sbPinyin.Append(py); + sbPinyin.Append(" "); + } + + return sbPinyin.ToString().Trim(); + } + + /// + /// 取中文文本的拼音 + /// + /// 编码为UTF8的文本 + /// 源文本的编码 + /// 返回encoding编码类型的中文文本的拼音 + public static string GetPinyin(string text, Encoding encoding) + { + string temp = ConvertEncoding(text.Trim(), encoding, Encoding.UTF8); + return ConvertEncoding(GetPinyin(temp), Encoding.UTF8, encoding); + } + + /// + /// 取和拼音相同的汉字列表 + /// + /// 编码为UTF8的拼音 + /// 取拼音相同的汉字列表,如拼音“ai”将会返回“唉爱……”等 + public static string GetChineseText(string pinyin) + { + string key = pinyin.Trim().ToLower(); + + foreach (string str in PyCode.codes) + { + if (str.StartsWith(key + " ") || str.StartsWith(key + ":")) + return str.Substring(7); + } + + return ""; + } + + + /// + /// 取和拼音相同的汉字列表,编码同参数encoding + /// + /// 编码为encoding的拼音 + /// 编码 + /// 返回编码为encoding的拼音为pinyin的汉字列表,如拼音“ai”将会返回“唉爱……”等 + public static string GetChineseText(string pinyin, Encoding encoding) + { + string text = ConvertEncoding(pinyin, encoding, Encoding.UTF8); + return ConvertEncoding(GetChineseText(text), Encoding.UTF8, encoding); + } + + + + /// + /// 返回单个字符的汉字拼音 + /// + /// 编码为UTF8的中文字符 + /// ch对应的拼音 + public static string GetPinyin(char ch) + { + short hash = GetHashIndex(ch); + for (var i = 0; i < PyHash.hashes[hash].Length; ++i) + { + short index = PyHash.hashes[hash][i]; + var pos = PyCode.codes[index].IndexOf(ch, 7); + if (pos != -1) + return PyCode.codes[index].Substring(0, 6).Trim(); + } + return ch.ToString(); + } + + /// + /// 返回单个字符的汉字拼音 + /// + /// 编码为encoding的中文字符 + /// 编码为encoding的ch对应的拼音 + public static string GetPinyin(char ch, Encoding encoding) + { + ch = ConvertEncoding(ch.ToString(), encoding, Encoding.UTF8)[0]; + return ConvertEncoding(GetPinyin(ch), Encoding.UTF8, encoding); + } + + /// + /// 转换编码 + /// + /// 文本 + /// 源编码 + /// 目标编码 + /// 目标编码文本 + public static string ConvertEncoding(string text, Encoding srcEncoding, Encoding dstEncoding) + { + byte[] srcBytes = srcEncoding.GetBytes(text); + byte[] dstBytes = Encoding.Convert(srcEncoding, dstEncoding, srcBytes); + return dstEncoding.GetString(dstBytes); + } + + /// + /// 取文本索引值 + /// + /// 字符 + /// 文本索引值 + private static short GetHashIndex(char ch) + { + return (short)((uint)ch % PyCode.codes.Length); + } + } +} diff --git a/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/Pinyin.cs.meta b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/Pinyin.cs.meta new file mode 100644 index 0000000..65ca48a --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/Pinyin.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ea36e52653d7c124a8ab2f814bf52457 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyCode.cs b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyCode.cs new file mode 100644 index 0000000..1bbbb5e --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyCode.cs @@ -0,0 +1,410 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NPinyin +{ + internal class PyCode + { + internal static string[] codes = new string[]{ +"a :阿啊吖嗄腌锕", +"ai :爱埃碍矮挨唉哎哀皑癌蔼艾隘捱嗳嗌嫒瑷暧砹锿霭", +"an :安按暗岸案俺氨胺鞍谙埯揞犴庵桉铵鹌黯", +"ang :昂肮盎", +"ao :凹奥敖熬翱袄傲懊澳坳拗嗷岙廒遨媪骜獒聱螯鏊鳌鏖", +"ba :把八吧巴拔霸罢爸坝芭捌扒叭笆疤跋靶耙茇菝岜灞钯粑鲅魃", +"bai :百白败摆柏佰拜稗捭掰", +"ban :办半板班般版拌搬斑扳伴颁扮瓣绊阪坂钣瘢癍舨", +"bang :帮棒邦榜梆膀绑磅蚌镑傍谤蒡浜", +"bao :报保包剥薄胞暴宝饱抱爆堡苞褒雹豹鲍葆孢煲鸨褓趵龅", +"bei :北被倍备背辈贝杯卑悲碑钡狈惫焙孛陂邶埤萆蓓呗悖碚鹎褙鐾鞴", +"ben :本奔苯笨畚坌贲锛", +"beng :泵崩绷甭蹦迸嘣甏", +"bi :比必避闭辟笔壁臂毕彼逼币鼻蔽鄙碧蓖毙毖庇痹敝弊陛匕俾荜荸薜吡哔狴庳愎滗濞弼妣婢嬖璧畀铋秕裨筚箅篦舭襞跸髀", +"bian :变边便编遍辩扁辨鞭贬卞辫匾弁苄忭汴缏飚煸砭碥窆褊蝙笾鳊", +"biao :表标彪膘婊骠杓飑飙镖镳瘭裱鳔髟", +"bie :别鳖憋瘪蹩", +"bin :宾彬斌濒滨摈傧豳缤玢槟殡膑镔髌鬓", +"bing :并病兵柄冰丙饼秉炳禀邴摒", +"bo :波播伯拨博勃驳玻泊菠钵搏铂箔帛舶脖膊渤亳啵饽檗擘礴钹鹁簸跛踣", +"bu :不部步布补捕卜哺埠簿怖卟逋瓿晡钚钸醭", +"ca :擦嚓礤", +"cai :采才材菜财裁彩猜睬踩蔡", +"can :参残蚕灿餐惭惨孱骖璨粲黪", +"cang :藏仓苍舱沧", +"cao :草槽操糙曹嘈漕螬艚", +"ce :测策侧册厕恻", +"cen :岑涔", +"ceng :层蹭", +"cha :查差插察茶叉茬碴搽岔诧猹馇汊姹杈楂槎檫锸镲衩", +"chai :柴拆豺侪钗瘥虿", +"chan :产铲阐搀掺蝉馋谗缠颤冁谄蒇廛忏潺澶羼婵骣觇禅镡蟾躔", +"chang :长常场厂唱肠昌倡偿畅猖尝敞伥鬯苌菖徜怅惝阊娼嫦昶氅鲳", +"chao :朝超潮巢抄钞嘲吵炒怊晁耖", +"che :车彻撤扯掣澈坼砗", +"chen :陈沉称衬尘臣晨郴辰忱趁伧谌谶抻嗔宸琛榇碜龀", +"cheng :成程称城承乘呈撑诚橙惩澄逞骋秤丞埕噌枨柽塍瞠铖铛裎蛏酲", +"chi :持尺齿吃赤池迟翅斥耻痴匙弛驰侈炽傺坻墀茌叱哧啻嗤彳饬媸敕眵鸱瘛褫蚩螭笞篪豉踟魑", +"chong :虫充冲崇宠茺忡憧铳舂艟", +"chou :抽仇臭酬畴踌稠愁筹绸瞅丑俦帱惆瘳雠", +"chu :出处除初础触楚锄储橱厨躇雏滁矗搐亍刍怵憷绌杵楮樗褚蜍蹰黜", +"chuai :揣搋啜膪踹", +"chuan :传船穿串川椽喘舛遄巛氚钏舡", +"chuang:床创窗闯疮幢怆", +"chui :吹垂锤炊捶陲棰槌", +"chun :春纯醇椿唇淳蠢莼鹑蝽", +"chuo :戳绰辍踔龊", +"ci :此次刺磁雌词茨疵辞慈瓷赐茈呲祠鹚糍", +"cong :从丛聪葱囱匆苁淙骢琮璁", +"cou :凑楱辏腠", +"cu :粗促醋簇蔟徂猝殂酢蹙蹴", +"cuan :篡蹿窜汆撺爨镩", +"cui :催脆淬粹摧崔瘁翠萃啐悴璀榱毳隹", +"cun :存村寸忖皴", +"cuo :错措撮磋搓挫厝嵯脞锉矬痤鹾蹉", +"da :大打达答搭瘩耷哒嗒怛妲疸褡笪靼鞑", +"dai :代带待袋戴呆歹傣殆贷逮怠埭甙呔岱迨骀绐玳黛", +"dan :单但弹担蛋淡胆氮丹旦耽郸掸惮诞儋萏啖殚赕眈疸瘅聃箪", +"dang :党当档挡荡谠凼菪宕砀裆", +"dao :到道导刀倒稻岛捣盗蹈祷悼叨忉氘纛", +"de :的得德锝", +"deng :等灯登邓蹬瞪凳噔嶝戥磴镫簦", +"di :地第低敌底帝抵滴弟递堤迪笛狄涤翟嫡蒂缔氐籴诋谛邸荻嘀娣绨柢棣觌砥碲睇镝羝骶", +"dia :嗲", +"dian :电点垫典店颠淀掂滇碘靛佃甸惦奠殿阽坫巅玷钿癜癫簟踮", +"diao :调掉吊碉叼雕凋刁钓铞铫貂鲷", +"die :迭跌爹碟蝶谍叠垤堞揲喋牒瓞耋蹀鲽", +"ding :定顶钉丁订盯叮鼎锭仃啶玎腚碇町疔耵酊", +"diu :丢铥", +"dong :动东冬懂洞冻董栋侗恫垌咚岽峒氡胨胴硐鸫", +"dou :斗豆兜抖陡逗痘蔸窦蚪篼", +"du :度都毒独读渡杜堵镀顿督犊睹赌肚妒芏嘟渎椟牍蠹笃髑黩", +"duan :断端段短锻缎椴煅簖", +"dui :对队堆兑怼憝碓", +"dun :盾吨顿蹲敦墩囤钝遁沌炖砘礅盹镦趸", +"duo :多夺朵掇哆垛躲跺舵剁惰堕咄哚沲缍柁铎裰踱", +"e :而二尔儿恶额恩俄耳饵蛾饿峨鹅讹娥厄扼遏鄂噩谔垩苊莪萼呃愕屙婀轭腭锇锷鹗颚鳄", +"ei :诶", +"en :恩蒽摁", +"er :而二尔儿耳饵洱贰佴迩珥铒鸸鲕", +"fa :发法阀乏伐罚筏珐垡砝", +"fan :反翻范犯饭繁泛番凡烦返藩帆樊矾钒贩蕃蘩幡梵燔畈蹯", +"fang :方放防访房纺仿妨芳肪坊邡枋钫舫鲂", +"fei :非肥飞费废肺沸菲匪啡诽吠芾狒悱淝妃绯榧腓斐扉镄痱蜚篚翡霏鲱", +"fen :分粉奋份粪纷芬愤酚吩氛坟焚汾忿偾瀵棼鲼鼢", +"feng :风封蜂丰缝峰锋疯奉枫烽逢冯讽凤俸酆葑唪沣砜", +"fou :否缶", +"fu :复服副府夫负富附福伏符幅腐浮辅付腹妇孵覆扶辐傅佛缚父弗甫肤氟敷拂俘涪袱抚俯釜斧脯腑赴赋阜讣咐匐凫郛芙苻茯莩菔拊呋幞怫滏艴孚驸绂绋桴赙祓砩黻黼罘稃馥蚨蜉蝠蝮麸趺跗鲋鳆", +"ga :噶嘎尬尕尜旮钆", +"gai :改该盖概钙溉丐陔垓戤赅", +"gan :干杆感敢赶甘肝秆柑竿赣坩苷尴擀泔淦澉绀橄旰矸疳酐", +"gang :刚钢缸纲岗港杠冈肛戆罡筻", +"gao :高搞告稿膏篙皋羔糕镐睾诰郜藁缟槔槁杲锆", +"ge :个各革格割歌隔哥铬阁戈葛搁鸽胳疙蛤鬲仡哿圪塥嗝搿膈硌镉袼虼舸骼", +"gen :根跟亘茛哏艮", +"geng :更耕颈庚羹埂耿梗哽赓绠鲠", +"gong :工公共供功攻巩贡汞宫恭龚躬弓拱珙肱蚣觥", +"gou :够构沟狗钩勾购苟垢佝诟岣遘媾缑枸觏彀笱篝鞲", +"gu :鼓固古骨故顾股谷估雇孤姑辜菇咕箍沽蛊嘏诂菰崮汩梏轱牯牿臌毂瞽罟钴锢鸪痼蛄酤觚鲴鹘", +"gua :挂刮瓜剐寡褂卦诖呱栝胍鸹", +"guai :怪乖拐", +"guan :关管观官灌贯惯冠馆罐棺倌莞掼涫盥鹳矜鳏", +"guang :光广逛咣犷桄胱", +"gui :规贵归硅鬼轨龟桂瑰圭闺诡癸柜跪刽匦刿庋宄妫桧炅晷皈簋鲑鳜", +"gun :滚辊棍衮绲磙鲧", +"guo :国过果锅郭裹馘埚掴呙帼崞猓椁虢聒蜾蝈", +"ha :哈铪", +"hai :还海害孩骸氦亥骇嗨胲醢", +"han :含焊旱喊汉寒汗函韩酣憨邯涵罕翰撼捍憾悍邗菡撖阚瀚晗焓顸颔蚶鼾", +"hang :航夯杭沆绗珩颃", +"hao :好号毫耗豪郝浩壕嚎蒿薅嗥嚆濠灏昊皓颢蚝", +"he :和合河何核赫荷褐喝贺呵禾盒菏貉阂涸鹤诃劾壑嗬阖纥曷盍颌蚵翮", +"hei :黑嘿", +"hen :很狠痕恨", +"heng :横衡恒哼亨蘅桁", +"hong :红洪轰烘哄虹鸿宏弘黉訇讧荭蕻薨闳泓", +"hou :后候厚侯喉猴吼堠後逅瘊篌糇鲎骺", +"hu :护互湖呼户弧乎胡糊虎忽瑚壶葫蝴狐唬沪冱唿囫岵猢怙惚浒滹琥槲轷觳烀煳戽扈祜瓠鹄鹕鹱笏醐斛", +"hua :化花话划滑华画哗猾骅桦砉铧", +"huai :坏怀淮槐徊踝", +"huan :环换欢缓患幻焕桓唤痪豢涣宦郇奂萑擐圜獾洹浣漶寰逭缳锾鲩鬟", +"huang :黄簧荒皇慌蝗磺凰惶煌晃幌恍谎隍徨湟潢遑璜肓癀蟥篁鳇", +"hui :会回灰挥辉汇毁慧恢绘惠徽蛔悔卉晦贿秽烩讳诲诙茴荟蕙咴哕喙隳洄浍彗缋珲晖恚虺蟪麾", +"hun :混浑荤昏婚魂诨馄阍溷", +"huo :活或火货获伙霍豁惑祸劐藿攉嚯夥钬锪镬耠蠖", +"ji :级及机极几积给基记己计集即际季激济技击继急剂既纪寄挤鸡迹绩吉脊辑籍疾肌棘畸圾稽箕饥讥姬缉汲嫉蓟冀伎祭悸寂忌妓藉丌亟乩剞佶偈诘墼芨芰荠蒺蕺掎叽咭哜唧岌嵴洎屐骥畿玑楫殛戟戢赍觊犄齑矶羁嵇稷瘠虮笈笄暨跻跽霁鲚鲫髻麂", +"jia :加家架价甲夹假钾贾稼驾嘉枷佳荚颊嫁伽郏葭岬浃迦珈戛胛恝铗镓痂瘕袷蛱笳袈跏", +"jian :间件见建坚减检践尖简碱剪艰渐肩键健柬鉴剑歼监兼奸箭茧舰俭笺煎缄硷拣捡荐槛贱饯溅涧僭谏谫菅蒹搛湔蹇謇缣枧楗戋戬牮犍毽腱睑锏鹣裥笕翦趼踺鲣鞯", +"jiang :将降讲江浆蒋奖疆僵姜桨匠酱茳洚绛缰犟礓耩糨豇", +"jiao :较教交角叫脚胶浇焦搅酵郊铰窖椒礁骄娇嚼矫侥狡饺缴绞剿轿佼僬艽茭挢噍峤徼姣敫皎鹪蛟醮跤鲛", +"jie :结阶解接节界截介借届街揭洁杰竭皆秸劫桔捷睫姐戒藉芥疥诫讦拮喈嗟婕孑桀碣疖颉蚧羯鲒骱", +"jin :进金近紧斤今尽仅劲浸禁津筋锦晋巾襟谨靳烬卺荩堇噤馑廑妗缙瑾槿赆觐衿", +"jing :经精京径井静竟晶净境镜景警茎敬惊睛竞荆兢鲸粳痉靖刭儆阱菁獍憬泾迳弪婧肼胫腈旌", +"jiong :炯窘迥扃", +"jiu :就九旧究久救酒纠揪玖韭灸厩臼舅咎疚僦啾阄柩桕鸠鹫赳鬏", +"ju :具据局举句聚距巨居锯剧矩拒鞠拘狙疽驹菊咀沮踞俱惧炬倨讵苣苴莒掬遽屦琚椐榘榉橘犋飓钜锔窭裾趄醵踽龃雎鞫", +"juan :卷捐鹃娟倦眷绢鄄狷涓桊蠲锩镌隽", +"jue :决觉绝掘撅攫抉倔爵诀厥劂谲矍蕨噘噱崛獗孓珏桷橛爝镢蹶觖", +"jun :军均菌君钧峻俊竣浚郡骏捃皲筠麇", +"ka :卡喀咖咯佧咔胩", +"kai :开凯揩楷慨剀垲蒈忾恺铠锎锴", +"kan :看刊坎堪勘砍侃莰戡龛瞰", +"kang :抗康炕慷糠扛亢伉闶钪", +"kao :考靠拷烤尻栲犒铐", +"ke :可克科刻客壳颗棵柯坷苛磕咳渴课嗑岢恪溘骒缂珂轲氪瞌钶锞稞疴窠颏蝌髁", +"ken :肯啃垦恳裉", +"keng :坑吭铿", +"kong :孔空控恐倥崆箜", +"kou :口扣抠寇芤蔻叩眍筘", +"ku :苦库枯酷哭窟裤刳堀喾绔骷", +"kua :跨夸垮挎胯侉", +"kuai :快块筷侩蒯郐哙狯脍", +"kuan :宽款髋", +"kuang :况矿狂框匡筐眶旷诓诳邝圹夼哐纩贶", +"kui :奎溃馈亏盔岿窥葵魁傀愧馗匮夔隗蒉揆喹喟悝愦逵暌睽聩蝰篑跬", +"kun :困昆坤捆悃阃琨锟醌鲲髡", +"kuo :扩括阔廓蛞", +"la :拉啦蜡腊蓝垃喇辣剌邋旯砬瘌", +"lai :来赖莱崃徕涞濑赉睐铼癞籁", +"lan :兰烂蓝览栏婪拦篮阑澜谰揽懒缆滥岚漤榄斓罱镧褴", +"lang :浪朗郎狼琅榔廊莨蒗啷阆锒稂螂", +"lao :老劳牢涝捞佬姥酪烙唠崂栳铑铹痨耢醪", +"le :了乐勒肋仂叻泐鳓", +"lei :类雷累垒泪镭蕾磊儡擂肋羸诔嘞嫘缧檑耒酹", +"leng :冷棱楞塄愣", +"li :理里利力立离例历粒厘礼李隶黎璃励犁梨丽厉篱狸漓鲤莉荔吏栗砾傈俐痢沥哩俪俚郦坜苈莅蓠藜呖唳喱猁溧澧逦娌嫠骊缡枥栎轹戾砺詈罹锂鹂疠疬蛎蜊蠡笠篥粝醴跞雳鲡鳢黧", +"lia :俩", +"lian :连联练炼脸链莲镰廉怜涟帘敛恋蔹奁潋濂琏楝殓臁裢裣蠊鲢", +"liang :量两粮良亮梁凉辆粱晾谅墚椋踉靓魉", +"liao :料疗辽僚撩聊燎寥潦撂镣廖蓼尥嘹獠寮缭钌鹩", +"lie :列裂烈劣猎冽埒捩咧洌趔躐鬣", +"lin :林磷临邻淋麟琳霖鳞凛赁吝蔺啉嶙廪懔遴檩辚膦瞵粼躏", +"ling :领另零令灵岭铃龄凌陵拎玲菱伶羚酃苓呤囹泠绫柃棂瓴聆蛉翎鲮", +"liu :流六留刘硫柳馏瘤溜琉榴浏遛骝绺旒熘锍镏鹨鎏", +"long :龙垄笼隆聋咙窿拢陇垅茏泷珑栊胧砻癃", +"lou :漏楼娄搂篓陋偻蒌喽嵝镂瘘耧蝼髅", +"lu :路率露绿炉律虑滤陆氯鲁铝录旅卢吕芦颅庐掳卤虏麓碌赂鹿潞禄戮驴侣履屡缕垆撸噜闾泸渌漉逯璐栌榈橹轳辂辘氇胪膂镥稆鸬鹭褛簏舻鲈", +"luan :卵乱峦挛孪滦脔娈栾鸾銮", +"lue :略掠锊", +"lun :论轮伦抡仑沦纶囵", +"luo :落罗螺洛络逻萝锣箩骡裸骆倮蠃荦捋摞猡泺漯珞椤脶镙瘰雒", +"m :呒", +"ma :马麻吗妈骂嘛码玛蚂唛犸嬷杩蟆", +"mai :麦脉卖买埋迈劢荬霾", +"man :满慢曼漫蔓瞒馒蛮谩墁幔缦熳镘颟螨鳗鞔", +"mang :忙芒盲茫氓莽邙漭硭蟒", +"mao :毛矛冒貌贸帽猫茅锚铆卯茂袤茆峁泖瑁昴牦耄旄懋瞀蟊髦", +"me :么麽", +"mei :没每美煤霉酶梅妹眉玫枚媒镁昧寐媚莓嵋猸浼湄楣镅鹛袂魅", +"men :们门闷扪焖懑钔", +"meng :孟猛蒙盟梦萌锰檬勐甍瞢懵朦礞虻蜢蠓艋艨", +"mi :米密迷蜜秘眯醚靡糜谜弥觅泌幂芈谧蘼咪嘧猕汨宓弭脒祢敉糸縻麋", +"mian :面棉免绵眠冕勉娩缅沔渑湎腼眄", +"miao :苗秒描庙妙瞄藐渺喵邈缈缪杪淼眇鹋", +"mie :灭蔑咩蠛篾", +"min :民敏抿皿悯闽苠岷闵泯缗玟珉愍黾鳘", +"ming :命明名鸣螟铭冥茗溟暝瞑酩", +"miu :谬", +"mo :磨末模膜摸墨摩莫抹默摹蘑魔沫漠寞陌谟茉蓦馍嫫殁镆秣瘼耱貊貘", +"mou :某谋牟侔哞眸蛑蝥鍪", +"mu :亩目木母墓幕牧姆穆拇牡暮募慕睦仫坶苜沐毪钼", +"n :嗯", +"na :那南哪拿纳钠呐娜捺肭镎衲", +"nai :耐奶乃氖奈鼐艿萘柰", +"nan :南难男喃囝囡楠腩蝻赧", +"nang :囊攮囔馕曩", +"nao :脑闹挠恼淖孬垴呶猱瑙硇铙蛲", +"ne :呢讷", +"nei :内馁", +"nen :嫩恁", +"neng :能", +"ni :你泥尼逆拟尿妮霓倪匿腻溺伲坭猊怩昵旎慝睨铌鲵", +"nian :年念粘蔫拈碾撵捻酿廿埝辇黏鲇鲶", +"niang :娘", +"niao :尿鸟茑嬲脲袅", +"nie :镍啮涅捏聂孽镊乜陧蘖嗫颞臬蹑", +"nin :您", +"ning :宁凝拧柠狞泞佞苎咛甯聍", +"niu :牛扭钮纽狃忸妞", +"nong :农弄浓脓侬哝", +"nou :耨", +"nu :女奴努怒弩胬孥驽恧钕衄", +"nuan :暖", +"nue :虐", +"nuo :诺挪懦糯傩搦喏锘", +"o :欧偶哦鸥殴藕呕沤讴噢怄瓯耦", +"ou :欧偶鸥殴藕呕沤讴怄瓯耦", +"pa :怕派爬帕啪趴琶葩杷筢", +"pai :派排拍牌哌徘湃俳蒎", +"pan :判盘叛潘攀磐盼畔胖爿泮袢襻蟠蹒", +"pang :旁乓庞耪胖彷滂逄螃", +"pao :跑炮刨抛泡咆袍匏狍庖脬疱", +"pei :配培陪胚呸裴赔佩沛辔帔旆锫醅霈", +"pen :喷盆湓", +"peng :碰棚蓬朋捧膨砰抨烹澎彭硼篷鹏堋嘭怦蟛", +"pi :批皮坯脾疲砒霹披劈琵毗啤匹痞僻屁譬丕仳陴邳郫圮鼙芘擗噼庀淠媲纰枇甓睥罴铍癖疋蚍蜱貔", +"pian :片偏篇骗谝骈犏胼翩蹁", +"piao :票漂飘瓢剽嘌嫖缥殍瞟螵", +"pie :撇瞥丿苤氕", +"pin :品贫频拼苹聘拚姘嫔榀牝颦", +"ping :平评瓶凭苹乒坪萍屏俜娉枰鲆", +"po :破迫坡泼颇婆魄粕叵鄱珀攴钋钷皤笸", +"pou :剖裒掊", +"pu :普谱扑埔铺葡朴蒲仆莆菩圃浦曝瀑匍噗溥濮璞氆镤镨蹼", +"qi :起其气期七器齐奇汽企漆欺旗畦启弃歧栖戚妻凄柒沏棋崎脐祈祁骑岂乞契砌迄泣讫亓俟圻芑芪萁萋葺蕲嘁屺岐汔淇骐绮琪琦杞桤槭耆欹祺憩碛颀蛴蜞綦綮蹊鳍麒", +"qia :恰掐洽葜髂", +"qian :前千钱浅签迁铅潜牵钳谴扦钎仟谦乾黔遣堑嵌欠歉倩佥阡芊芡茜荨掮岍悭慊骞搴褰缱椠肷愆钤虔箬箝", +"qiang :强枪抢墙腔呛羌蔷戕嫱樯戗炝锖锵镪襁蜣羟跄", +"qiao :桥瞧巧敲乔蕉橇锹悄侨鞘撬翘峭俏窍劁诮谯荞愀憔樵硗跷鞒", +"qie :切且茄怯窃郄惬妾挈锲箧", +"qin :亲侵勤秦钦琴芹擒禽寝沁芩揿吣嗪噙溱檎锓覃螓衾", +"qing :情清青轻倾请庆氢晴卿擎氰顷苘圊檠磬蜻罄箐謦鲭黥", +"qiong :穷琼邛茕穹蛩筇跫銎", +"qiu :求球秋丘邱囚酋泅俅巯犰湫逑遒楸赇虬蚯蝤裘糗鳅鼽", +"qu :去区取曲渠屈趋驱趣蛆躯娶龋诎劬蕖蘧岖衢阒璩觑氍朐祛磲鸲癯蛐蠼麴瞿黢", +"quan :全权圈劝泉醛颧痊拳犬券诠荃悛绻辁畎铨蜷筌鬈", +"que :确却缺炔瘸鹊榷雀阕阙悫", +"qun :群裙逡", +"ran :然燃染冉苒蚺髯", +"rang :让壤嚷瓤攘禳穰", +"rao :绕扰饶荛娆桡", +"re :热惹", +"ren :人认任仁刃忍壬韧妊纫仞荏葚饪轫稔衽", +"reng :仍扔", +"ri :日", +"rong :容溶荣熔融绒戎茸蓉冗嵘狨榕肜蝾", +"rou :肉揉柔糅蹂鞣", +"ru :如入儒乳茹蠕孺辱汝褥蓐薷嚅洳溽濡缛铷襦颥", +"ruan :软阮朊", +"rui :瑞锐蕊芮蕤枘睿蚋", +"run :润闰", +"ruo :弱若偌", +"sa :撒萨洒卅仨挲脎飒", +"sai :塞赛腮鳃噻", +"san :三散叁伞馓毵糁", +"sang :桑丧嗓搡磉颡", +"sao :扫搔骚嫂埽缫缲臊瘙鳋", +"se :色瑟涩啬铯穑", +"sen :森", +"seng :僧", +"sha :沙杀砂啥纱莎刹傻煞杉唼歃铩痧裟霎鲨", +"shai :筛晒", +"shan :山闪善珊扇陕苫杉删煽衫擅赡膳汕缮剡讪鄯埏芟潸姗嬗骟膻钐疝蟮舢跚鳝", +"shang :上商伤尚墒赏晌裳垧绱殇熵觞", +"shao :少烧稍绍哨梢捎芍勺韶邵劭苕潲蛸筲艄", +"she :社设射摄舌涉舍蛇奢赊赦慑厍佘猞滠歙畲麝", +"shen :深身神伸甚渗沈肾审申慎砷呻娠绅婶诜谂莘哂渖椹胂矧蜃", +"sheng :生胜声省升盛绳剩圣牲甥嵊晟眚笙", +"shi :是时十使事实式识世试石什示市史师始施士势湿适食失视室氏蚀诗释拾饰驶狮尸虱矢屎柿拭誓逝嗜噬仕侍恃谥埘莳蓍弑轼贳炻铈螫舐筮酾豕鲥鲺", +"shou :手受收首守授寿兽售瘦狩绶艏", +"shu :数书树属术输述熟束鼠疏殊舒蔬薯叔署枢梳抒淑赎孰暑曙蜀黍戍竖墅庶漱恕丨倏塾菽摅沭澍姝纾毹腧殳秫", +"shua :刷耍唰", +"shuai :衰帅摔甩蟀", +"shuan :栓拴闩涮", +"shuang:双霜爽孀", +"shui :水谁睡税", +"shun :顺吮瞬舜", +"shuo :说硕朔烁蒴搠妁槊铄", +"si :四思死斯丝似司饲私撕嘶肆寺嗣伺巳厮兕厶咝汜泗澌姒驷缌祀锶鸶耜蛳笥", +"song :松送宋颂耸怂讼诵凇菘崧嵩忪悚淞竦", +"sou :搜艘擞嗽叟薮嗖嗾馊溲飕瞍锼螋", +"su :素速苏塑缩俗诉宿肃酥粟僳溯夙谡蔌嗉愫涑簌觫稣", +"suan :算酸蒜狻", +"sui :随穗碎虽岁隋绥髓遂隧祟谇荽濉邃燧眭睢", +"sun :损孙笋荪狲飧榫隼", +"suo :所缩锁索蓑梭唆琐唢嗦嗍娑桫睃羧", +"ta :他它她塔踏塌獭挞蹋闼溻遢榻沓铊趿鳎", +"tai :台太态胎抬泰苔酞汰邰薹肽炱钛跆鲐", +"tan :谈碳探炭坦贪滩坍摊瘫坛檀痰潭谭毯袒叹郯澹昙忐钽锬", +"tang :堂糖唐塘汤搪棠膛倘躺淌趟烫傥帑溏瑭樘铴镗耥螗螳羰醣", +"tao :套讨逃陶萄桃掏涛滔绦淘鼗啕洮韬焘饕", +"te :特忒忑铽", +"teng :腾疼藤誊滕", +"ti :提题体替梯惕剔踢锑蹄啼嚏涕剃屉倜悌逖缇鹈裼醍", +"tian :天田添填甜恬舔腆掭忝阗殄畋", +"tiao :条跳挑迢眺佻祧窕蜩笤粜龆鲦髫", +"tie :铁贴帖萜餮", +"ting :听停庭挺廷厅烃汀亭艇莛葶婷梃铤蜓霆", +"tong :同通统铜痛筒童桶桐酮瞳彤捅佟仝茼嗵恸潼砼", +"tou :头投透偷钭骰", +"tu :图土突途徒凸涂吐兔屠秃堍荼菟钍酴", +"tuan :团湍抟彖疃", +"tui :推退腿颓蜕褪煺", +"tun :吞屯臀氽饨暾豚", +"tuo :脱拖托妥椭鸵陀驮驼拓唾乇佗坨庹沱柝橐砣箨酡跎鼍", +"wa :瓦挖哇蛙洼娃袜佤娲腽", +"wai :外歪", +"wan :完万晚弯碗顽湾挽玩豌丸烷皖惋宛婉腕剜芄菀纨绾琬脘畹蜿", +"wang :往王望网忘妄亡旺汪枉罔尢惘辋魍", +"wei :为位委围维唯卫微伟未威危尾谓喂味胃魏伪违韦畏纬巍桅惟潍苇萎蔚渭尉慰偎诿隈葳薇囗帏帷崴嵬猥猬闱沩洧涠逶娓玮韪軎炜煨痿艉鲔", +"wen :问温文稳纹闻蚊瘟吻紊刎阌汶璺雯", +"weng :嗡翁瓮蓊蕹", +"wo :我握窝蜗涡沃挝卧斡倭莴喔幄渥肟硪龌", +"wu :无五物武务误伍舞污悟雾午屋乌吴诬钨巫呜芜梧吾毋捂侮坞戊晤勿兀仵阢邬圬芴唔庑怃忤浯寤迕妩婺骛杌牾焐鹉鹜痦蜈鋈鼯", +"xi :系席西习细吸析喜洗铣稀戏隙希息袭锡烯牺悉惜溪昔熙硒矽晰嘻膝夕熄汐犀檄媳僖兮隰郗菥葸蓰奚唏徙饩阋浠淅屣嬉玺樨曦觋欷熹禊禧皙穸蜥螅蟋舄舾羲粞翕醯鼷", +"xia :下夏吓狭霞瞎虾匣辖暇峡侠厦呷狎遐瑕柙硖罅黠", +"xian :线现先县限显鲜献险陷宪纤掀弦腺锨仙咸贤衔舷闲涎嫌馅羡冼苋莶藓岘猃暹娴氙燹祆鹇痫蚬筅籼酰跣跹霰", +"xiang :想向相象响项箱乡香像详橡享湘厢镶襄翔祥巷芗葙饷庠骧缃蟓鲞飨", +"xiao :小消削效笑校销硝萧肖孝霄哮嚣宵淆晓啸哓崤潇逍骁绡枭枵筱箫魈", +"xie :些写斜谢协械卸屑鞋歇邪胁蟹泄泻楔蝎挟携谐懈偕亵勰燮薤撷獬廨渫瀣邂绁缬榭榍躞", +"xin :新心信锌芯辛欣薪忻衅囟馨昕歆鑫", +"xing :行性形型星兴醒姓幸腥猩惺刑邢杏陉荇荥擤饧悻硎", +"xiong :雄胸兄凶熊匈汹芎", +"xiu :修锈休袖秀朽羞嗅绣咻岫馐庥溴鸺貅髹", +"xu :续许须需序虚絮畜叙蓄绪徐墟戌嘘酗旭恤婿诩勖圩蓿洫溆顼栩煦盱胥糈醑", +"xuan :选旋宣悬玄轩喧癣眩绚儇谖萱揎泫渲漩璇楦暄炫煊碹铉镟痃", +"xue :学血雪穴靴薛谑泶踅鳕", +"xun :训旬迅讯寻循巡勋熏询驯殉汛逊巽埙荀蕈薰峋徇獯恂洵浔曛醺鲟", +"ya :压亚呀牙芽雅蚜鸭押鸦丫崖衙涯哑讶伢垭揠岈迓娅琊桠氩砑睚痖", +"yan :验研严眼言盐演岩沿烟延掩宴炎颜燕衍焉咽阉淹蜒阎奄艳堰厌砚雁唁彦焰谚厣赝俨偃兖谳郾鄢菸崦恹闫阏湮滟妍嫣琰檐晏胭焱罨筵酽魇餍鼹", +"yang :样养氧扬洋阳羊秧央杨仰殃鸯佯疡痒漾徉怏泱炀烊恙蛘鞅", +"yao :要药摇腰咬邀耀疟妖瑶尧遥窑谣姚舀夭爻吆崾徭幺珧杳轺曜肴鹞窈繇鳐", +"ye :也业页叶液夜野爷冶椰噎耶掖曳腋靥谒邺揶晔烨铘", +"yi :一以义意已移医议依易乙艺益异宜仪亿遗伊役衣疑亦谊翼译抑忆疫壹揖铱颐夷胰沂姨彝椅蚁倚矣邑屹臆逸肄裔毅溢诣翌绎刈劓佚佾诒圯埸懿苡荑薏弈奕挹弋呓咦咿噫峄嶷猗饴怿怡悒漪迤驿缢殪轶贻旖熠眙钇镒镱痍瘗癔翊蜴舣羿翳酏黟", +"yin :因引阴印音银隐饮荫茵殷姻吟淫寅尹胤鄞垠堙茚吲喑狺夤洇氤铟瘾窨蚓霪龈", +"ying :应影硬营英映迎樱婴鹰缨莹萤荧蝇赢盈颖嬴郢茔莺萦蓥撄嘤膺滢潆瀛瑛璎楹媵鹦瘿颍罂", +"yo :哟唷", +"yong :用勇永拥涌蛹庸佣臃痈雍踊咏泳恿俑壅墉喁慵邕镛甬鳙饔", +"you :有由又油右友优幼游尤诱犹幽悠忧邮铀酉佑釉卣攸侑莠莜莸呦囿宥柚猷牖铕疣蚰蚴蝣鱿黝鼬", +"yu :于与育鱼雨玉余遇预域语愈渔予羽愚御欲宇迂淤盂榆虞舆俞逾愉渝隅娱屿禹芋郁吁喻峪狱誉浴寓裕豫驭禺毓伛俣谀谕萸蓣揄圄圉嵛狳饫馀庾阈鬻妪妤纡瑜昱觎腴欤於煜熨燠聿钰鹆鹬瘐瘀窬窳蜮蝓竽臾舁雩龉", +"yuan :员原圆源元远愿院缘援园怨鸳渊冤垣袁辕猿苑垸塬芫掾沅媛瑗橼爰眢鸢螈箢鼋", +"yue :月越约跃曰阅钥岳粤悦龠瀹樾刖钺", +"yun :运云匀允孕耘郧陨蕴酝晕韵郓芸狁恽愠纭韫殒昀氲熨", +"za :杂咱匝砸咋咂", +"zai :在再载栽灾哉宰崽甾", +"zan :赞咱暂攒拶瓒昝簪糌趱錾", +"zang :脏葬赃奘驵臧", +"zao :造早遭燥凿糟枣皂藻澡蚤躁噪灶唣", +"ze :则择责泽仄赜啧帻迮昃笮箦舴", +"zei :贼", +"zen :怎谮", +"zeng :增曾憎赠缯甑罾锃", +"zha :扎炸闸铡轧渣喳札眨栅榨乍诈揸吒咤哳砟痄蚱齄", +"zhai :寨摘窄斋宅债砦瘵", +"zhan :战展站占瞻毡詹沾盏斩辗崭蘸栈湛绽谵搌旃", +"zhang :张章掌仗障胀涨账樟彰漳杖丈帐瘴仉鄣幛嶂獐嫜璋蟑", +"zhao :照找招召赵爪罩沼兆昭肇诏棹钊笊", +"zhe :这着者折哲浙遮蛰辙锗蔗谪摺柘辄磔鹧褶蜇赭", +"zhen :真针阵镇振震珍诊斟甄砧臻贞侦枕疹圳蓁浈缜桢榛轸赈胗朕祯畛稹鸩箴", +"zheng :争正政整证征蒸症郑挣睁狰怔拯帧诤峥徵钲铮筝", +"zhi :之制治只质指直支织止至置志值知执职植纸致枝殖脂智肢秩址滞汁芝吱蜘侄趾旨挚掷帜峙稚炙痔窒卮陟郅埴芷摭帙忮彘咫骘栉枳栀桎轵轾贽胝膣祉祗黹雉鸷痣蛭絷酯跖踬踯豸觯", +"zhong :中种重众钟终忠肿仲盅衷冢锺螽舯踵", +"zhou :轴周洲州皱骤舟诌粥肘帚咒宙昼荮啁妯纣绉胄碡籀酎", +"zhu :主注著住助猪铸株筑柱驻逐祝竹贮珠朱诸蛛诛烛煮拄瞩嘱蛀伫侏邾茱洙渚潴杼槠橥炷铢疰瘃竺箸舳翥躅麈", +"zhua :抓", +"zhuai :拽", +"zhuan :转专砖撰赚篆啭馔颛", +"zhuang:装状壮庄撞桩妆僮", +"zhui :追锥椎赘坠缀惴骓缒", +"zhun :准谆肫窀", +"zhuo :捉桌拙卓琢茁酌啄灼浊倬诼擢浞涿濯焯禚斫镯", +"zi :子自资字紫仔籽姿兹咨滋淄孜滓渍谘嵫姊孳缁梓辎赀恣眦锱秭耔笫粢趑觜訾龇鲻髭", +"zong :总纵宗综棕鬃踪偬枞腙粽", +"zou :走邹奏揍诹陬鄹驺鲰", +"zu :组族足阻祖租卒诅俎菹镞", +"zuan :钻纂攥缵躜", +"zui :最罪嘴醉蕞", +"zun :尊遵撙樽鳟", +"zuo :作做左座坐昨佐柞阼唑嘬怍胙祚"}; + } +} diff --git a/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyCode.cs.meta b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyCode.cs.meta new file mode 100644 index 0000000..839ed74 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyCode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f62374cec666c6548b4b870066c57c86 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyHash.cs b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyHash.cs new file mode 100644 index 0000000..883c072 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyHash.cs @@ -0,0 +1,411 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NPinyin +{ + internal class PyHash + { + internal static short[][] hashes = new short[][] { +new short[]{23, 70, 96, 128, 154, 165, 172, 195}, +new short[]{25, 35, 87, 108, 120, 128, 132, 137, 168, 180, 325, 334, 336, 353, 361, 380}, +new short[]{23, 34, 46, 81, 82, 87, 134, 237, 255, 288, 317, 322, 354, 359}, +new short[]{7, 11, 37, 49, 53, 56, 131, 132, 146, 176, 315, 372}, +new short[]{11, 69, 73, 87, 96, 103, 159, 175, 195, 296, 298, 359, 361}, +new short[]{57, 87, 115, 126, 149, 244, 282, 298, 308, 345, 355}, +new short[]{19, 37, 117, 118, 141, 154, 196, 216, 267, 301, 327, 333, 337, 347}, +new short[]{4, 11, 59, 61, 62, 87, 119, 169, 183, 198, 262, 334, 362, 380}, +new short[]{37, 135, 167, 170, 246, 250, 334, 341, 351, 354, 386, 390, 398}, +new short[]{5, 6, 52, 55, 76, 146, 165, 244, 256, 266, 300, 318, 331}, +new short[]{6, 71, 94, 129, 137, 141, 169, 179, 225, 226, 235, 248, 289, 290, 333, 345, 391}, +new short[]{0, 33, 37, 62, 90, 131, 205, 246, 268, 343, 349, 380}, +new short[]{31, 62, 85, 115, 117, 150, 159, 167, 171, 204, 215, 252, 343}, +new short[]{69, 81, 98, 140, 165, 195, 239, 240, 259, 265, 329, 368, 375, 392, 393}, +new short[]{13, 81, 82, 123, 132, 144, 154, 165, 334, 336, 345, 348, 349, 355, 367, 377, 383}, +new short[]{31, 32, 44, 57, 76, 83, 87, 129, 151, 172, 176, 183, 184, 193, 221, 235, 285, 288, 305}, +new short[]{10, 14, 60, 76, 85, 97, 115, 125, 128, 130, 286, 288, 301, 313, 382}, +new short[]{62, 128, 136, 175, 211, 240, 254, 273, 274, 317, 330, 344, 349, 360, 380}, +new short[]{29, 47, 52, 116, 126, 127, 130, 133, 191, 284, 288, 306, 353, 361, 383}, +new short[]{1, 15, 25, 67, 83, 90, 117, 121, 150, 228, 308, 324, 336, 351, 386}, +new short[]{34, 37, 67, 101, 103, 117, 127, 165, 168, 254, 267, 272, 274, 288, 305, 310, 323, 329, 333, 358, 378}, +new short[]{5, 74, 103, 135, 163, 165, 171, 244, 262, 266, 334, 352, 390, 397}, +new short[]{4, 17, 95, 125, 165, 186, 203, 221, 252, 282, 317, 333, 339, 348, 351, 353}, +new short[]{74, 79, 81, 84, 92, 110, 116, 117, 131, 132, 154, 199, 241, 251, 300, 306, 349, 359, 383, 387}, +new short[]{40, 83, 127, 144, 161, 188, 249, 288, 344, 382, 388}, +new short[]{8, 55, 61, 76, 85, 98, 111, 127, 186, 230, 241, 247, 267, 287, 327, 341, 344, 347, 359, 364}, +new short[]{20, 59, 69, 80, 117, 129, 176, 186, 191, 237, 275, 289, 309, 338, 375, 380}, +new short[]{5, 15, 25, 35, 40, 129, 174, 236, 274, 337, 347}, +new short[]{14, 22, 47, 56, 87, 120, 129, 144, 155, 160, 237, 283, 284, 309, 327, 337, 365, 372}, +new short[]{1, 14, 47, 132, 198, 254, 255, 300, 310, 335, 336, 372}, +new short[]{2, 36, 64, 96, 125, 176, 184, 190, 211, 271, 308, 315, 367}, +new short[]{20, 76, 79, 81, 110, 117, 120, 129, 182, 192, 235, 353, 378}, +new short[]{37, 83, 88, 92, 111, 127, 243, 303, 324, 325, 348, 353, 359, 371, 377}, +new short[]{5, 87, 90, 124, 127, 180, 259, 288, 290, 302, 312, 313, 324, 332}, +new short[]{55, 62, 89, 98, 108, 132, 168, 240, 248, 322, 325, 327, 347, 353, 391, 396}, +new short[]{4, 8, 13, 35, 37, 39, 41, 64, 111, 174, 212, 245, 248, 251, 263, 288, 335, 373, 375}, +new short[]{10, 39, 93, 110, 168, 227, 228, 254, 288, 336, 378, 381}, +new short[]{75, 92, 122, 176, 198, 211, 214, 283, 334, 353, 359, 379, 386}, +new short[]{5, 8, 13, 19, 57, 87, 104, 125, 130, 176, 202, 249, 252, 290, 309, 391}, +new short[]{88, 132, 173, 176, 235, 247, 253, 292, 324, 328, 339, 359}, +new short[]{19, 32, 61, 84, 87, 118, 120, 125, 129, 132, 181, 190, 288, 290, 331, 355, 359, 366}, +new short[]{13, 25, 46, 126, 140, 157, 165, 225, 226, 252, 288, 304, 327, 353, 378}, +new short[]{12, 14, 26, 56, 72, 95, 131, 132, 134, 142, 253, 298, 337, 361, 391}, +new short[]{4, 18, 37, 49, 87, 93, 196, 225, 226, 246, 248, 250, 255, 310, 354, 358}, +new short[]{64, 87, 110, 111, 128, 135, 151, 165, 177, 188, 191, 268, 312, 334, 352, 354, 357, 371}, +new short[]{10, 17, 19, 30, 40, 48, 81, 97, 125, 129, 130, 182, 234, 305, 328, 393}, +new short[]{13, 69, 80, 114, 192, 200, 235, 343, 345, 353, 354, 360, 374, 378, 383}, +new short[]{83, 87, 94, 105, 107, 124, 144, 153, 219, 290, 298, 324, 349, 358, 367}, +new short[]{10, 36, 142, 169, 221, 232, 241, 246, 346, 347, 375, 383, 390}, +new short[]{26, 104, 126, 143, 176, 186, 241, 247, 250, 318, 320, 333, 360}, +new short[]{66, 92, 116, 148, 191, 215, 254, 333, 334, 335, 336, 351, 353, 358, 380}, +new short[]{9, 37, 55, 56, 76, 79, 90, 111, 122, 124, 161, 192, 247, 313, 353, 359, 374}, +new short[]{17, 30, 34, 56, 64, 68, 90, 125, 151, 168, 176, 188, 286, 333, 338, 360}, +new short[]{26, 143, 173, 182, 190, 194, 246, 284, 286, 328, 333, 355, 357, 360, 362, 363, 377, 380}, +new short[]{1, 13, 87, 122, 168, 171, 186, 201, 297, 328, 349, 352, 380}, +new short[]{18, 39, 61, 88, 98, 123, 129, 131, 148, 162, 165, 243, 285, 314, 340, 349, 360, 377, 378}, +new short[]{67, 98, 117, 118, 122, 128, 156, 174, 184, 207, 244, 250, 330, 335, 342, 372, 375}, +new short[]{13, 38, 63, 160, 180, 185, 189, 190, 219, 248, 253, 275, 297, 318, 355}, +new short[]{1, 44, 47, 93, 107, 172, 235, 276, 281, 287, 290, 306, 333, 334, 337, 347, 353, 376}, +new short[]{13, 15, 32, 125, 127, 157, 165, 176, 236, 344, 350, 381}, +new short[]{47, 65, 93, 134, 159, 174, 218, 282, 318, 336, 358, 373, 379}, +new short[]{7, 17, 40, 66, 102, 141, 154, 159, 165, 172, 174, 177, 328, 329, 334, 348, 379, 382}, +new short[]{4, 34, 36, 76, 79, 122, 127, 138, 176, 241, 267, 309, 334, 367, 382}, +new short[]{9, 17, 33, 46, 90, 103, 125, 138, 144, 157, 185, 198, 224, 250, 260, 291, 326, 343, 349, 377, 381}, +new short[]{29, 31, 53, 58, 134, 138, 193, 287, 305, 308, 333, 334}, +new short[]{13, 64, 83, 93, 129, 192, 227, 244, 397}, +new short[]{7, 8, 14, 78, 85, 103, 138, 175, 176, 200, 203, 234, 301, 313, 361}, +new short[]{13, 75, 87, 111, 244, 253, 288, 321, 339, 341, 357, 395}, +new short[]{4, 14, 42, 64, 69, 108, 110, 117, 122, 131, 159, 163, 188, 198, 200, 206, 244, 292, 300, 354, 390}, +new short[]{14, 37, 73, 87, 129, 135, 144, 176, 182, 300, 346, 352, 380, 383}, +new short[]{23, 50, 87, 143, 171, 186, 191, 223, 290, 333, 334, 364, 378, 380, 388, 391, 393}, +new short[]{5, 14, 23, 36, 62, 71, 76, 95, 99, 128, 176, 211, 229, 357}, +new short[]{12, 33, 47, 70, 81, 90, 97, 119, 122, 131, 189, 190, 191, 235, 244, 253, 320, 350, 359}, +new short[]{10, 13, 23, 93, 110, 120, 135, 171, 195, 250, 293, 298, 329, 344, 354}, +new short[]{13, 29, 37, 163, 169, 200, 211, 214, 217, 236, 246, 249, 282, 327, 349, 353, 362, 372}, +new short[]{5, 13, 23, 41, 57, 62, 76, 89, 111, 135, 195, 234, 248, 314, 334, 341, 349, 380}, +new short[]{17, 35, 57, 117, 121, 206, 235, 243, 265, 329, 358, 374}, +new short[]{13, 28, 41, 55, 69, 101, 103, 126, 138, 198, 267, 276, 288, 313, 334, 335, 339, 354, 376, 383, 394}, +new short[]{11, 13, 19, 36, 38, 58, 75, 124, 232, 235, 265, 286, 298, 330, 333, 359}, +new short[]{4, 19, 25, 43, 110, 125, 165, 331, 334, 341, 349, 355, 372}, +new short[]{40, 55, 64, 70, 117, 126, 127, 135, 160, 172, 173, 186, 270, 318, 338, 344, 378}, +new short[]{122, 176, 198, 238, 246, 284, 286, 290, 318, 329, 337, 381, 394}, +new short[]{23, 36, 37, 44, 117, 124, 198, 204, 233, 248, 282, 288, 297, 314, 332, 336, 388}, +new short[]{15, 33, 54, 64, 75, 85, 115, 127, 165, 196, 229, 237, 254, 307, 327, 335, 349, 383}, +new short[]{22, 87, 121, 127, 161, 180, 248, 250, 276, 313, 324, 347, 349, 355, 357, 359}, +new short[]{14, 48, 67, 88, 130, 131, 172, 188, 195, 203, 267, 282, 333, 339, 350, 392}, +new short[]{22, 31, 37, 98, 118, 132, 135, 137, 142, 151, 243, 244, 282, 305, 333, 349, 350, 351, 353, 358, 374}, +new short[]{15, 42, 67, 75, 125, 134, 189, 255, 261, 309, 334, 350, 380, 382}, +new short[]{10, 39, 87, 97, 105, 109, 125, 137, 225, 226, 253, 329, 341, 354, 363, 372}, +new short[]{5, 17, 42, 64, 80, 111, 120, 169, 175, 206, 237, 267, 288, 290, 324, 351, 364, 390}, +new short[]{3, 33, 55, 75, 91, 97, 103, 132, 187, 220, 232, 234, 240, 288, 301, 330, 336, 337, 338, 340, 359, 374, 380, 382}, +new short[]{13, 87, 98, 125, 126, 127, 128, 250, 330, 341, 353, 360, 374, 382, 391}, +new short[]{59, 66, 75, 125, 135, 172, 192, 230, 231, 255, 256, 276, 300, 306, 339, 349, 353, 390}, +new short[]{25, 36, 56, 90, 107, 125, 127, 142, 165, 195, 244, 246, 319, 347, 355, 375, 380}, +new short[]{2, 33, 35, 36, 72, 74, 87, 92, 111, 131, 145, 176, 244, 248, 282, 333, 355, 359}, +new short[]{5, 39, 127, 134, 137, 200, 240, 283, 284, 343, 344, 372}, +new short[]{9, 32, 37, 80, 96, 104, 110, 117, 154, 176, 244, 297, 298, 339, 353, 374, 381}, +new short[]{38, 51, 64, 76, 80, 93, 96, 134, 150, 173, 275, 290, 340, 347, 359, 363, 380}, +new short[]{55, 89, 111, 126, 157, 159, 162, 182, 188, 244, 253, 280, 334, 359, 384, 398}, +new short[]{59, 64, 75, 81, 97, 105, 115, 125, 155, 198, 248, 262, 319, 323, 376}, +new short[]{13, 41, 76, 125, 127, 130, 134, 135, 159, 167, 183, 229, 230, 240, 246, 308, 319, 329, 333, 334, 340, 344, 363, 382}, +new short[]{8, 13, 19, 31, 70, 76, 79, 96, 127, 153, 163, 165, 184, 227, 230, 247, 255, 336, 337, 348, 353, 357, 361, 362}, +new short[]{71, 87, 111, 121, 130, 142, 150, 160, 175, 224, 248, 314, 336, 353, 357, 359}, +new short[]{67, 84, 101, 130, 287, 288, 332, 333, 359, 361, 377}, +new short[]{34, 52, 90, 100, 125, 135, 165, 173, 320, 341, 352, 359, 382, 392}, +new short[]{13, 18, 39, 55, 62, 87, 248, 255, 290, 327, 349, 353, 355, 360, 383}, +new short[]{1, 9, 12, 29, 32, 36, 82, 139, 140, 149, 153, 165, 167, 180, 185, 231, 241, 244, 274, 299, 309, 329, 355, 362}, +new short[]{48, 66, 98, 107, 120, 122, 125, 135, 190, 195, 198, 215, 253, 256, 280, 282, 307, 320, 334, 349, 353, 355}, +new short[]{1, 7, 13, 25, 64, 98, 139, 144, 166, 176, 206, 236, 262, 330, 362}, +new short[]{37, 55, 116, 123, 125, 131, 165, 234, 266, 276, 328, 329, 342, 349, 353, 359, 391}, +new short[]{126, 137, 191, 215, 239, 288, 290, 321, 324, 333, 334, 338, 349, 353, 362, 379}, +new short[]{50, 57, 87, 93, 98, 115, 134, 148, 174, 229, 251, 260, 285, 298, 313, 348, 349, 350}, +new short[]{5, 13, 31, 45, 69, 81, 108, 122, 127, 160, 165, 176, 179, 237, 244, 301, 316, 352, 360}, +new short[]{5, 87, 95, 98, 101, 132, 135, 159, 167, 190, 203, 217, 234, 235, 247, 289, 333, 341, 343, 352}, +new short[]{22, 56, 66, 85, 87, 93, 126, 127, 163, 230, 243, 248, 254, 280, 301, 305, 334, 357}, +new short[]{13, 19, 53, 59, 76, 91, 117, 122, 195, 298, 303, 309, 337, 345, 398}, +new short[]{9, 54, 84, 107, 125, 127, 135, 144, 156, 173, 176, 202, 215, 231, 234, 246, 266, 282, 335, 336, 347, 351, 374}, +new short[]{11, 15, 30, 31, 40, 57, 58, 87, 88, 113, 186, 244, 245, 256, 308, 334, 377}, +new short[]{62, 111, 176, 196, 228, 231, 288, 294, 302, 306, 350, 353, 375, 378, 392}, +new short[]{119, 131, 133, 154, 161, 179, 198, 232, 234, 265, 301, 314, 344, 353, 378}, +new short[]{67, 84, 123, 172, 175, 176, 182, 229, 290, 359, 360, 375, 383, 393}, +new short[]{33, 36, 39, 102, 116, 136, 137, 208, 234, 256, 307, 329, 341, 347, 376, 380}, +new short[]{13, 27, 32, 80, 95, 108, 131, 165, 167, 180, 190, 200, 235, 241, 244, 323, 330, 339, 372}, +new short[]{1, 18, 37, 62, 67, 82, 85, 118, 125, 147, 159, 169, 174, 243, 284, 307, 313, 318, 355, 391, 396}, +new short[]{10, 87, 91, 135, 169, 176, 215, 246, 267, 282, 295, 320, 345, 353, 380}, +new short[]{2, 11, 13, 29, 90, 124, 131, 132, 170, 174, 176, 229, 246, 258, 298, 336, 344, 349}, +new short[]{14, 37, 42, 71, 128, 152, 185, 218, 288, 304, 315, 353, 362, 380, 391}, +new short[]{17, 20, 36, 73, 93, 128, 163, 194, 211, 217, 282, 290, 320, 354, 383}, +new short[]{9, 26, 32, 101, 127, 169, 178, 183, 191, 236, 244, 310, 330, 336, 345, 353, 360, 372, 380, 394}, +new short[]{7, 13, 64, 78, 81, 90, 115, 133, 164, 169, 244, 246, 269, 278, 290, 292, 310, 320, 353, 360, 364, 366, 380}, +new short[]{8, 65, 81, 84, 91, 126, 129, 158, 183, 184, 194, 254, 262, 333, 334, 339, 351, 363, 382}, +new short[]{44, 87, 96, 97, 125, 161, 173, 177, 183, 188, 189, 209, 235, 288, 315, 334, 351}, +new short[]{50, 56, 60, 62, 67, 71, 105, 149, 154, 158, 164, 167, 185, 221, 285, 288, 308, 337, 344, 353}, +new short[]{6, 10, 37, 62, 74, 79, 81, 128, 139, 154, 167, 198, 228, 244, 267, 290, 302, 368, 394}, +new short[]{6, 30, 35, 36, 62, 65, 71, 112, 153, 163, 167, 180, 186, 195, 249, 286, 303, 329, 334}, +new short[]{158, 241, 282, 324, 332, 334, 351, 353, 363, 365}, +new short[]{17, 89, 117, 144, 165, 180, 185, 198, 229, 244, 290, 334, 335, 380}, +new short[]{20, 32, 45, 57, 64, 66, 120, 135, 144, 176, 192, 244, 297, 301, 354, 381}, +new short[]{1, 7, 35, 62, 74, 122, 159, 170, 172, 238, 239, 307, 308, 338, 349, 350, 359, 366, 368, 375, 382, 383}, +new short[]{7, 9, 23, 66, 92, 103, 111, 135, 182, 203, 246, 247, 265, 285, 288, 303, 317, 329, 348}, +new short[]{13, 39, 74, 87, 127, 135, 144, 193, 212, 243, 270, 290, 303, 315, 375, 376}, +new short[]{33, 36, 40, 59, 101, 120, 127, 244, 285, 287, 309, 339, 391}, +new short[]{4, 10, 39, 195, 268, 284, 336, 354, 359, 375, 381}, +new short[]{39, 42, 62, 79, 83, 84, 101, 109, 132, 138, 202, 215, 277, 353, 358, 359}, +new short[]{10, 39, 46, 73, 84, 87, 132, 170, 192, 219, 232, 246, 288, 320, 337}, +new short[]{10, 12, 56, 87, 91, 101, 132, 227, 254, 301, 303, 333, 343, 347, 351}, +new short[]{7, 8, 15, 18, 82, 105, 130, 232, 250, 290, 316, 332, 348, 350}, +new short[]{36, 109, 110, 125, 154, 191, 193, 246, 265, 348, 349, 350, 378, 383}, +new short[]{12, 16, 45, 57, 87, 92, 101, 105, 129, 130, 155, 167, 218, 292, 293, 327, 349, 354, 361}, +new short[]{30, 59, 64, 121, 125, 149, 163, 188, 212, 250, 348, 350, 351, 352, 353, 378, 380}, +new short[]{1, 69, 130, 138, 194, 200, 239, 260, 264, 357, 380, 381, 382, 396}, +new short[]{7, 10, 19, 40, 57, 61, 125, 137, 141, 212, 239, 251, 310, 333, 347, 359, 380, 383}, +new short[]{20, 28, 50, 97, 109, 134, 157, 162, 184, 199, 244, 246, 286, 352, 353, 360, 373, 380}, +new short[]{35, 62, 87, 96, 122, 127, 136, 142, 148, 155, 165, 186, 196, 227, 354, 380, 388}, +new short[]{81, 82, 101, 115, 125, 200, 243, 313, 351, 359, 367}, +new short[]{7, 19, 40, 61, 107, 108, 124, 154, 161, 244, 309, 329, 345, 379, 394}, +new short[]{10, 27, 48, 66, 75, 103, 116, 122, 128, 221, 228, 319, 322, 350, 377, 398}, +new short[]{2, 64, 74, 117, 130, 165, 172, 180, 191, 218, 221, 288, 299, 325, 347, 353, 355, 360}, +new short[]{5, 76, 79, 87, 106, 111, 137, 168, 180, 235, 243, 288, 315, 321, 338, 344, 348, 378, 382, 383}, +new short[]{0, 29, 31, 37, 40, 50, 88, 100, 129, 134, 137, 144, 174, 186, 203, 254, 310, 313, 329, 341, 359, 364}, +new short[]{69, 70, 71, 96, 115, 121, 130, 157, 159, 200, 230, 246, 250, 299, 318, 324, 353, 359, 380, 391}, +new short[]{7, 90, 95, 116, 127, 128, 135, 137, 141, 154, 161, 254, 330, 359, 379, 388}, +new short[]{10, 14, 56, 91, 108, 125, 130, 167, 211, 228, 246, 258, 280, 306, 324, 333, 336, 338, 379}, +new short[]{4, 5, 14, 57, 85, 98, 125, 135, 136, 176, 254, 334, 336, 337, 351, 358, 362, 379, 383}, +new short[]{1, 4, 13, 18, 19, 32, 50, 60, 62, 87, 117, 176, 211, 251, 329, 343, 359}, +new short[]{38, 56, 94, 103, 117, 125, 129, 144, 159, 176, 244, 251, 253, 324, 345, 353, 386, 390}, +new short[]{4, 22, 38, 47, 59, 64, 82, 97, 110, 135, 153, 176, 235, 236, 241, 287, 288, 303, 333, 347, 358, 359, 361}, +new short[]{2, 5, 20, 52, 97, 125, 127, 132, 135, 137, 174, 188, 191, 243, 288, 310, 334, 346, 348, 349, 362, 372, 378}, +new short[]{19, 35, 55, 98, 125, 131, 134, 147, 153, 246, 255, 390}, +new short[]{5, 59, 62, 129, 136, 153, 198, 225, 235, 239, 254, 295, 334, 338, 341, 359, 361}, +new short[]{8, 13, 51, 94, 121, 122, 125, 126, 129, 240, 272, 290, 297, 323, 352, 358, 376, 391, 395}, +new short[]{6, 111, 116, 122, 125, 131, 135, 164, 175, 200, 212, 221, 267, 287, 319, 328, 334, 344, 378}, +new short[]{83, 108, 143, 172, 176, 192, 198, 246, 262, 286, 287, 308, 338, 340, 343, 348, 353, 367, 380, 383}, +new short[]{39, 82, 92, 118, 126, 128, 144, 171, 211, 234, 244, 253, 328, 333, 339, 357, 359, 380}, +new short[]{37, 62, 64, 81, 97, 122, 125, 127, 137, 211, 246, 344, 360}, +new short[]{7, 29, 62, 67, 69, 81, 87, 107, 132, 151, 160, 229, 244, 284, 285, 317, 358, 387, 390}, +new short[]{13, 75, 76, 83, 87, 154, 165, 190, 212, 258, 285, 308, 309, 316, 320, 332, 336, 340, 352, 353, 354, 358, 383}, +new short[]{9, 19, 29, 46, 122, 125, 127, 130, 170, 171, 174, 180, 182, 232, 282, 290, 359, 362, 367}, +new short[]{13, 40, 71, 98, 101, 116, 125, 127, 169, 172, 175, 283, 288, 309, 311, 313, 323, 334, 353, 391}, +new short[]{3, 9, 70, 104, 118, 173, 200, 219, 246, 262, 288, 297, 309, 328, 329, 334, 341, 353}, +new short[]{32, 89, 93, 131, 132, 142, 199, 200, 214, 246, 287, 298, 307, 339, 348, 349, 357, 358, 368, 372, 391}, +new short[]{103, 134, 159, 176, 186, 235, 261, 276, 282, 290, 301, 317, 329, 345, 356}, +new short[]{10, 59, 125, 129, 130, 192, 217, 283, 318, 343, 345, 349, 353, 380, 383, 392}, +new short[]{19, 76, 79, 102, 107, 126, 155, 161, 180, 253, 288, 289, 290, 314, 329, 333, 334, 360, 368, 378, 394}, +new short[]{12, 92, 98, 105, 137, 149, 172, 196, 198, 244, 260, 262, 282, 298, 329, 345, 353, 368, 390}, +new short[]{31, 39, 79, 83, 121, 125, 167, 171, 186, 198, 288, 303, 306, 334, 337, 376}, +new short[]{13, 20, 36, 57, 98, 108, 114, 165, 171, 225, 226, 262, 269, 305, 309, 351, 377, 389}, +new short[]{13, 51, 71, 93, 110, 129, 130, 156, 165, 170, 173, 183, 191, 200, 211, 212, 255, 266, 299, 301, 329, 336, 348}, +new short[]{31, 56, 97, 122, 125, 129, 160, 188, 202, 204, 206, 225, 235, 247, 254, 255, 288, 334, 350, 362, 365, 367}, +new short[]{9, 32, 37, 70, 75, 87, 88, 96, 125, 130, 162, 163, 168, 169, 257, 285, 308, 310, 337, 373, 392}, +new short[]{18, 40, 42, 47, 73, 76, 85, 105, 108, 125, 130, 132, 134, 167, 191, 284, 310, 311, 344, 358, 361, 374, 378, 379}, +new short[]{5, 19, 29, 31, 48, 65, 98, 129, 131, 143, 165, 171, 172, 196, 198, 277, 296, 311, 317, 327, 351, 380}, +new short[]{51, 69, 96, 98, 117, 123, 130, 131, 148, 161, 168, 172, 176, 184, 202, 324, 332, 336, 348, 392}, +new short[]{1, 20, 37, 57, 70, 76, 79, 87, 165, 176, 234, 251, 333, 388}, +new short[]{8, 13, 134, 135, 153, 165, 169, 193, 195, 255, 273, 337, 348, 359, 360, 382, 391}, +new short[]{2, 14, 53, 71, 83, 127, 136, 144, 149, 208, 234, 235, 293, 301, 347, 352}, +new short[]{20, 40, 42, 95, 135, 141, 165, 199, 250, 290, 299, 308, 337, 338, 350, 353, 354, 355, 358, 380}, +new short[]{13, 19, 33, 35, 36, 49, 85, 121, 122, 127, 137, 158, 165, 282, 303, 320, 328, 334, 365, 367, 374}, +new short[]{17, 37, 123, 126, 127, 139, 140, 143, 167, 185, 192, 235, 254, 275, 315, 340, 349, 353, 362}, +new short[]{57, 72, 127, 159, 163, 165, 176, 199, 215, 218, 238, 254, 284, 288, 336, 339, 347, 352, 380, 395}, +new short[]{54, 69, 81, 101, 114, 121, 165, 206, 236, 313, 332, 338, 349, 358, 360, 362, 377}, +new short[]{29, 37, 43, 120, 127, 176, 193, 244, 246, 254, 284, 288, 336, 339, 372}, +new short[]{36, 56, 85, 122, 125, 126, 154, 232, 282, 308, 314, 315, 324, 336, 353, 359, 382}, +new short[]{7, 99, 104, 117, 124, 125, 143, 176, 239, 298, 318, 383}, +new short[]{13, 20, 71, 90, 108, 122, 176, 186, 214, 231, 247, 262, 267, 280, 286, 300, 332, 358, 377, 380, 385, 390, 393}, +new short[]{31, 65, 75, 79, 85, 91, 109, 110, 120, 159, 229, 235, 288, 298, 347, 355, 359, 379, 381}, +new short[]{38, 75, 82, 90, 99, 202, 248, 265, 324, 329, 350, 354, 355, 365}, +new short[]{7, 15, 72, 90, 117, 125, 140, 144, 171, 198, 269, 271, 282, 305, 325, 338, 343, 353}, +new short[]{13, 14, 20, 29, 37, 42, 45, 47, 165, 184, 244, 329, 341, 347, 372}, +new short[]{31, 36, 82, 99, 149, 154, 173, 182, 185, 200, 217, 251, 298, 329, 332, 333, 349, 353, 354, 355, 377, 383}, +new short[]{32, 44, 45, 52, 93, 97, 108, 114, 120, 144, 155, 172, 236, 240, 267, 272, 282, 288, 329, 333, 334, 343, 381}, +new short[]{35, 55, 57, 62, 95, 96, 98, 127, 131, 177, 262, 317, 318, 357, 359, 380, 388}, +new short[]{22, 24, 68, 103, 115, 119, 120, 125, 128, 156, 162, 184, 186, 235, 244, 327, 353, 358, 378, 380, 393}, +new short[]{29, 37, 62, 67, 81, 83, 93, 104, 110, 129, 132, 142, 172, 274, 298, 354, 380}, +new short[]{19, 45, 66, 87, 104, 108, 118, 155, 170, 176, 234, 286, 310, 313, 327, 329, 333, 347, 358, 368, 380, 383, 386}, +new short[]{10, 14, 32, 83, 96, 131, 165, 180, 205, 211, 249, 255, 286, 288, 292, 299, 312, 336, 338, 349, 368, 375}, +new short[]{2, 13, 48, 75, 85, 98, 116, 125, 126, 128, 135, 136, 151, 188, 195, 243, 280, 289, 333, 339, 349, 378, 382}, +new short[]{9, 19, 39, 45, 87, 106, 117, 125, 126, 127, 154, 165, 202, 211, 256, 309, 360, 397, 398}, +new short[]{14, 21, 65, 76, 87, 93, 97, 105, 131, 177, 212, 254, 294, 336, 349, 359, 381}, +new short[]{36, 55, 65, 70, 87, 93, 96, 98, 108, 127, 254, 337, 352, 359, 375, 380}, +new short[]{22, 42, 62, 82, 131, 132, 136, 158, 168, 196, 267, 305, 336}, +new short[]{45, 69, 74, 75, 81, 120, 123, 126, 127, 130, 150, 171, 191, 194, 313, 339, 368, 378, 379, 389, 398}, +new short[]{35, 43, 85, 98, 122, 131, 135, 176, 189, 250, 259, 277, 288, 303, 333, 336, 345, 376, 381, 387}, +new short[]{1, 6, 34, 87, 115, 129, 131, 202, 235, 252, 256, 263, 317, 328, 349, 372, 391}, +new short[]{3, 18, 42, 48, 84, 90, 92, 138, 193, 227, 288, 310, 315, 353, 375}, +new short[]{2, 10, 31, 66, 124, 145, 240, 314, 334}, +new short[]{32, 38, 84, 141, 165, 188, 193, 212, 346, 359, 379, 380}, +new short[]{10, 75, 81, 96, 111, 140, 179, 298, 309, 353, 357, 359, 380, 396}, +new short[]{2, 34, 121, 127, 132, 134, 184, 234, 244, 251, 262, 290, 308, 359, 380}, +new short[]{17, 24, 93, 172, 186, 198, 218, 234, 239, 250, 252, 255, 307, 309, 325, 334, 354, 359}, +new short[]{14, 18, 45, 50, 131, 174, 211, 237, 252, 267, 309, 334, 348, 351, 377, 391}, +new short[]{32, 61, 87, 97, 125, 126, 132, 184, 249, 252, 273, 284, 288, 339, 383, 398}, +new short[]{76, 81, 87, 127, 147, 161, 163, 199, 206, 306, 329, 340, 349, 353, 360, 383}, +new short[]{14, 16, 76, 87, 101, 169, 188, 243, 246, 251, 253, 269, 298, 355, 375, 380}, +new short[]{32, 79, 87, 103, 117, 125, 127, 177, 244, 301, 305, 317, 333, 338, 340, 342, 391}, +new short[]{4, 67, 76, 121, 127, 130, 140, 158, 165, 186, 193, 251, 301, 303, 330, 336}, +new short[]{11, 76, 83, 84, 87, 214, 248, 276, 299, 311, 320, 329, 332, 335, 371}, +new short[]{2, 4, 19, 40, 42, 71, 98, 119, 121, 137, 167, 262, 288, 295, 306, 339, 350, 382}, +new short[]{14, 40, 54, 90, 125, 129, 132, 146, 147, 165, 169, 176, 190, 253, 284, 303, 307, 316, 339, 342, 359, 389}, +new short[]{47, 59, 71, 103, 125, 126, 129, 130, 200, 206, 240, 254, 276, 282, 299, 303, 307, 318, 320, 336, 338, 357, 362, 380, 387, 392}, +new short[]{4, 22, 58, 102, 113, 115, 153, 167, 188, 212, 262, 286, 305, 333, 348, 354, 360, 371, 379, 386}, +new short[]{5, 6, 56, 61, 108, 128, 129, 164, 165, 177, 182, 225, 226, 235, 244, 246, 249, 310, 333, 348, 349, 381, 391}, +new short[]{18, 32, 33, 53, 56, 176, 186, 199, 200, 244, 246, 248, 259, 285, 289, 306, 358, 371, 373, 375, 379}, +new short[]{40, 43, 70, 76, 83, 84, 90, 93, 101, 125, 159, 204, 276, 282, 304, 320, 339, 351, 353, 367, 391}, +new short[]{14, 19, 59, 71, 76, 87, 93, 97, 105, 111, 120, 121, 122, 154, 171, 211, 231, 244, 286, 288, 341, 351}, +new short[]{10, 56, 65, 72, 92, 108, 123, 129, 212, 258, 329, 353, 359}, +new short[]{5, 76, 124, 127, 161, 172, 188, 244, 250, 266, 290, 318, 347, 351, 369, 382, 391, 395}, +new short[]{1, 33, 86, 120, 121, 130, 154, 162, 173, 192, 241, 244, 262, 338, 339, 343, 353, 380, 390}, +new short[]{1, 15, 22, 54, 57, 85, 126, 127, 176, 188, 248, 305, 332, 347, 349, 358, 367}, +new short[]{91, 111, 122, 125, 130, 178, 190, 224, 225, 226, 235, 286, 308, 329, 334, 345, 346, 349, 358, 362, 367}, +new short[]{16, 26, 51, 54, 84, 85, 98, 120, 272, 319, 349, 359, 360, 362, 377, 391, 398}, +new short[]{73, 85, 102, 109, 128, 153, 171, 184, 248, 249, 256, 298, 300, 335, 338, 340, 355, 370}, +new short[]{9, 108, 122, 131, 164, 168, 173, 176, 195, 218, 235, 286, 341, 350, 353, 358, 375, 377}, +new short[]{25, 62, 125, 140, 165, 173, 200, 225, 226, 243, 283, 286, 329, 343, 357, 366, 377}, +new short[]{10, 35, 58, 64, 98, 103, 125, 127, 129, 135, 141, 165, 169, 175, 189, 244, 258, 259, 306, 331, 333, 378, 380, 391}, +new short[]{54, 87, 89, 99, 116, 125, 129, 221, 246, 269, 324, 335, 348, 351}, +new short[]{85, 90, 103, 115, 131, 134, 165, 207, 282, 307, 313, 328, 346, 349, 380, 383, 387, 398}, +new short[]{10, 40, 74, 84, 160, 239, 253, 272, 282, 333, 344, 351, 359, 360, 379}, +new short[]{32, 38, 54, 74, 76, 117, 163, 171, 176, 217, 227, 250, 251, 280, 329, 330, 350, 378}, +new short[]{13, 20, 40, 107, 129, 135, 154, 158, 161, 163, 179, 206, 281, 315, 325, 351, 355, 359, 397}, +new short[]{0, 4, 37, 49, 62, 98, 117, 129, 177, 244, 285, 289, 306, 338, 360, 381}, +new short[]{36, 38, 43, 61, 71, 87, 120, 128, 172, 200, 235, 247, 251, 282, 299, 329, 341, 352, 355}, +new short[]{43, 71, 83, 85, 108, 117, 118, 121, 133, 138, 165, 206, 231, 254, 290, 291, 335, 336, 359, 362, 377}, +new short[]{29, 32, 71, 103, 122, 125, 198, 224, 244, 285, 303, 333, 335, 337}, +new short[]{54, 55, 82, 87, 101, 108, 127, 229, 230, 269, 290, 306, 349, 353}, +new short[]{9, 117, 126, 137, 154, 165, 167, 186, 192, 229, 277, 283, 301, 317, 365, 367, 372, 378}, +new short[]{4, 11, 19, 47, 51, 92, 110, 132, 137, 140, 290, 298, 361, 377, 379}, +new short[]{23, 83, 98, 134, 165, 170, 186, 190, 253, 269, 308, 322, 327, 332, 335, 344, 398}, +new short[]{60, 83, 111, 129, 173, 176, 186, 232, 306, 327, 329, 349, 355}, +new short[]{25, 31, 40, 56, 72, 95, 126, 144, 149, 161, 173, 240, 262, 332, 333, 356, 368, 391, 394}, +new short[]{91, 127, 134, 144, 155, 158, 161, 232, 251, 280, 287, 353, 380, 394}, +new short[]{37, 43, 57, 84, 87, 149, 175, 288, 330, 380}, +new short[]{8, 9, 83, 97, 120, 128, 158, 171, 193, 232, 287, 308, 309, 334, 355}, +new short[]{39, 40, 62, 82, 94, 98, 101, 144, 147, 205, 290, 333, 339, 353, 372, 397}, +new short[]{10, 20, 38, 125, 135, 138, 168, 180, 191, 203, 231, 250, 280, 301, 328, 345, 388}, +new short[]{44, 54, 64, 87, 117, 122, 127, 154, 234, 239, 244, 298, 329, 378, 383}, +new short[]{13, 62, 70, 97, 121, 176, 244, 267, 282, 318, 324, 334, 341, 353, 386, 388}, +new short[]{40, 89, 91, 117, 125, 131, 155, 173, 193, 244, 273, 277, 328, 333, 360, 382}, +new short[]{30, 47, 95, 108, 127, 165, 188, 211, 273, 349, 354, 368, 391}, +new short[]{19, 52, 87, 98, 100, 122, 125, 157, 159, 215, 217, 235, 254, 309, 336, 344, 349, 382}, +new short[]{19, 85, 87, 136, 144, 180, 190, 229, 310, 345, 365, 376, 390}, +new short[]{35, 52, 87, 113, 124, 135, 145, 167, 174, 225, 226, 244, 247, 300, 359}, +new short[]{10, 35, 69, 103, 129, 144, 165, 180, 230, 232, 329, 335, 353, 359, 371, 390}, +new short[]{5, 13, 80, 83, 135, 139, 142, 176, 179, 190, 205, 217, 282, 298, 308, 334, 353, 359}, +new short[]{24, 52, 67, 108, 135, 138, 153, 176, 231, 249, 283, 304, 337, 351, 353, 355}, +new short[]{90, 93, 127, 132, 136, 163, 165, 196, 284, 306, 353, 383}, +new short[]{20, 37, 103, 126, 135, 184, 204, 215, 221, 288, 300, 329, 339, 358, 383}, +new short[]{16, 36, 52, 99, 117, 136, 171, 190, 243, 244, 303, 315, 333, 349, 373, 382}, +new short[]{0, 57, 69, 98, 125, 129, 132, 158, 165, 190, 191, 193, 198, 254, 256, 285, 288, 303, 339, 346, 351, 391}, +new short[]{1, 13, 21, 87, 125, 132, 150, 204, 240, 249, 253, 265, 288, 334, 343, 348, 349, 359}, +new short[]{29, 40, 71, 80, 91, 99, 122, 203, 289, 290, 298, 329, 353, 380, 390}, +new short[]{2, 5, 36, 57, 93, 102, 135, 140, 314, 343, 398}, +new short[]{20, 59, 107, 193, 204, 246, 247, 336, 341, 342, 354, 359, 360, 383}, +new short[]{47, 71, 93, 111, 116, 120, 122, 130, 251, 286, 298, 299, 348}, +new short[]{21, 52, 56, 69, 76, 118, 120, 125, 137, 274, 280, 324, 327, 335, 339, 340}, +new short[]{23, 29, 57, 75, 98, 132, 149, 157, 160, 235, 244, 288, 327, 340, 354, 372, 377}, +new short[]{4, 22, 97, 103, 111, 129, 131, 151, 158, 176, 204, 248, 265, 309, 359, 391, 392}, +new short[]{15, 17, 73, 105, 115, 170, 186, 228, 255, 317, 321, 339, 349, 379, 380, 381}, +new short[]{17, 52, 72, 103, 188, 329, 342, 353, 358, 359, 374, 376, 380, 393}, +new short[]{40, 48, 74, 124, 135, 191, 225, 226, 237, 291, 300, 304, 310, 347, 359, 380, 396}, +new short[]{2, 36, 47, 57, 122, 125, 174, 188, 203, 224, 255, 325, 353, 359, 387}, +new short[]{13, 58, 69, 83, 115, 120, 134, 161, 165, 174, 175, 191, 246, 255, 280, 353, 357, 358, 359, 379}, +new short[]{1, 29, 47, 87, 89, 135, 176, 190, 209, 236, 304, 344, 348, 358, 359, 378}, +new short[]{8, 13, 40, 52, 58, 61, 71, 125, 144, 168, 189, 210, 260, 337, 338, 340, 347, 376, 380}, +new short[]{29, 90, 126, 127, 129, 136, 145, 159, 165, 188, 274, 284, 288, 316, 329, 358, 380}, +new short[]{2, 19, 103, 120, 123, 159, 165, 175, 177, 180, 238, 244, 251, 294, 329, 342, 345, 349, 357, 376, 392}, +new short[]{41, 42, 59, 71, 81, 98, 101, 117, 159, 171, 180, 240, 285, 290, 299, 344, 353}, +new short[]{83, 103, 108, 142, 175, 248, 290, 300, 321, 354, 365, 374, 382}, +new short[]{12, 67, 105, 130, 140, 171, 188, 192, 244, 276, 290, 302, 348, 349, 357, 360, 380}, +new short[]{4, 13, 36, 65, 75, 160, 165, 185, 198, 235, 293, 324, 327, 333, 345, 347, 375, 383}, +new short[]{37, 61, 80, 125, 234, 283, 290, 353, 359, 378, 383}, +new short[]{9, 32, 83, 110, 155, 248, 252, 288, 313}, +new short[]{37, 48, 52, 93, 167, 170, 179, 244, 267, 288, 296, 333, 335, 355, 374}, +new short[]{35, 92, 98, 153, 165, 184, 215, 233, 242, 290, 339, 355}, +new short[]{9, 38, 83, 121, 127, 165, 176, 235, 253, 305, 330, 337, 355, 358, 359}, +new short[]{35, 117, 122, 125, 132, 136, 183, 235, 254, 280, 285, 286, 329, 334, 338, 353, 372}, +new short[]{6, 87, 117, 125, 141, 144, 153, 157, 179, 215, 267, 272, 289, 329, 336, 359}, +new short[]{7, 14, 37, 82, 135, 147, 154, 202, 244, 290, 297, 298, 345, 355, 368, 383}, +new short[]{105, 135, 173, 244, 255, 280, 288, 299, 304, 307, 337, 338, 341, 344}, +new short[]{19, 31, 33, 77, 92, 99, 114, 151, 173, 202, 253, 318, 329, 333, 358, 371}, +new short[]{1, 8, 14, 30, 39, 120, 157, 172, 227, 229, 251, 257, 272, 339, 380}, +new short[]{19, 98, 171, 191, 213, 246, 289, 353, 357, 366, 374, 383}, +new short[]{8, 98, 125, 126, 144, 152, 244, 277, 282, 290, 322, 393}, +new short[]{17, 206, 211, 224, 336, 338, 386}, +new short[]{52, 55, 71, 99, 105, 191, 211, 215, 224, 246, 290, 300, 336, 339, 361}, +new short[]{15, 16, 44, 66, 96, 121, 127, 162, 167, 202, 219, 243, 244, 254, 282, 320, 345, 390}, +new short[]{7, 83, 92, 121, 130, 160, 177, 280, 308, 309, 339, 350, 352, 358, 380, 390}, +new short[]{67, 122, 144, 148, 170, 173, 184, 222, 280, 374}, +new short[]{2, 4, 15, 19, 115, 130, 136, 148, 172, 180, 243, 251, 313, 329, 333, 359, 364}, +new short[]{90, 98, 108, 124, 167, 176, 202, 254, 286, 351, 359}, +new short[]{80, 126, 135, 167, 212, 242, 243, 256, 283, 286, 295, 327, 337, 340, 346, 357, 358, 364}, +new short[]{19, 108, 125, 132, 149, 172, 180, 186, 200, 254, 286, 296, 339, 344, 350, 359, 391}, +new short[]{62, 65, 67, 105, 127, 129, 132, 250, 298, 307, 334, 344, 359, 383}, +new short[]{31, 59, 87, 107, 121, 131, 132, 160, 244, 246, 247, 253, 344, 360, 394}, +new short[]{4, 39, 76, 125, 130, 148, 168, 170, 191, 196, 298, 306, 327, 338, 345, 349, 360, 375}, +new short[]{13, 14, 32, 84, 98, 122, 126, 156, 188, 235, 255, 330, 336, 338, 375, 380, 389}, +new short[]{5, 18, 31, 54, 71, 74, 76, 81, 87, 93, 126, 129, 182, 303, 327, 353, 359, 373, 391}, +new short[]{13, 37, 64, 137, 138, 180, 244, 247, 251, 253, 269, 284, 308, 344, 374, 376}, +new short[]{5, 7, 10, 23, 35, 125, 168, 169, 187, 191, 192, 313, 337, 340, 342, 365}, +new short[]{62, 67, 122, 125, 165, 190, 217, 243, 254, 256, 265, 299, 318, 353, 394}, +new short[]{4, 24, 62, 92, 109, 118, 134, 143, 144, 176, 190, 199, 221, 299, 349, 380}, +new short[]{22, 35, 64, 74, 92, 113, 161, 172, 193, 282, 287, 307, 359, 393}, +new short[]{37, 50, 66, 75, 76, 78, 82, 87, 139, 159, 172, 176, 188, 231, 352, 371}, +new short[]{19, 31, 75, 121, 144, 152, 163, 171, 172, 198, 243, 246, 285, 288, 289, 333, 344, 347, 357, 398}, +new short[]{1, 15, 17, 51, 57, 65, 69, 127, 241, 244, 254, 259, 329, 336, 358}, +new short[]{9, 95, 117, 121, 125, 137, 204, 242, 247, 301, 309, 314, 334, 339, 350, 354, 358}, +new short[]{9, 61, 96, 111, 130, 163, 180, 211, 225, 226, 241, 253, 282, 283, 346, 355, 359, 380, 383}, +new short[]{94, 117, 121, 124, 126, 130, 135, 172, 199, 232, 286, 325, 336, 352, 362, 375}, +new short[]{110, 125, 163, 250, 265, 303, 329, 334, 391}, +new short[]{47, 72, 76, 111, 125, 157, 169, 245, 254, 285, 287, 297, 298, 336, 353, 359, 383}, +new short[]{62, 93, 115, 125, 127, 130, 174, 231, 308, 310, 329, 333, 355, 359, 390}, +new short[]{44, 116, 163, 167, 180, 191, 200, 245, 254, 329, 343, 345, 354, 364}, +new short[]{31, 62, 105, 108, 144, 145, 162, 173, 177, 191, 198, 247, 249, 344, 345, 348, 353}, +new short[]{29, 65, 66, 74, 83, 87, 125, 148, 165, 228, 334, 353, 359, 380, 383, 391}, +new short[]{2, 15, 125, 130, 239, 290, 312, 336, 337, 341, 398}, +new short[]{40, 76, 87, 114, 119, 120, 165, 229, 265, 313, 324, 349, 358, 383}, +new short[]{48, 62, 87, 91, 103, 186, 195, 212, 214, 315, 322, 327, 330, 338, 339}, +new short[]{9, 32, 85, 108, 135, 191, 224, 237, 257, 288, 307, 310, 313, 318, 329, 337, 352, 395}, +new short[]{87, 93, 102, 112, 129, 154, 171, 236, 317, 320, 349, 350, 359, 380}, +new short[]{1, 14, 92, 111, 137, 140, 186, 290, 329, 336, 354, 355, 378, 379, 383}, +new short[]{7, 26, 37, 47, 84, 101, 144, 153, 175, 180, 198, 232, 243, 305, 333, 353, 357, 383}, +new short[]{20, 58, 76, 93, 99, 127, 134, 154, 188, 206, 246, 312, 313, 324}, +new short[]{2, 12, 117, 125, 160, 167, 188, 206, 279, 285, 287, 301, 329, 332, 333, 336, 344, 362}, +new short[]{2, 76, 126, 127, 137, 165, 244, 288, 290, 339, 346, 351, 359, 365, 383}, +new short[]{66, 108, 136, 151, 174, 265, 344, 351, 353, 357, 378, 386}, +new short[]{8, 76, 87, 90, 111, 116, 124, 176, 198, 334, 337, 349, 359, 379, 394}, +new short[]{32, 36, 42, 76, 81, 125, 127, 205, 227, 262, 280, 288, 326, 336, 390, 398}, +new short[]{9, 32, 65, 83, 89, 93, 97, 122, 129, 178, 180, 215, 241, 246, 323, 332, 353, 362, 364, 380}, +new short[]{5, 24, 56, 127, 130, 155, 184, 191, 217, 235, 245, 339, 344, 358, 359, 362, 380}, +new short[]{14, 40, 64, 71, 93, 108, 131, 165, 188, 204, 217, 235, 237, 241, 248, 308, 309, 318, 380, 387}, +new short[]{17, 29, 34, 74, 125, 175, 184, 196, 211, 275, 301, 318, 327, 334, 349, 355, 358, 368}, +new short[]{15, 45, 110, 111, 116, 129, 132, 211, 247, 275, 286, 317, 333, 334, 377, 383}, +new short[]{4, 5, 59, 87, 103, 124, 125, 127, 130, 165, 241, 265, 299, 353, 360}, +new short[]{31, 120, 124, 135, 154, 197, 235, 243, 247, 248, 258, 309, 320, 335, 357}, +new short[]{50, 125, 127, 130, 137, 147, 171, 172, 267, 289, 301, 308, 325, 334, 337, 353, 360, 374, 391}, +new short[]{62, 64, 69, 87, 111, 118, 129, 134, 212, 239, 244, 246, 250, 254, 307, 322, 329, 370, 372}, +new short[]{54, 92, 128, 160, 198, 244, 248, 255, 284, 314, 335, 349, 358, 360, 376, 380}, +new short[]{9, 13, 29, 54, 72, 89, 110, 122, 126, 139, 158, 159, 163, 230, 304, 306, 313}, +new short[]{1, 9, 54, 95, 108, 132, 176, 193, 243, 251, 339, 378}, +new short[]{0, 96, 99, 135, 137, 184, 212, 232, 251, 315, 334}, +new short[]{140, 157, 165, 182, 235, 294, 314, 349, 354, 365}, +new short[]{14, 18, 31, 56, 117, 125, 138, 227, 246, 283, 334, 345, 352, 357, 361}, +new short[]{0, 71, 82, 130, 131, 144, 161, 235, 247, 301, 333, 335, 345, 353, 355, 359, 360, 374}, +new short[]{6, 23, 35, 117, 125, 141, 169, 200, 244, 288, 298, 338, 353, 379}, +new short[]{10, 98, 125, 127, 138, 153, 219, 244, 307, 350, 353, 366, 367}, +new short[]{9, 32, 40, 122, 126, 127, 170, 176, 300, 334, 350, 391}, +new short[]{6, 13, 31, 87, 89, 97, 125, 165, 171, 173, 176, 244, 331, 348, 373}, +new short[]{10, 61, 87, 105, 123, 125, 127, 195, 260, 265, 323, 361, 362}, +new short[]{2, 20, 90, 124, 353, 354, 378, 382}, +new short[]{5, 48, 58, 83, 98, 117, 125, 126, 196, 198}, +new short[]{13, 37, 50, 64, 66, 79, 99, 132, 135, 244, 247, 380}, +new short[]{57, 165, 235, 238, 248, 272, 287, 299, 327, 329, 334, 350, 353, 380}, +new short[]{55, 66, 118, 125, 130, 169, 250, 255, 271, 314, 324, 338, 353}, +new short[]{7, 31, 62, 84, 103, 105, 111, 126, 132, 149, 154, 191, 250, 334, 372, 375}, +new short[]{56, 81, 114, 117, 120, 124, 127, 128, 154, 254, 290, 317, 345, 354}, +new short[]{4, 13, 86, 101, 153, 191, 193, 231, 243, 258, 283, 288, 308, 353, 387, 392}, +new short[]{5, 37, 58, 62, 67, 84, 87, 176, 237, 267, 333, 334, 347}, +new short[]{1, 7, 74, 110, 165, 168, 182, 233, 288, 305, 309, 315, 347, 351, 353, 358, 360, 375}, +new short[]{57, 84, 129, 138, 165, 243, 244, 259, 280, 282, 290, 380, 383} +}; + } +} diff --git a/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyHash.cs.meta b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyHash.cs.meta new file mode 100644 index 0000000..2eb162d --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Res/NPinyin.Core.3.0.0/PyHash.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 47607456657e8d649bd40c1f61597a7c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Tools.meta b/Assets/00.StaryEvo/Editor/Tools.meta new file mode 100644 index 0000000..8ac5930 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Tools.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 55212e443fd50fb43bd3aba9c5ed2033 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Tools/FileUtility.cs b/Assets/00.StaryEvo/Editor/Tools/FileUtility.cs new file mode 100644 index 0000000..00a4c71 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Tools/FileUtility.cs @@ -0,0 +1,311 @@ +using System; +using System.Diagnostics; +using UnityEngine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +//using UnityEditor.Experimental.TerrainAPI; +using Debug = UnityEngine.Debug; + +#if UNITY_ANDROID && !UNITY_EDITOR +using Babybus.Uno; +#endif + +#if UNITY_IOS +using UnityEngine.iOS; +#endif +namespace Stary.Evo.Editor +{ + public static class FileUtility + { + public static string GetStreamingAssetsPath(string fileName) + { +#if UNITY_ANDROID && !UNITY_EDITOR + return System.IO.Path.Combine(Application.streamingAssetsPath+ "/Android",fileName); +#elif UNITY_EDITOR + return System.IO.Path.Combine("file://" + Application.streamingAssetsPath + "/Android", fileName); +#elif UNITY_IOS + return "file://"+ System.IO.Path.Combine(Application.streamingAssetsPath + "/IOS", fileName); +#else + return ""; +#endif + } + + /// + /// 读取StreamingAssets目录文件 + /// + /// + /// + public static byte[] ReadStreamingAssets(string path) + { +#if UNITY_ANDROID && !UNITY_EDITOR + var bytes = AndroidStreamingAssetSyncLoader.LoadFile(path); +#else + var bytes = File.ReadAllBytes(Application.streamingAssetsPath + "/" + path); +#endif + return bytes; + } + + public static void CreateDirectory(string path) + { + string directoryName = Path.GetDirectoryName(path); + if (directoryName != "" && !Directory.Exists(directoryName)) + Directory.CreateDirectory(directoryName); + } + + public static void WriteAllText(string path, string content) + { + if (string.IsNullOrEmpty(path)) return; + CreateDirectory(path); + File.WriteAllText(path, content); + } + + public static void WriteAllBytes(string path, byte[] bytes) + { + if (string.IsNullOrEmpty(path)) return; + CreateDirectory(path); + File.WriteAllBytes(path, bytes); + } + + public static void Move(string sourceFileName, string destFileName) + { + if (sourceFileName == destFileName) + return; + if (!File.Exists(sourceFileName)) + return; + CreateDirectory(destFileName); + DeleteFile(destFileName); + File.Move(sourceFileName, destFileName); + } + + public static void Copy(string sourceFileName, string destFileName, bool overwrite) + { + if (sourceFileName == destFileName) + return; + CreateDirectory(destFileName); + File.Copy(sourceFileName, destFileName, overwrite); + } + + public static void CopyDirectory(string srcPath, string dstPath, bool overwrite = true, + string excludeExtension = ".meta") + { + DeleteFile(dstPath); + if (!Directory.Exists(dstPath)) + Directory.CreateDirectory(dstPath); + foreach (var file in Directory.GetFiles(srcPath, "*.*") + .Where(path => Path.GetExtension(path) != excludeExtension)) + { + File.Copy(file, Path.Combine(dstPath, Path.GetFileName(file)), overwrite); + } + + foreach (var dir in Directory.GetDirectories(srcPath) + .Where(path => Path.GetExtension(path) != excludeExtension)) + CopyDirectory(dir, Path.Combine(dstPath, Path.GetFileName(dir)), overwrite); + } + + public static void CopyDirectory(string srcPath, string dstPath, string[] excludeFileExtensions, + string[] excludeDirectoryExtensions = null, bool overwrite = true) + { + if (!Directory.Exists(dstPath)) + Directory.CreateDirectory(dstPath); + foreach (var file in Directory.GetFiles(srcPath, "*.*", SearchOption.TopDirectoryOnly).Where(path => + excludeFileExtensions == null || !excludeFileExtensions.Contains(Path.GetExtension(path)))) + { + File.Copy(file, Path.Combine(dstPath, Path.GetFileName(file)), overwrite); + } + + foreach (var dir in Directory.GetDirectories(srcPath).Where(path => + excludeDirectoryExtensions == null || + !excludeDirectoryExtensions.Contains(Path.GetExtension(path)))) + CopyDirectory(dir, Path.Combine(dstPath, Path.GetFileName(dir)), excludeFileExtensions, + excludeDirectoryExtensions, overwrite); + } + + public static void DeleteFile(string path) + { + if (File.Exists(path)) + File.Delete(path); + } + + /// + /// 文件是否被占用 + /// + /// + /// + public static bool IsFileInUse(string fileName) + { + if (File.Exists(fileName) == false) return false; + bool inUse = true; + FileStream fs = null; + try + { + fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None); + inUse = false; + } + catch + { + // ignored + } + finally + { + if (fs != null) + fs.Close(); + } + + return inUse; //true表示正在使用,false没有使用 + } + + /// + /// 是否只读文件 + /// + /// + /// + public static bool IsReadOnly(string path) + { + if (!File.Exists(path)) return false; + FileInfo fi = new FileInfo(path); + return fi.IsReadOnly; + } + + public static void DeleteDirectory(string path) + { + if (Directory.Exists(path)) Directory.Delete(path, true); + } + + public static string GetFullPathWithoutExtension(string path) + { + return Path.GetDirectoryName(path) + "/" + Path.GetFileNameWithoutExtension(path); + } + + public static int GetFileSize(string path) + { + if (!File.Exists(path)) return 0; + FileStream fs = new FileStream(path, FileMode.Open); + long length = fs.Length; + fs.Close(); + return (int)length; + } + + /// + /// 获取文件夹下所有文件路径 + /// + /// + /// "*.mp3" + /// + public static string[] GetFiles(string path, string extension = "*") + { + if (File.Exists(path)) + { + return Directory.GetFiles(path, extension, SearchOption.AllDirectories); + } + else + { + return null; + } + } + + public static void TakePhoto(Camera camera, string path, int width, int height, bool hideCamera = true) + { + Rect rect = new Rect(0, 0, width, height); + camera.gameObject.SetActive(true); + //特别注意事项 + camera.clearFlags = CameraClearFlags.SolidColor; + var color = Color.black; + color.a = 0.00001f; + camera.backgroundColor = color; + RenderTexture rt = new RenderTexture(width, height, 24); + camera.targetTexture = rt; + camera.Render(); + //ps: --- 如果这样加上第二个相机,可以实现只截图某几个指定的相机一起看到的图像。 + //ps: camera2.targetTexture = rt; + //ps: camera2.Render(); + //ps: ------------------------------------------------------------------- + // 激活这个rt, 并从中中读取像素 + RenderTexture.active = rt; + Texture2D texture = new Texture2D(width, height, TextureFormat.RGBA32, true); + texture.ReadPixels(rect, 0, 0); + texture.Apply(); + RenderTexture.active = null; + camera.gameObject.SetActive(!hideCamera); + byte[] bytes = texture.EncodeToPNG(); + WriteAllBytes(path, bytes); +#if UNITY_EDITOR + Debug.Log("截屏了一张照片: " + path); +#endif + } + + public static Texture2D LoadTextureByIO(string path, int width, int height) + { + //创建文件读取流 + FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); + fileStream.Seek(0, SeekOrigin.Begin); + //创建文件长度缓冲区 + byte[] bytes = new byte[fileStream.Length]; + //读取文件 + fileStream.Read(bytes, 0, (int)fileStream.Length); + //释放文件读取流 + fileStream.Close(); + fileStream.Dispose(); + fileStream = null; + //创建Texture + Texture2D texture = new Texture2D(width, height); + texture.LoadImage(bytes); +#if UNITY_EDITOR + Debug.Log("跳场景或删除时要Destroy(texutre)掉,不然内存会增加"); +#endif + return texture; + } + + public static Sprite LoadSpriteByIO(string fileName, int width, int height) + { + Texture2D texture2D = LoadTextureByIO(fileName, width, height); + return Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f)); + } + + // 硬盘检测方法 + public static bool CheckDriveExists(string driveLetter) + { + try + { + // 确保输入格式正确(例如:"D:") + if (!driveLetter.EndsWith(":\\")) + driveLetter += ":\\"; + + foreach (DriveInfo drive in DriveInfo.GetDrives()) + { + if (drive.IsReady && drive.Name.Equals(driveLetter, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + } + catch (Exception e) + { + Debug.LogError($"检测硬盘时发生错误: {e.Message}"); + } + + return false; + } + + + /// + /// 打开文件夹 + /// + /// + public static void OpenDirectory(string path) + { +#if UNITY_EDITOR + if (string.IsNullOrEmpty(path)) return; + path = path.Replace("/", "\\"); + if (!Directory.Exists(path)) + { + Debug.LogError("No Directory: " + path); + return; + } + + System.Diagnostics.Process.Start("explorer.exe", path); +#endif + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/Tools/FileUtility.cs.meta b/Assets/00.StaryEvo/Editor/Tools/FileUtility.cs.meta new file mode 100644 index 0000000..69ac0f4 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Tools/FileUtility.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fed445ec831030842bac58a58425da7e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Utils.meta b/Assets/00.StaryEvo/Editor/Utils.meta new file mode 100644 index 0000000..d62683c --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Utils.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4243a630ce08e1145a1511cf887befab +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Editor/Utils/EditorFrameworkUtils.cs b/Assets/00.StaryEvo/Editor/Utils/EditorFrameworkUtils.cs new file mode 100644 index 0000000..c4793e8 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Utils/EditorFrameworkUtils.cs @@ -0,0 +1,562 @@ +/**************************************************** + 文件:EditorFrameworkUtils.cs + 作者:张铮 + 邮箱: + 日期:2022/3/8 17:50:17 + 功能: +*****************************************************/ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using UnityEditor; +using UnityEngine; + +namespace EditorFramework +{ +#if UNITY_EDITOR + /// + /// 文件辅助类 + /// + public static class EditorFrameworkUtils + { + /// + /// 编码方式 + /// + private static readonly Encoding Encoding = Encoding.UTF8; + + /// + /// 递归取得文件夹下文件 + /// + /// + /// + public static void GetFiles(string dir, List list) + { + GetFiles(dir, list, new List()); + } + + /// + /// 递归取得文件夹下文件 + /// + /// + /// + /// + public static void GetFiles(string dir, List list, List fileExtsions) + { + //添加文件 + string[] files = Directory.GetFiles(dir); + if (fileExtsions.Count > 0) + { + foreach (string file in files) + { + string extension = Path.GetExtension(file); + if (extension != null && fileExtsions.Contains(extension)) + { + list.Add(file); + } + } + } + else + { + list.AddRange(files); + } + + //如果是目录,则递归 + DirectoryInfo[] directories = new DirectoryInfo(dir).GetDirectories(); + foreach (DirectoryInfo item in directories) + { + GetFiles(item.FullName, list, fileExtsions); + } + } + + /// + /// 创建文件夹 + /// + public static void CreateFolder() + { + // Directory.CreateDirectory();// + } + + /// + /// 写入文件 + /// + /// 文件名 + /// 文件内容 + public static void WriteFile(string filePath, string content) + { + try + { + var fs = new FileStream(filePath, FileMode.Create); + Encoding encode = Encoding; + //获得字节数组 + byte[] data = encode.GetBytes(content); + //开始写入 + fs.Write(data, 0, data.Length); + //清空缓冲区、关闭流 + fs.Flush(); + fs.Close(); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + + /// + /// 读取文件 + /// + /// + /// + public static string ReadFile(string filePath) + { + return ReadFile(filePath, Encoding); + } + + /// + /// 读取文件 + /// + /// + /// + /// + public static string ReadFile(string filePath, Encoding encoding) + { + using (var sr = new StreamReader(filePath, encoding)) + { + return sr.ReadToEnd(); + } + } + + /// + /// 读取文件 + /// + /// + /// + public static List ReadFileLines(string filePath) + { + var str = new List(); + using (var sr = new StreamReader(filePath, Encoding)) + { + String input; + while ((input = sr.ReadLine()) != null) + { + str.Add(input); + } + } + + return str; + } + + /// + /// 复制文件夹(及文件夹下所有子文件夹和文件) + /// + /// 待复制的文件夹路径 + /// 目标路径 + public static void CopyDirectory(String sourcePath, String destinationPath) + { + var info = new DirectoryInfo(sourcePath); + Directory.CreateDirectory(destinationPath); + foreach (FileSystemInfo fsi in info.GetFileSystemInfos()) + { + String destName = Path.Combine(destinationPath, fsi.Name); + + if (fsi is FileInfo) //如果是文件,复制文件 + File.Copy(fsi.FullName, destName); + else //如果是文件夹,新建文件夹,递归 + { + Directory.CreateDirectory(destName); + CopyDirectory(fsi.FullName, destName); + } + } + } + + /// + /// 删除文件夹(及文件夹下所有子文件夹和文件) + /// + /// + public static void DeleteFolder(string directoryPath) + { + foreach (string d in Directory.GetFileSystemEntries(directoryPath)) + { + if (File.Exists(d)) + { + var fi = new FileInfo(d); + if (fi.Attributes.ToString().IndexOf("ReadOnly", StringComparison.Ordinal) != -1) + fi.Attributes = FileAttributes.Normal; + File.Delete(d); //删除文件 + } + else + DeleteFolder(d); //删除文件夹 + } + + Directory.Delete(directoryPath); //删除空文件夹 + } + + /// + /// 清空文件夹(及文件夹下所有子文件夹和文件) + /// + /// + public static void ClearFolder(string directoryPath) + { + foreach (string d in Directory.GetFileSystemEntries(directoryPath)) + { + if (File.Exists(d)) + { + var fi = new FileInfo(d); + if (fi.Attributes.ToString().IndexOf("ReadOnly", StringComparison.Ordinal) != -1) + fi.Attributes = FileAttributes.Normal; + File.Delete(d); //删除文件 + } + else + DeleteFolder(d); //删除文件夹 + } + } + + /// + /// 取得文件大小,按适当单位转换 + /// + /// + /// + public static string GetFileSize(string filepath) + { + string result = "0KB"; + if (File.Exists(filepath)) + { + var size = new FileInfo(filepath).Length; + int filelength = size.ToString().Length; + if (filelength < 4) + result = size + "byte"; + else if (filelength < 7) + result = Math.Round(Convert.ToDouble(size / 1024d), 2) + "KB"; + else if (filelength < 10) + result = Math.Round(Convert.ToDouble(size / 1024d / 1024), 2) + "MB"; + else if (filelength < 13) + result = Math.Round(Convert.ToDouble(size / 1024d / 1024 / 1024), 2) + "GB"; + else + result = Math.Round(Convert.ToDouble(size / 1024d / 1024 / 1024 / 1024), 2) + "TB"; + return result; + } + + return result; + } + + /// + /// 删除文件. + /// + /// 删除完整文件夹路径. + /// 删除文件的名称. + public static void DeleteFile(string path, string name) + { + File.Delete(path + name); + } + + // /// + // /// 删除文件 + // /// + // /// + // /// + // /// + // public static bool DeleteFiles(string path, string filesName) + // { + // bool isDelete = false; + // try + // { + // if (Directory.Exists(path)) + // { + // if (File.Exists(PathUtil.Build(path, filesName))) + // { + // File.Delete(PathUtil.Build(path, filesName)); + // isDelete = true; + // } + // } + // } + // catch + // { + // return isDelete; + // } + // + // return isDelete; + // } + + /// + /// 删除文件夹下所有子文件夹与文件 + /// + public static void DeleteAllChild(string path, FileAttributes filter) + { + if (!Directory.Exists(path)) + return; + + DirectoryInfo dir = new DirectoryInfo(path); + FileInfo[] files = dir.GetFiles("*"); + for (int i = 0; i < files.Length; ++i) + { + if ((files[i].Attributes & filter) > 0) + continue; + if (File.Exists(files[i].FullName)) + File.Delete(files[i].FullName); + } + + DirectoryInfo[] dirs = dir.GetDirectories("*"); + for (int i = 0; i < dirs.Length; ++i) + { + if ((dirs[i].Attributes & filter) > 0) + continue; + + if (Directory.Exists(dirs[i].FullName)) + Directory.Delete(dirs[i].FullName, true); + } + } + + /// + /// 绝对路径转相对路径 + /// + public static string AbsoluteToRelativePath(string root_path, string absolute_path) + { + absolute_path = absolute_path.Replace('\\', '/'); + int last_idx = absolute_path.LastIndexOf(root_path); + if (last_idx < 0) + return absolute_path; + + int start = last_idx + root_path.Length; + if (absolute_path[start] == '/') + start += 1; + + int length = absolute_path.Length - start; + return absolute_path.Substring(start, length); + } + + /// + /// 获得取除路径扩展名的路径 + /// + public static string GetPathWithoutExtension(this string full_name) + { + int last_idx = full_name.LastIndexOfAny(".".ToCharArray()); + if (last_idx < 0) + return full_name; + + return full_name.Substring(0, last_idx); + } + + /// + /// 将字符串转为大写或小写 + /// + /// + /// + /// + public static string GetUpperOrLower(this string tmp, bool isUpper = true) + { + if (isUpper) + return tmp.ToLower(); + else + return tmp.ToUpper(); + } + /// + /// 判断是否有中文,有转为全拼 + /// + /// + /// + // public static string ChineseToPinYin(string text, bool isfile = true) + // { + // if (HasChinese(text)) + // { + // return ConvertPinYin(text, isfile).GetUpperOrLower().Replace(" ", ""); + // } + // else + // { + // if (isfile) + // text = String.Concat("_", text); + // return text.GetUpperOrLower(); + // } + // } + + /// + /// 判断字符串中是否有中文 + /// + private static bool HasChinese(string s) + { + return Regex.IsMatch(s, "[\u4e00-\u9fbb]"); + } + + /// + /// 汉字转全拼 + /// + // private static string ConvertPinYin(string text, bool isfile = true) + // { + // if (string.IsNullOrEmpty(text)) + // return text; + // + // try + // { + // var sb = new StringBuilder(); + // bool isfirstchinese = false; + // if (HasChinese(text.ToList()[0].ToString())) + // { + // isfirstchinese = true; + // } + // + // for (int i = 0; i < text.ToList().Count; i++) + // { + // if (text.ToList()[i] <= 127) + // sb.Append(text.ToList()[i]); + // else + // sb.Append($"_{NPinyin.Pinyin.GetPinyin(text.ToList()[i])}_"); + // } + // + // var name = sb.ToString().Replace("__", "_"); + // if (!isfile) //裁剪首尾字符“_” + // { + // name = name.Trim('_'); + // } + // else + // { + // name = name.TrimEnd('_'); + // if (!isfirstchinese) + // name = String.Concat("_", name); + // } + // + // return name; + // } + // catch (Exception e) + // { + // Debug.LogError($"拼音转换失败:{text} {e.Message}"); + // } + // + // return text; + // } + + /// + /// 删除指定字符后的字符串 + /// + /// 字符串 + /// 符号例如:“ .” + /// + public static string DeleteLastIndex(string fileName, string lastIndex) + { + int index = fileName.LastIndexOf(lastIndex); + if (index >= 0) + { + fileName = fileName.Substring(0, index); + } + + return fileName; + } + + /// + /// 带颜色的日志输出 + /// + public static void LogColor(string s, string path = null, Color color = default) + { + if (string.IsNullOrEmpty(path)) + Debug.Log($"{s}"); + else + { + string assetPath = s.Replace("\\", "/").Replace(Application.dataPath, "Assets"); + Debug.Log($"{assetPath}", + AssetDatabase.LoadAssetAtPath(assetPath)); + } + } + + /// + /// 过滤:去掉首尾空格和换行符【\n】 + /// + private static string FilterTo(string self) + { + self = self.TrimStart(); + self = self.TrimEnd(); + self = self.Replace("\n", ""); + return self; + } + + /// + /// 获取Assets下带.meta文件的资源的路径 + /// + /// 文件夹、资源 + private static string[] GetPathsOfAssetsObject(string objectName) + { + string[] guids = AssetDatabase.FindAssets(objectName); + string[] paths = new string[guids.Length]; + for (int i = 0; i < guids.Length; i++) + { + string path = AssetDatabase.GUIDToAssetPath(guids[i]); + if (path.Contains("Assets")) + paths[i] = path; + } + + return paths; + } + + /// + /// 保存json文件 + /// + /// 数据 + /// 服务器路径 + /// json名称 + /// + public static void SaveJson(T data, string serverPath, string jsonName) + { + string json = JsonConvert.SerializeObject(data); + // 获取Assets目录的上级路径 + string path = Path.Combine(serverPath, $"{jsonName}.json"); + + if (!Directory.Exists(serverPath)) + { + Directory.CreateDirectory(serverPath); + } + + File.WriteAllText(path, json, Encoding.UTF8); + + AssetDatabase.Refresh(); + // 保存更改 + AssetDatabase.SaveAssets(); + } + // ... 保持原有 using 和命名空间不变 ... + + + /// + /// 修改文件后缀名 + /// + /// 原始文件路径 + /// 新后缀名(带或不带点) + /// 新文件路径 + public static string ChangeFileExtension(string filePath, string newExtension) + { + if (string.IsNullOrEmpty(filePath)) + return filePath; + + string directory = Path.GetDirectoryName(filePath); + string fileName = Path.GetFileNameWithoutExtension(filePath); + newExtension = newExtension.StartsWith(".") ? newExtension : $".{newExtension}"; + return Path.Combine(directory, $"{fileName}{newExtension}"); + } + + /// + /// 实际修改文件后缀名并移动文件 + /// + /// 原始文件路径 + /// 新后缀名(带或不带点) + /// 是否覆盖已存在文件 + public static void RenameFileExtension(string sourcePath, string newExtension, bool overwrite = true) + { + string newPath = ChangeFileExtension(sourcePath, newExtension); + + if (File.Exists(sourcePath)) + { + if (File.Exists(newPath) && overwrite) + { + File.Delete(newPath); + } + + File.Move(sourcePath, newPath); + } + +#if UNITY_EDITOR + AssetDatabase.Refresh(); +#endif + } + + // ... 后续原有方法保持不变 ... + } +#endif +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Editor/Utils/EditorFrameworkUtils.cs.meta b/Assets/00.StaryEvo/Editor/Utils/EditorFrameworkUtils.cs.meta new file mode 100644 index 0000000..a423322 --- /dev/null +++ b/Assets/00.StaryEvo/Editor/Utils/EditorFrameworkUtils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 43588cd3871baa94aa8202bf75437197 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.InformationSave/Editor/InformationSave.Editor.asmdef b/Assets/00.StaryEvo/Editor/com.stary.evo.editor.asmdef similarity index 55% rename from Assets/02.InformationSave/Editor/InformationSave.Editor.asmdef rename to Assets/00.StaryEvo/Editor/com.stary.evo.editor.asmdef index 33c46dd..e2bceb6 100644 --- a/Assets/02.InformationSave/Editor/InformationSave.Editor.asmdef +++ b/Assets/00.StaryEvo/Editor/com.stary.evo.editor.asmdef @@ -1,8 +1,12 @@ { - "name": "InformationSave.Editor", + "name": "com.stary.evo.editor", "rootNamespace": "", "references": [ - "GUID:798515657a60df04299a490c4f01f2b7" + "GUID:d1a793c2b6959e04ea45b972eaa369c8", + "GUID:2373f786d14518f44b0f475db77ba4de", + "GUID:c5ecc461727906345a35491a0440694f", + "GUID:4d1926c9df5b052469a1c63448b7609a", + "GUID:e34a5702dd353724aa315fb8011f08c3" ], "includePlatforms": [ "Editor" diff --git a/Assets/02.InformationSave/RunTime/InformationSave.RunTime.asmdef.meta b/Assets/00.StaryEvo/Editor/com.stary.evo.editor.asmdef.meta similarity index 76% rename from Assets/02.InformationSave/RunTime/InformationSave.RunTime.asmdef.meta rename to Assets/00.StaryEvo/Editor/com.stary.evo.editor.asmdef.meta index 595b339..6afc490 100644 --- a/Assets/02.InformationSave/RunTime/InformationSave.RunTime.asmdef.meta +++ b/Assets/00.StaryEvo/Editor/com.stary.evo.editor.asmdef.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 798515657a60df04299a490c4f01f2b7 +guid: 044184040b21c434b8aee6f2a3424c06 AssemblyDefinitionImporter: externalObjects: {} userData: diff --git a/Assets/00.StaryEvo/Runtime.meta b/Assets/00.StaryEvo/Runtime.meta new file mode 100644 index 0000000..5a671bb --- /dev/null +++ b/Assets/00.StaryEvo/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9ea0e0cec345a1f4badc8365ec7ac027 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Architecture.meta b/Assets/00.StaryEvo/Runtime/Architecture.meta new file mode 100644 index 0000000..5deaa46 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 218dd6b6c808431fbd852e29526cd2ae +timeCreated: 1624936510 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Architecture.cs b/Assets/00.StaryEvo/Runtime/Architecture/Architecture.cs new file mode 100644 index 0000000..6778471 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Architecture.cs @@ -0,0 +1,389 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ + /// + /// 架构 + /// + /// + public abstract class Architecture : IArchitecture where T : Architecture, new() + { + /// + /// 是否已经初始化完成 + /// + private bool mInited = false; + + /// + /// 用于初始化的 Datas 的缓存 + /// + private List mDatas = new List(); + + /// + /// 用于初始化的 Systems 的缓存 + /// + private List mSystems = new List(); + + + /// + /// IOC + /// + private IOCContainer mContainer = new IOCContainer(); + + // 留给子类注册模块 + protected abstract void Init(); + + #region 类似单例模式 但是仅在内部访问 + + private static T mArchitecture = null; + + public static IArchitecture Interface + { + get + { + if (mArchitecture == null) + { + MakeSureArchitecture(); + } + + return mArchitecture; + } + } + + /// + /// 增加注册 + /// + public static Action OnRegisterPatch = architecture => { Debug.Log("调用了"); }; + + // 确保 Container 是有实例的 + static void MakeSureArchitecture() + { + Debug.Log((mArchitecture == null) + "----mArchitecture是否为空"); + if (mArchitecture == null) + { + mArchitecture = new T(); + mArchitecture.Init(); + mArchitecture.IOCInitClass(); + // 调用 + OnRegisterPatch?.Invoke(mArchitecture); + + // 初始化 Data + for (int i = 0; i < mArchitecture.mDatas.Count; i++) + { + mArchitecture.mDatas[i].Init(); + } + + // 清空 Data + mArchitecture.mDatas.Clear(); + + // 初始化 System + for (int i = 0; i < mArchitecture.mSystems.Count; i++) + { + mArchitecture.mSystems[i].Init(); + } + + // 清空 System + mArchitecture.mSystems.Clear(); + mArchitecture.mInited = true; + } + } + + // // 提供一个释放模块的 API + public static void Dispose() + { + for (int i = 0; i < mArchitecture.mSystems.Count; i++) + { + mArchitecture.mSystems[i].Dispose(); + } + + for (int i = 0; i < mArchitecture.mDatas.Count; i++) + { + mArchitecture.mDatas[i].Dispose(); + } + + mArchitecture = null; + } + + #endregion + + + #region 组件注册 + + // 提供一个注册 System 的 API + public void RegisterSystem(TSystem system) where TSystem : ISystem + { + // 需要给 System 赋值一下 + system.SetArchitecture(this); + mContainer.Register(system); + + // 如果初始化过了 + if (mInited) + { + system.Init(); + } + else + { + // 添加到 System 缓存中,用于初始化 + mSystems.Add(system); + } + } + + // 提供一个注册 Data 的 API + public void RegisterData(TData data) where TData : IData + { + // 需要给 Data 赋值一下 + data.SetArchitecture(this); + mContainer.Register(data); + // 如果初始化过了 + if (mInited) + { + data.Init(); + } + else + { + // 添加到 Data 缓存中,用于初始化 + mDatas.Add(data); + } + } + + // 提供一个注册工具模块的 API + public void RegisterUtility(TUtility utility) where TUtility : IUtility + { + mContainer.Register(utility); + } + + // 提供一个获取 Data 的 API + public TData GetData() where TData : class, IData + { + return mContainer.Get(); + } + + #endregion + + #region IOC容器注册 + + //IOC初始化注册 + private void IOCInitClass() + { + } + + // // 提供一个注册模块的 API + public static void RegisterIOC(TArchitecture instance) + { + mArchitecture = null; + MakeSureArchitecture(); + mArchitecture.mContainer.Register(instance); + } + + // 提供一个获取模块的 API + public static TArchitecture GetIOC() where TArchitecture : class + { + MakeSureArchitecture(); + return mArchitecture.mContainer.Get(); + } + + // 提供一个获取模块的 API + public static void UnRegisterIOC() where TArchitecture : class + { + mArchitecture.mContainer.UnRegister(); + } + + #endregion + + // 提供一个获取工具模块的 API + public TUtility GetUtility() where TUtility : class, IUtility + { + return mContainer.Get(); + } + + // 提供一个获取系统的 API + public TSystem GetSystem() where TSystem : class, ISystem + { + return mContainer.Get(); + } + + // 提供一个传递Command的 API(不经过对象池) + public void SendCommand() where TCommand : ICommand, new() + { + var command = new TCommand(); + ExecuteCommand(command); + } + + // 提供一个传递Command的 API + public void SendCommand(TCommand command) where TCommand : ICommand + { + ExecuteCommand(command); + } + + protected virtual void ExecuteCommand(ICommand command) + { + command.SetArchitecture(this); + command.Execute(); + } + + private EnumEventSystem _mEnumEventSystem = new EnumEventSystem(); + + /// + /// 事件发送 + /// + /// + public void SendEvent(TEvent key) where TEvent : IConvertible + { + _mEnumEventSystem.Send(key); + } + + /// + /// 事件发送 + /// + /// + public void SendEvent(TEvent key, Tvalue1 value) where TEvent : IConvertible + { + _mEnumEventSystem.Send(key, value); + } + + /// + /// 事件发送 + /// + /// + public void SendEvent(TEvent key, Tvalue1 value1, Tvalue2 value2) + where TEvent : IConvertible + { + _mEnumEventSystem.Send(key, value1, value2); + } + + /// + /// 事件发送 + /// + /// + public void SendEvent(TEvent key, Tvlue1 value1, Tvlue2 vlue2, Tvlue3 vlue3) + where TEvent : IConvertible + { + _mEnumEventSystem.Send(key, value1, vlue2, vlue3); + } + + /// + /// 事件发送 + /// + /// + public void SendEvent(TEvent key, object[] values) where TEvent : IConvertible + { + _mEnumEventSystem.Send(key, values); + } + + /// + /// 事件监听 + /// + /// + /// + /// + public IUnRegister RegisterEvent(TEvent key, Action onEvent) where TEvent : IConvertible + { + return _mEnumEventSystem.Register(key, onEvent); + } + + /// + /// 事件监听 + /// + /// + /// + /// + public IUnRegister RegisterEvent(TEvent key, Action onEvent) + where TEvent : IConvertible + { + return _mEnumEventSystem.Register(key, onEvent); + } + + /// + /// 事件监听 + /// + /// + /// + /// + public IUnRegister RegisterEvent(TEvent key, Action onEvent) + where TEvent : IConvertible + { + return _mEnumEventSystem.Register(key, onEvent); + } + + /// + /// 事件监听 + /// + /// + /// + /// + public IUnRegister RegisterEvent(TEvent key, + Action onEvent) where TEvent : IConvertible + { + return _mEnumEventSystem.Register(key, onEvent); + } + + /// + /// 事件监听 + /// + /// + /// + /// + public IUnRegister RegisterEvent(TEvent key, Action onEvent) where TEvent : IConvertible + { + return _mEnumEventSystem.Register(key, onEvent); + } + + /// + /// 事件销毁 + /// + /// + /// + public void UnRegisterEvent(TEvent key, Action onEvent)where TEvent : IConvertible + { + _mEnumEventSystem.UnRegister(key,onEvent); + } + /// + /// 事件销毁 + /// + /// + /// + public void UnRegisterEvent(TEvent key, Action< Tvalue1> onEvent)where TEvent : IConvertible + { + _mEnumEventSystem.UnRegister(key,onEvent); + } + /// + /// 事件销毁 + /// + /// + /// + public void UnRegisterEvent(TEvent key, Action onEvent)where TEvent : IConvertible + { + _mEnumEventSystem.UnRegister(key,onEvent); + } + /// + /// 事件销毁 + /// + /// + /// + public void UnRegisterEvent(TEvent key, Action onEvent)where TEvent : IConvertible + { + _mEnumEventSystem.UnRegister(key,onEvent); + } + /// + /// 事件销毁 + /// + /// + /// + public void UnRegisterEvent(TEvent key, Action onEvent)where TEvent : IConvertible + { + _mEnumEventSystem.UnRegister(key,onEvent); + } + public TResult SendQuery(IQuery query) + { + return DoQuery(query); + } + + protected virtual TResult DoQuery(IQuery query) + { + query.SetArchitecture(this); + return query.Do(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Architecture.cs.meta b/Assets/00.StaryEvo/Runtime/Architecture/Architecture.cs.meta new file mode 100644 index 0000000..fbbc12f --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Architecture.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0fb98abbb7c823c4bafea1f9b125736d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes.meta b/Assets/00.StaryEvo/Runtime/Architecture/Attributes.meta new file mode 100644 index 0000000..95fe0f8 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 75d4c33e7e46b5c478f8e068ed9be6c6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionCNAttribute.cs b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionCNAttribute.cs new file mode 100644 index 0000000..0b252a1 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionCNAttribute.cs @@ -0,0 +1,22 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License + * + * http://qframework.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using System; + +namespace Stary.Evo +{ + public class APIDescriptionCNAttribute : Attribute + { + public string Description { get; private set; } + + public APIDescriptionCNAttribute(string description) + { + Description = description; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionCNAttribute.cs.meta b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionCNAttribute.cs.meta new file mode 100644 index 0000000..0710b0a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionCNAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2c5538bb5e55498ba063f98c0c7a8800 +timeCreated: 1647422088 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionENAttribute.cs b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionENAttribute.cs new file mode 100644 index 0000000..b4b230a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionENAttribute.cs @@ -0,0 +1,23 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License + * + * http://qframework.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using System; + +namespace Stary.Evo +{ + public class APIDescriptionENAttribute : Attribute + { + public string Description { get; private set; } + + public APIDescriptionENAttribute(string description) + { + Description = description; + } + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionENAttribute.cs.meta b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionENAttribute.cs.meta new file mode 100644 index 0000000..f018dd4 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIDescriptionENAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 570b6aa696204dbc949fea41caf8fcae +timeCreated: 1647422110 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIExampleCodeAttribute.cs b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIExampleCodeAttribute.cs new file mode 100644 index 0000000..f2fea4b --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIExampleCodeAttribute.cs @@ -0,0 +1,22 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License + * + * http://qframework.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using System; + +namespace Stary.Evo +{ + public class APIExampleCodeAttribute : Attribute + { + public string Code { get; private set; } + + public APIExampleCodeAttribute(string code) + { + Code = code; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIExampleCodeAttribute.cs.meta b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIExampleCodeAttribute.cs.meta new file mode 100644 index 0000000..62c4736 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/APIExampleCodeAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b48b349a950f405095cf304b9bde0338 +timeCreated: 1647424574 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/ClassAPIAttribute.cs b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/ClassAPIAttribute.cs new file mode 100644 index 0000000..24f27cb --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/ClassAPIAttribute.cs @@ -0,0 +1,24 @@ + +using System; + +namespace Stary.Evo +{ + [AttributeUsage(AttributeTargets.Class)] + public class ClassAPIAttribute : Attribute + { + public string DisplayMenuName { get; private set; } + public string GroupName { get; private set; } + + public int RenderOrder { get;private set; } + + public string DisplayClassName { get; private set; } + + public ClassAPIAttribute(string groupName, string displayMenuName,int renderOrder,string displayClassName = null) + { + GroupName = groupName; + DisplayMenuName = displayMenuName; + RenderOrder = renderOrder; + DisplayClassName = displayClassName; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/ClassAPIAttribute.cs.meta b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/ClassAPIAttribute.cs.meta new file mode 100644 index 0000000..8cfa49a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/ClassAPIAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 72248ec1038f4ce58ad2861e9b02aa52 +timeCreated: 1647404455 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/MethodAPIAttribute.cs b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/MethodAPIAttribute.cs new file mode 100644 index 0000000..b562b70 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/MethodAPIAttribute.cs @@ -0,0 +1,18 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License + * + * http://qframework.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using System; + +namespace Stary.Evo +{ + [AttributeUsage(AttributeTargets.Method)] + public class MethodAPIAttribute : Attribute + { + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/MethodAPIAttribute.cs.meta b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/MethodAPIAttribute.cs.meta new file mode 100644 index 0000000..54f3e17 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/MethodAPIAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5db430b6c4ac4de5a9836454125e0669 +timeCreated: 1647428627 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/PropertyAPIAttribute.cs b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/PropertyAPIAttribute.cs new file mode 100644 index 0000000..d2322f3 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/PropertyAPIAttribute.cs @@ -0,0 +1,18 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License + * + * http://qframework.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using System; + +namespace Stary.Evo +{ + [AttributeUsage(AttributeTargets.Property)] + public class PropertyAPIAttribute : Attribute + { + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/Attributes/PropertyAPIAttribute.cs.meta b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/PropertyAPIAttribute.cs.meta new file mode 100644 index 0000000..b7c2829 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/Attributes/PropertyAPIAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ab3c662f56b4401eaad6594ef6182e75 +timeCreated: 1647515468 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/IArchitecture.cs b/Assets/00.StaryEvo/Runtime/Architecture/IArchitecture.cs new file mode 100644 index 0000000..ebe15a6 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/IArchitecture.cs @@ -0,0 +1,173 @@ +using System; + +namespace Stary.Evo +{ + public interface IArchitecture + { + /// + /// 注册 System + /// + void RegisterSystem(T instance) where T : ISystem; + + /// + /// 获取 System + /// + T GetSystem() where T : class, ISystem; + + + /// + /// 注册 Data + /// + void RegisterData(T instance) where T : IData; + + /// + /// 获取 Data + /// + /// + /// + T GetData() where T : class, IData; + + + /// + /// 注册 Utility + /// + void RegisterUtility(T instance) where T : IUtility; + + /// + /// 获取 Utility + /// + T GetUtility() where T : class, IUtility; + + + /// + /// 发送命令 + /// + void SendCommand() where T : ICommand, new(); + + /// + /// 发送命令 + /// + void SendCommand(T command) where T : ICommand; + + /// + /// 事件发送 + /// + /// + public void SendEvent(TEvent key) where TEvent : IConvertible; + + /// + /// 事件发送 + /// + /// + public void SendEvent(TEvent key, Tvalue1 value) where TEvent : IConvertible; + + /// + /// 事件发送 + /// + /// + public void SendEvent(TEvent key, Tvalue1 value1, Tvalue2 value2) + where TEvent : IConvertible; + + /// + /// 事件发送 + /// + /// + public void SendEvent(TEvent key, Tvlue1 value1, Tvlue2 vlue2, Tvlue3 vlue3) + where TEvent : IConvertible; + + /// + /// 事件发送 + /// + /// + public void SendEvent(TEvent key, object[] values) where TEvent : IConvertible; + + /// + /// 事件监听 + /// + /// + /// + /// + public IUnRegister RegisterEvent(TEvent key, Action onEvent) where TEvent : IConvertible; + + /// + /// 事件监听 + /// + /// + /// + /// + public IUnRegister RegisterEvent(TEvent key, Action onEvent) + where TEvent : IConvertible; + + /// + /// 事件监听 + /// + /// + /// + /// + public IUnRegister RegisterEvent(TEvent key, Action onEvent) + where TEvent : IConvertible; + + /// + /// 事件监听 + /// + /// + /// + /// + public IUnRegister RegisterEvent(TEvent key, + Action onEvent) where TEvent : IConvertible; + + /// + /// 事件监听 + /// + /// + /// + /// + public IUnRegister RegisterEvent(TEvent key, Action onEvent) where TEvent : IConvertible; + + /// + /// 事件销毁 + /// + /// + /// + public void UnRegisterEvent(TEvent key, Action onEvent) where TEvent : IConvertible; + + /// + /// 事件销毁 + /// + /// + /// + public void UnRegisterEvent(TEvent key, Action onEvent) where TEvent : IConvertible; + + /// + /// 事件销毁 + /// + /// + /// + public void UnRegisterEvent(TEvent key, Action onEvent) + where TEvent : IConvertible; + + /// + /// 事件销毁 + /// + /// + /// + /// + /// + /// + /// + public void UnRegisterEvent(TEvent key, Action onEvent) + where TEvent : IConvertible; + + /// + /// 事件销毁 + /// + /// + /// + /// + /// + public void UnRegisterEvent(TEvent key, Action onEvent) where TEvent : IConvertible; + + + TResult SendQuery(IQuery query); + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Architecture/IArchitecture.cs.meta b/Assets/00.StaryEvo/Runtime/Architecture/IArchitecture.cs.meta new file mode 100644 index 0000000..afa1c5a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Architecture/IArchitecture.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 55418c02fe504af59375dddd017925f3 +timeCreated: 1624954968 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/BindableProperty.meta b/Assets/00.StaryEvo/Runtime/BindableProperty.meta new file mode 100644 index 0000000..7ce2468 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/BindableProperty.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 315d6f08092768e47a024d5c7d094717 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/BindableProperty/BindableProperty.cs b/Assets/00.StaryEvo/Runtime/BindableProperty/BindableProperty.cs new file mode 100644 index 0000000..b7f7edf --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/BindableProperty/BindableProperty.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ + + public interface IBindableProperty : IReadonlyBindableProperty + { + new T Value { get; set; } + void SetValueWithoutEvent(T newValue); + } + + public interface IReadonlyBindableProperty + { + T Value { get; } + + IUnRegister RegisterWithInitValue(Action action); + void UnRegister(Action onValueChanged); + IUnRegister Register(Action onValueChanged); + } + + public class BindableProperty : IBindableProperty + { + public BindableProperty(T defaultValue = default) + { + mValue = defaultValue; + } + + protected T mValue; + + public T Value + { + get => GetValue(); + set + { + if (value == null && mValue == null) return; + if (value != null && value.Equals(mValue)) return; + + SetValue(value); + mOnValueChanged?.Invoke(value); + } + } + + protected virtual void SetValue(T newValue) + { + mValue = newValue; + } + + protected virtual T GetValue() + { + return mValue; + } + + public void SetValueWithoutEvent(T newValue) + { + mValue = newValue; + } + + private Action mOnValueChanged = (v) => { }; + + public IUnRegister Register(Action onValueChanged) + { + mOnValueChanged += onValueChanged; + return new BindablePropertyUnRegister() + { + BindableProperty = this, + OnValueChanged = onValueChanged + }; + } + + public IUnRegister RegisterWithInitValue(Action onValueChanged) + { + onValueChanged(mValue); + return Register(onValueChanged); + } + + public static implicit operator T(BindableProperty property) + { + return property.Value; + } + + public override string ToString() + { + return Value.ToString(); + } + + public void UnRegister(Action onValueChanged) + { + mOnValueChanged -= onValueChanged; + } + } + + public class BindablePropertyUnRegister : IUnRegister + { + public BindableProperty BindableProperty { get; set; } + + public Action OnValueChanged { get; set; } + + public void UnRegister() + { + BindableProperty.UnRegister(OnValueChanged); + + BindableProperty = null; + OnValueChanged = null; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/BindableProperty/BindableProperty.cs.meta b/Assets/00.StaryEvo/Runtime/BindableProperty/BindableProperty.cs.meta new file mode 100644 index 0000000..bbafb78 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/BindableProperty/BindableProperty.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 57e121dc01fbf6b4f973d5170b1b7050 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Design.meta b/Assets/00.StaryEvo/Runtime/Design.meta new file mode 100644 index 0000000..35dc277 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5029af932e6e4085b9438be230c649b7 +timeCreated: 1624956902 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/ICommand.cs b/Assets/00.StaryEvo/Runtime/Design/ICommand.cs new file mode 100644 index 0000000..fa7badd --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/ICommand.cs @@ -0,0 +1,34 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ + public interface ICommand : IBelongToArchitecture,ICanSetArchitecture,ICanGetSystem,ICanGetData,ICanGetUtility,ICanSendCommand,ICanSendEvent, ICanSendQuery + { + void Execute(); + } + + public abstract class AbstractCommand : ICommand + { + private IArchitecture mArchitecture; + + IArchitecture IBelongToArchitecture.GetArchitecture() + { + return mArchitecture; + } + + void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) + { + mArchitecture = architecture; + + } + + void ICommand.Execute() + { + OnExecute(); + } + + protected abstract void OnExecute(); + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/ICommand.cs.meta b/Assets/00.StaryEvo/Runtime/Design/ICommand.cs.meta new file mode 100644 index 0000000..b8c9485 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/ICommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 501ba9abd3ae8344c8f30f3d4a18b34b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Design/IController.cs b/Assets/00.StaryEvo/Runtime/Design/IController.cs new file mode 100644 index 0000000..521c941 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/IController.cs @@ -0,0 +1,7 @@ +namespace Stary.Evo +{ + public interface IController:IBelongToArchitecture,ICanGetSystem,ICanGetData,ICanSendCommand,ICanRegisterEvent,ICanSendQuery, ICanGetUtility + { + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/IController.cs.meta b/Assets/00.StaryEvo/Runtime/Design/IController.cs.meta new file mode 100644 index 0000000..427cfe3 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/IController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 485e552656f54b618a85271943a76c3d +timeCreated: 1625018098 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/IData.cs b/Assets/00.StaryEvo/Runtime/Design/IData.cs new file mode 100644 index 0000000..462c02e --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/IData.cs @@ -0,0 +1,34 @@ +namespace Stary.Evo +{ + public interface IData: IBelongToArchitecture,ICanSetArchitecture,ICanGetUtility ,ICanSendEvent + { + void Init(); + void Dispose(); + } + + public abstract class AbstractData : IData + { + private IArchitecture mArchitecture; + //接口阉割,子类重写无法用子类调用 + IArchitecture IBelongToArchitecture.GetArchitecture() + { + return mArchitecture; + } + + void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) + { + mArchitecture = architecture; + } + + void IData.Init() + { + OnInit(); + } + + public abstract void Dispose(); + + //数据初始化 + protected abstract void OnInit(); + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/IData.cs.meta b/Assets/00.StaryEvo/Runtime/Design/IData.cs.meta new file mode 100644 index 0000000..852dd6c --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/IData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2138d8e4edea4564b328a71f45aadfd7 +timeCreated: 1624937508 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/IQuery.cs b/Assets/00.StaryEvo/Runtime/Design/IQuery.cs new file mode 100644 index 0000000..1d82588 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/IQuery.cs @@ -0,0 +1,29 @@ +namespace Stary.Evo +{ + public interface IQuery : IBelongToArchitecture,ICanSetArchitecture,ICanGetData,ICanGetSystem,ICanGetUtility + { + TResult Do(); + } + + public abstract class AbstractQuery : IQuery + { + public T Do() + { + return OnDo(); + } + + protected abstract T OnDo(); + + private IArchitecture mArchitecture; + + IArchitecture IBelongToArchitecture.GetArchitecture() + { + return mArchitecture; + } + + void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) + { + mArchitecture = architecture; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/IQuery.cs.meta b/Assets/00.StaryEvo/Runtime/Design/IQuery.cs.meta new file mode 100644 index 0000000..8338b3a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/IQuery.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f4fd5f513a09f6f47b1b0a27a2f0500e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Design/ISystem.cs b/Assets/00.StaryEvo/Runtime/Design/ISystem.cs new file mode 100644 index 0000000..063a53f --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/ISystem.cs @@ -0,0 +1,30 @@ +namespace Stary.Evo +{ + public interface ISystem: IBelongToArchitecture,ICanSetArchitecture,ICanGetData,ICanGetUtility ,ICanRegisterEvent,ICanSendEvent,ICanGetSystem + { + void Init(); + void Dispose(); + } + public abstract class AbstractSystem : ISystem + { + private IArchitecture mArchitecture; + IArchitecture IBelongToArchitecture.GetArchitecture() + { + return mArchitecture; + } + + void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) + { + mArchitecture = architecture; + } + + void ISystem.Init() + { + OnInit(); + } + + public abstract void Dispose(); + + protected abstract void OnInit(); + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/ISystem.cs.meta b/Assets/00.StaryEvo/Runtime/Design/ISystem.cs.meta new file mode 100644 index 0000000..f7b6e64 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/ISystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 187938c258244d9ea6e81a5948033cf8 +timeCreated: 1624954926 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/IUtility.cs b/Assets/00.StaryEvo/Runtime/Design/IUtility.cs new file mode 100644 index 0000000..426ac0b --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/IUtility.cs @@ -0,0 +1,7 @@ +namespace Stary.Evo +{ + public interface IUtility + { + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/IUtility.cs.meta b/Assets/00.StaryEvo/Runtime/Design/IUtility.cs.meta new file mode 100644 index 0000000..3294325 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/IUtility.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 55d0b44b52f841d4af6f7ebc0cad1abe +timeCreated: 1625038442 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/UnRegisterOnDestroyTrigger.cs b/Assets/00.StaryEvo/Runtime/Design/UnRegisterOnDestroyTrigger.cs new file mode 100644 index 0000000..af0fd0a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/UnRegisterOnDestroyTrigger.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ + + /// + /// 用于注销的接口(为了防止注册后忘记注销特实现此接口) + /// + public interface IUnRegister + { + void UnRegister(); + } + public interface IUnRegisterList + { + List UnregisterList { get; } + } + public static class IUnRegisterListExtension + { + public static void AddToUnregisterList(this IUnRegister self, IUnRegisterList unRegisterList) + { + unRegisterList.UnregisterList.Add(self); + } + + public static void UnRegisterAll(this IUnRegisterList self) + { + foreach (var unRegister in self.UnregisterList) + { + unRegister.UnRegister(); + } + + self.UnregisterList.Clear(); + } + } + /// + /// 自定义可注销的类 + /// + public struct CustomUnRegister : IUnRegister + { + /// + /// 委托对象 + /// + private Action mOnUnRegister { get; set; } + + /// + /// 带参构造函数 + /// + /// + public CustomUnRegister(Action onUnRegsiter) + { + mOnUnRegister = onUnRegsiter; + } + + /// + /// 资源释放 + /// + public void UnRegister() + { + mOnUnRegister.Invoke(); + mOnUnRegister = null; + } + } + /// + /// 注销的触发器 + /// + public class UnRegisterOnDestroyTrigger : MonoBehaviour + { + private HashSet mUnRegisters = new HashSet(); + + public void AddUnRegister(IUnRegister unRegister) + { + mUnRegisters.Add(unRegister); + } + public void RemoveUnRegister(IUnRegister unRegister) + { + mUnRegisters.Remove(unRegister); + } + + private void OnDestroy() + { + foreach (var unRegister in mUnRegisters) + { + unRegister.UnRegister(); + } + + mUnRegisters.Clear(); + } + } + + /// + /// 注销触发器的使用简化 + /// + public static class UnRegisterExtension + { + public static IUnRegister UnRegisterWhenGameObjectDestroyed(this IUnRegister unRegister, GameObject gameObject) + { + var trigger = gameObject.GetComponent()??null; + + if (!trigger) + { + trigger = gameObject.AddComponent(); + } + + trigger.AddUnRegister(unRegister); + + return unRegister; + } + } + +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Design/UnRegisterOnDestroyTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Design/UnRegisterOnDestroyTrigger.cs.meta new file mode 100644 index 0000000..af7dd48 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Design/UnRegisterOnDestroyTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 81fe5c4dfa304c2ab19ebf1cc876813e +timeCreated: 1730381395 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/DomainBase.cs b/Assets/00.StaryEvo/Runtime/DomainBase.cs new file mode 100644 index 0000000..51a8064 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/DomainBase.cs @@ -0,0 +1,44 @@ +using System.Threading.Tasks; +using UnityEngine; +using UnityEngine.Events; + +namespace Stary.Evo +{ + /// + /// 热更基类,应该继承的基类 + /// + public class DomainBase : MonoBehaviour + { + /// + /// 触发Domain时,调用该方法 + /// + /// + public virtual void OnEnter(string param) + { + } + + /// + /// Domain被关闭时,会调该方法 + /// + /// + public virtual void OnExit() + { + } + + /// + /// 如果Domain主动退出,请触发此Action + /// + public UnityAction RequestExit; + + public virtual async Task OnEnterAsync(string param) + { + await Task.Delay(1); + } + + public virtual async Task OnExitAsync() + { + await Task.Delay(1); + } + } +} + diff --git a/Assets/00.StaryEvo/Runtime/DomainBase.cs.meta b/Assets/00.StaryEvo/Runtime/DomainBase.cs.meta new file mode 100644 index 0000000..a17165a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/DomainBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8923efe3eb184e7f9283f71e2dc4ea10 +timeCreated: 1742540500 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/IOC.meta b/Assets/00.StaryEvo/Runtime/IOC.meta new file mode 100644 index 0000000..cab875d --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/IOC.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 36db59b1e91d4e6aa6155fd9cf38164e +timeCreated: 1624956940 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/IOC/IOCContainer.cs b/Assets/00.StaryEvo/Runtime/IOC/IOCContainer.cs new file mode 100644 index 0000000..81a96cd --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/IOC/IOCContainer.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ + public class IOCContainer + { + /// + /// 实例 + /// + public Dictionary mInstances = new Dictionary(); + + /// + /// 注册 + /// + /// + /// + public void Register(T instance) + { + var key = typeof(T); + + if (mInstances.ContainsKey(key)) + { + mInstances[key] = instance; + } + else + { + mInstances.Add(key, instance); + } + } + + /// + /// 注销 + /// + public void UnRegister() where T : class + { + var key = typeof(T); + + + if (mInstances.TryGetValue(key, out var retObj)) + { + retObj = null; + mInstances.Remove(key); + } + else + { + Debug.LogErrorFormat("IOC容器里不存在Key:--【{0}】--请用对应创建的key进行调用",key); + + } + } + public T Get() where T : class + { + var key = typeof(T); + + + if (mInstances.TryGetValue(key, out var retObj)) + { + return retObj as T; + } + else + { + Debug.LogErrorFormat("IOC容器里不存在Key:--【{0}】--请用对应创建的key进行调用",key); + + } + + return null; + } + } + +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/IOC/IOCContainer.cs.meta b/Assets/00.StaryEvo/Runtime/IOC/IOCContainer.cs.meta new file mode 100644 index 0000000..25b83f1 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/IOC/IOCContainer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: efee404ec60bbfb4c86bce2914f6c7cb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/PlayerSettings.meta b/Assets/00.StaryEvo/Runtime/PlayerSettings.meta new file mode 100644 index 0000000..4025997 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/PlayerSettings.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 74d74706ae6d4fada1c6284ad3d3fe71 +timeCreated: 1739526557 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/PlayerSettings/DomainConfig.cs b/Assets/00.StaryEvo/Runtime/PlayerSettings/DomainConfig.cs new file mode 100644 index 0000000..8eb071b --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/PlayerSettings/DomainConfig.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using UnityEngine.Serialization; + +namespace Stary.Evo +{ + [CreateAssetMenu(fileName = "DomainConfig", menuName = "Evo/Create DomainConfig")] + public class DomainConfig : ScriptableObject + { + /// + /// 域id + /// + public string domain; + /// + /// 入口预制体 + /// + public string mainPrefab; + /// + /// 入口命名空间 + /// + public string @namespace; + /// + /// 入口类 + /// + public string className; + + } + + +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/PlayerSettings/DomainConfig.cs.meta b/Assets/00.StaryEvo/Runtime/PlayerSettings/DomainConfig.cs.meta new file mode 100644 index 0000000..9448a62 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/PlayerSettings/DomainConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 03dc1bf5b95446838cce6d0fefed81fe +timeCreated: 1739527373 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/PlayerSettings/HotfixMainResDomain.cs b/Assets/00.StaryEvo/Runtime/PlayerSettings/HotfixMainResDomain.cs new file mode 100644 index 0000000..9bda2f4 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/PlayerSettings/HotfixMainResDomain.cs @@ -0,0 +1,24 @@ +using System; +using UnityEngine; + +namespace Stary.Evo +{ + + + [CreateAssetMenu(fileName = "HotfixMainResDomain", menuName = "Evo/Create HotfixMainResDomain")] + public class HotfixMainResDomain : ScriptableObject + { + public HotfixMainResDomainEntity hotfixMainResDomainEntity; + } + + [Serializable] + public class HotfixMainResDomainEntity + { + public string domain; + public string ipconfig="http://192.168.31.100:5005/HotRefresh"; + public string pathconfig; + public string packageVersion; + public string username="UnityHot"; + public string password="Unity1234"; + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/PlayerSettings/HotfixMainResDomain.cs.meta b/Assets/00.StaryEvo/Runtime/PlayerSettings/HotfixMainResDomain.cs.meta new file mode 100644 index 0000000..2d15161 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/PlayerSettings/HotfixMainResDomain.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1a78aa2541a743f89b2646efe4073f01 +timeCreated: 1741332398 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/ResLoad.meta b/Assets/00.StaryEvo/Runtime/ResLoad.meta new file mode 100644 index 0000000..a9d99b8 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/ResLoad.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4596f376175f453ebfb7d31c31b3e9bc +timeCreated: 1739759528 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/ResLoad/AddressableLoad.cs b/Assets/00.StaryEvo/Runtime/ResLoad/AddressableLoad.cs new file mode 100644 index 0000000..be28883 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/ResLoad/AddressableLoad.cs @@ -0,0 +1,203 @@ +// using System; +// using System.Collections.Generic; +// using System.Linq; +// using System.Threading.Tasks; +// using UnityEngine; +// using UnityEngine.AddressableAssets; +// using UnityEngine.ResourceManagement.AsyncOperations; +// using UnityEngine.ResourceManagement.ResourceProviders; +// using UnityEngine.SceneManagement; +// using Stary.Evo; +// +// public class AddressableLoad : Singleton +// { +// private Dictionary nameCaches = new Dictionary(); +// private AsyncOperationHandle ScenesHandle; //当前场景的Addressable Handle +// +// +// /// +// ///异步读取指定的Addressable类型的数据 +// /// +// /// +// /// 执行成功的回调 +// /// 执行失败的回调 +// /// 路径 +// public async Task LoadAssetASync(string addressName) where T : UnityEngine.Object +// { +// try +// { +// if (nameCaches.TryGetValue(addressName, out var existingHandle)) +// { +// await existingHandle.Task; +// if (existingHandle.Status == AsyncOperationStatus.Succeeded) +// { +// var result = (T)existingHandle.Result; +// return result; +// } +// else +// { +// nameCaches.Remove(addressName); +// } +// } +// +// var handle = Addressables.LoadAssetAsync(addressName); +// nameCaches.Add(addressName, handle); +// await handle.Task; +// return handle.Result; +// } +// catch (Exception e) +// { +// Debug.LogError($"加载资源失败: 【{addressName}】\n{e.Message}"); +// return null; +// } +// } +// +// /// +// /// 同步读取指定的Addressable类型的数据 +// /// +// /// +// /// 执行成功的回调 +// /// 执行失败的回调 +// /// 路径 +// public void LoadAssetSync(string addressName, Action onComplete, Action onFailed) where T : UnityEngine.Object +// { +// if (nameCaches.ContainsKey(addressName)) +// { +// var handle = this.nameCaches[addressName]; +// if (handle.IsDone) +// { +// if (onComplete != null) +// { +// onComplete(nameCaches[addressName].Result as T); +// } +// } +// else +// { +// HandleAddCompleted(addressName, handle, onComplete, onFailed); +// } +// } +// else +// { +// var handle = Addressables.LoadAssetAsync(addressName); +// HandleAddCompleted(addressName, handle, onComplete, onFailed); +// nameCaches.Add(addressName, handle); +// } +// } +// +// /// +// /// 同步读取指定的Addressable类型的场景数据 +// /// +// public async Task LoadSceneAsync(string sceneName, LoadSceneMode mode, Action completeCallBack = null, +// bool isActiveOnLoaded = true, int priority = 100) +// { +// var handle = Addressables.LoadSceneAsync(sceneName, mode, isActiveOnLoaded, priority); +// +// var res = await handle.Task; +// +// completeCallBack?.Invoke(); +// +// return res; +// } +// +// /// +// /// 读取指定的Addressable类型的名字或标签数据的集合 +// /// +// /// 名字 +// /// 单个执行成功的回调 +// /// 全部执行成功的回调 +// /// 执行失败的回调 +// /// +// public void LoadTagAsset(string addressTag, Action onComplete, Action allOnComplete, +// Action onFailed = null) where T : UnityEngine.Object +// { +// if (nameCaches.ContainsKey(addressTag)) +// { +// var handle = this.nameCaches[addressTag]; +// if (handle.IsDone) +// { +// if (onComplete != null) +// { +// onComplete(nameCaches[addressTag].Result as T); +// } +// } +// else +// { +// HandleAddCompleted(addressTag, handle, allOnComplete, onFailed); +// } +// } +// else +// { +// var handle = Addressables.LoadAssetsAsync(addressTag, onComplete); +// AddTagCompleted(addressTag, handle, allOnComplete, onFailed); +// nameCaches.Add(addressTag, handle); +// } +// } +// +// private void AddTagCompleted(string addressTag, AsyncOperationHandle handle, Action allOnComplete, +// Action onFailed = null) where T : UnityEngine.Object +// { +// handle.Completed += (result) => +// { +// if (result.Status == AsyncOperationStatus.Succeeded) +// { +// var obj = result.Result as T; +// if (allOnComplete != null) +// { +// allOnComplete(obj); +// } +// } +// else +// { +// if (onFailed != null) +// { +// onFailed(); +// } +// +// Debug.LogErrorFormat("读取地址为-【{0}】-的ab包资源失败!", addressTag); +// } +// }; +// } +// +// private void HandleAddCompleted(string addressName, AsyncOperationHandle handle, Action onComplete, +// Action onFailed = null) where T : UnityEngine.Object +// { +// handle.Completed += (result) => +// { +// if (result.Status == AsyncOperationStatus.Succeeded) +// { +// var obj = result.Result as T; +// if (onComplete != null) +// { +// onComplete(obj); +// } +// } +// else +// { +// if (onFailed != null) +// { +// onFailed(); +// } +// +// Debug.LogErrorFormat("读取地址为-【{0}】-的ab包资源失败!", addressName); +// } +// }; +// } +// +// private void LoadRelease(string name) +// { +// if (nameCaches.ContainsKey(name)) +// { +// Addressables.Release(nameCaches[name]); +// nameCaches.Remove(name); +// } +// } +// +// private void OnDestroy() +// { +// for (int i = 0; i < nameCaches.Count; i++) +// { +// KeyValuePair kv = nameCaches.ElementAt(i); +// LoadRelease(kv.Key); +// } +// } +// } \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/ResLoad/AddressableLoad.cs.meta b/Assets/00.StaryEvo/Runtime/ResLoad/AddressableLoad.cs.meta new file mode 100644 index 0000000..0f26e4a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/ResLoad/AddressableLoad.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f2a6c483194d4c64da7c4c43bb892873 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Rule.meta b/Assets/00.StaryEvo/Runtime/Rule.meta new file mode 100644 index 0000000..32291f6 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7923f15e799e4b51a9c5791d805c04cc +timeCreated: 1625107159 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/IBelongToArchitecture.cs b/Assets/00.StaryEvo/Runtime/Rule/IBelongToArchitecture.cs new file mode 100644 index 0000000..2a865ba --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/IBelongToArchitecture.cs @@ -0,0 +1,7 @@ +namespace Stary.Evo +{ + public interface IBelongToArchitecture + { + IArchitecture GetArchitecture(); + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/IBelongToArchitecture.cs.meta b/Assets/00.StaryEvo/Runtime/Rule/IBelongToArchitecture.cs.meta new file mode 100644 index 0000000..6d04ad5 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/IBelongToArchitecture.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 29267e7525d5442b8656b4c7e32d46db +timeCreated: 1624936941 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanGetModel.cs b/Assets/00.StaryEvo/Runtime/Rule/ICanGetModel.cs new file mode 100644 index 0000000..d04fc99 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanGetModel.cs @@ -0,0 +1,14 @@ +namespace Stary.Evo +{ + public interface ICanGetData: IBelongToArchitecture + { + + } + public static class CanGetDataExtension + { + public static T GetData(this ICanGetData self) where T : class, IData + { + return self.GetArchitecture().GetData(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanGetModel.cs.meta b/Assets/00.StaryEvo/Runtime/Rule/ICanGetModel.cs.meta new file mode 100644 index 0000000..793205f --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanGetModel.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1a8db07c697b49dfb467b3adb719f864 +timeCreated: 1625107407 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanGetSystem.cs b/Assets/00.StaryEvo/Runtime/Rule/ICanGetSystem.cs new file mode 100644 index 0000000..1d82f28 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanGetSystem.cs @@ -0,0 +1,16 @@ +using UnityEngine; + +namespace Stary.Evo +{ + public interface ICanGetSystem: IBelongToArchitecture + { + + } + public static class CanGetSystemExtension + { + public static T GetSystem(this ICanGetSystem self) where T : class, ISystem + { + return self.GetArchitecture().GetSystem(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanGetSystem.cs.meta b/Assets/00.StaryEvo/Runtime/Rule/ICanGetSystem.cs.meta new file mode 100644 index 0000000..5e8b397 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanGetSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 98fef7169f2540d883fef0f3b57e7597 +timeCreated: 1625109288 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanGetUtility.cs b/Assets/00.StaryEvo/Runtime/Rule/ICanGetUtility.cs new file mode 100644 index 0000000..b89a8b7 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanGetUtility.cs @@ -0,0 +1,14 @@ +namespace Stary.Evo +{ + public interface ICanGetUtility: IBelongToArchitecture + { + + } + public static class CanGetUtilityExtension + { + public static T GetUtility(this ICanGetUtility self) where T : class, IUtility + { + return self.GetArchitecture().GetUtility(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanGetUtility.cs.meta b/Assets/00.StaryEvo/Runtime/Rule/ICanGetUtility.cs.meta new file mode 100644 index 0000000..90d77dc --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanGetUtility.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ac4506dbc33147408207becd4084b9e4 +timeCreated: 1625107159 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanRegisterEvent.cs b/Assets/00.StaryEvo/Runtime/Rule/ICanRegisterEvent.cs new file mode 100644 index 0000000..da1ce6f --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanRegisterEvent.cs @@ -0,0 +1,67 @@ +using System; + +namespace Stary.Evo +{ + public interface ICanRegisterEvent:IBelongToArchitecture + { + + } + public static class CanRegisterEventExtension + { + + public static IUnRegister RegisterEvent(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible + { + + return self.GetArchitecture().RegisterEvent(key,onEvent); + } + public static IUnRegister RegisterEvent(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible + { + + return self.GetArchitecture().RegisterEvent(key,onEvent); + } + public static IUnRegister RegisterEvent(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible + { + + return self.GetArchitecture().RegisterEvent(key,onEvent); + } + + public static IUnRegister RegisterEvent(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible + { + + return self.GetArchitecture().RegisterEvent(key,onEvent); + } + public static IUnRegister RegisterEvent(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible + { + + return self.GetArchitecture().RegisterEvent(key,onEvent); + } + + + public static void UnRegisterEvent(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible + { + + self.GetArchitecture().UnRegisterEvent(key,onEvent); + } + public static void UnRegisterEvent(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible + { + + self.GetArchitecture().UnRegisterEvent(key,onEvent); + } + public static void UnRegisterEvent(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible + { + + self.GetArchitecture().UnRegisterEvent(key,onEvent); + } + + public static void UnRegisterEvent(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible + { + + self.GetArchitecture().UnRegisterEvent(key,onEvent); + } + public static void UnRegisterEvent(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible + { + + self.GetArchitecture().UnRegisterEvent(key,onEvent); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanRegisterEvent.cs.meta b/Assets/00.StaryEvo/Runtime/Rule/ICanRegisterEvent.cs.meta new file mode 100644 index 0000000..d144372 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanRegisterEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3afca6ed153c4f35bfbe630644c9bdab +timeCreated: 1625124335 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanSendCommand.cs b/Assets/00.StaryEvo/Runtime/Rule/ICanSendCommand.cs new file mode 100644 index 0000000..d73f410 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanSendCommand.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +namespace Stary.Evo +{ + public interface ICanSendCommand: IBelongToArchitecture + { + + } + public static class CanSendCommandExtension + { + public static void SendCommand(this ICanSendCommand self) where T :class, ICommand, new() + { + self.GetArchitecture().SendCommand(); + } + + public static void SendCommand(this ICanSendCommand self,T command) where T : ICommand + { + self.GetArchitecture().SendCommand(command); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanSendCommand.cs.meta b/Assets/00.StaryEvo/Runtime/Rule/ICanSendCommand.cs.meta new file mode 100644 index 0000000..8b3d7a0 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanSendCommand.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7d4d286b9072404a9d1eed529797d37b +timeCreated: 1625109500 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanSendEvent.cs b/Assets/00.StaryEvo/Runtime/Rule/ICanSendEvent.cs new file mode 100644 index 0000000..54a78a8 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanSendEvent.cs @@ -0,0 +1,39 @@ +using System; + +namespace Stary.Evo +{ + public interface ICanSendEvent:IBelongToArchitecture + { + + } + public static class CanSendEventExtension + { + public static void SendEvent(this ICanSendEvent self,T key) where T : IConvertible + { + + self.GetArchitecture().SendEvent(key); + } + public static void SendEvent(this ICanSendEvent self,T key,T1 value) where T : IConvertible + { + + self.GetArchitecture().SendEvent(key,value); + } + public static void SendEvent(this ICanSendEvent self,T key,T1 value1,T2 value2) where T : IConvertible + { + + self.GetArchitecture().SendEvent(key,value1,value2); + } + + public static void SendEvent(this ICanSendEvent self,T key,T1 value1,T2 value2,T3 value3) where T : IConvertible + { + + self.GetArchitecture().SendEvent(key,value1,value2, value3); + } + public static void SendEvent(this ICanSendEvent self,T key,object[] values) where T : IConvertible + { + + self.GetArchitecture().SendEvent(key,values); + } + } + +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanSendEvent.cs.meta b/Assets/00.StaryEvo/Runtime/Rule/ICanSendEvent.cs.meta new file mode 100644 index 0000000..f469178 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanSendEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0d5b249bb8554780a126cbe5d7189165 +timeCreated: 1625124323 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanSendQuery.cs b/Assets/00.StaryEvo/Runtime/Rule/ICanSendQuery.cs new file mode 100644 index 0000000..e7d5d9f --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanSendQuery.cs @@ -0,0 +1,16 @@ +namespace Stary.Evo +{ + public interface ICanSendQuery : IBelongToArchitecture + { + + } + + public static class CanSendQueryExtension + { + public static T SendQuery(this ICanSendQuery self, IQuery query) + { + return self.GetArchitecture().SendQuery(query); + } + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanSendQuery.cs.meta b/Assets/00.StaryEvo/Runtime/Rule/ICanSendQuery.cs.meta new file mode 100644 index 0000000..015a0a2 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanSendQuery.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 435afd9942e6ed5409bb08b235b4dc03 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanSetArchitecture.cs b/Assets/00.StaryEvo/Runtime/Rule/ICanSetArchitecture.cs new file mode 100644 index 0000000..81181ac --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanSetArchitecture.cs @@ -0,0 +1,7 @@ +namespace Stary.Evo +{ + public interface ICanSetArchitecture + { + void SetArchitecture(IArchitecture architecture); + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Rule/ICanSetArchitecture.cs.meta b/Assets/00.StaryEvo/Runtime/Rule/ICanSetArchitecture.cs.meta new file mode 100644 index 0000000..917b5b6 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Rule/ICanSetArchitecture.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1d30432f9f834aab87ee534ecc6e3fa4 +timeCreated: 1625018433 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Singleton.cs b/Assets/00.StaryEvo/Runtime/Singleton.cs new file mode 100644 index 0000000..a10eb05 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Singleton.cs @@ -0,0 +1,85 @@ +using System; +using System.Reflection; +using UnityEngine; + +namespace Stary.Evo +{ + public class Singleton where T : class + { + public static T Instance + { + get + { + if (mInstance == null) + { + // 通过反射获取构造 + var ctors = typeof(T).GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic); + // 获取无参非 public 的构造 + var ctor = Array.Find(ctors, c => c.GetParameters().Length == 0); + + if (ctor == null) + { + throw new Exception("Non-Public Constructor() not found in " + typeof(T)); + } + + mInstance = ctor.Invoke(null) as T; + } + + return mInstance; + } + } + + private static T mInstance; + } + /// + /// 单例基类 + /// + /// + public class MonoSingleton: MonoBehaviour where T: MonoBehaviour + { + private static T mInstance; + + public static T Instance + { + get { + if (mInstance == null) + { + T t = GameObject.FindObjectOfType(); + if (t) + { + mInstance = t; + } + else + { + GameObject go = new GameObject(typeof(T).Name); + mInstance = go.AddComponent(); + } + + return mInstance; + } + + return mInstance; + } + } + + + } + + + public class DoNotDestroy : MonoBehaviour + { + public static DoNotDestroy Instance; + + private void Awake() + { + if (Instance != null) + { + Destroy(gameObject); + return; + } + + Instance = this; + DontDestroyOnLoad(gameObject); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Singleton.cs.meta b/Assets/00.StaryEvo/Runtime/Singleton.cs.meta new file mode 100644 index 0000000..3e94bc9 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Singleton.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 87700e1e40089e843aa7c13dd28b0214 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool.meta b/Assets/00.StaryEvo/Runtime/Tool.meta new file mode 100644 index 0000000..3f51fad --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0d11726814f336347b8828f1029dfad5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit.meta new file mode 100644 index 0000000..c06c58b --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0e595bb208aff00418dc5a646f5e5bae +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component.meta new file mode 100644 index 0000000..f579c21 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9bc0ac15207240f695c4ba3f35865240 +timeCreated: 1710224493 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs new file mode 100644 index 0000000..1ffab10 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs @@ -0,0 +1,24 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License + * + * https://qStary.Evo.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnDeselectUnityEvent: MonoBehaviour, IDeselectHandler + { + public UnityEvent OnDeselectEvent; + + public void OnDeselect(BaseEventData eventData) + { + OnDeselectEvent?.Invoke(eventData); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs.meta new file mode 100644 index 0000000..b40cf96 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5edff8e50ab84809afe6b9894eef68ab +timeCreated: 1710224509 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs new file mode 100644 index 0000000..bc6b4ea --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs @@ -0,0 +1,24 @@ +/**************************************************************************** + * Copyright (c) 2016 - 2024 liangxiegame UNDER MIT License + * + * https://qStary.Evo.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnSelectUnityEvent : MonoBehaviour, ISelectHandler + { + public UnityEvent OnSelectEvent; + + public void OnSelect(BaseEventData eventData) + { + OnSelectEvent?.Invoke(eventData); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs.meta new file mode 100644 index 0000000..4257f79 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b73c32a61ddd4b469f20ad0f287b2a9e +timeCreated: 1710224585 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem.meta new file mode 100644 index 0000000..e3dde46 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9a4d4fb049e264d7585467dc91a94f28 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs new file mode 100644 index 0000000..9432d81 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; + +namespace Stary.Evo +{ + public interface IEasyEvent + { + } + + public class EasyEvent : IEasyEvent + { + private Action mOnEvent = () => { }; + + public IUnRegister Register(Action onEvent) + { + mOnEvent += onEvent; + return new CustomUnRegister(() => { UnRegister(onEvent); }); + } + + public void UnRegister(Action onEvent) + { + mOnEvent -= onEvent; + } + + public void Trigger() + { + mOnEvent?.Invoke(); + } + } + + public class EasyEvent : IEasyEvent + { + private Action mOnEvent = e => { }; + + public IUnRegister Register(Action onEvent) + { + mOnEvent += onEvent; + return new CustomUnRegister(() => { UnRegister(onEvent); }); + } + + public void UnRegister(Action onEvent) + { + mOnEvent -= onEvent; + } + + public void Trigger(T t) + { + mOnEvent?.Invoke(t); + } + } + + public class EasyEvent : IEasyEvent + { + private Action mOnEvent = (t, k) => { }; + + public IUnRegister Register(Action onEvent) + { + mOnEvent += onEvent; + return new CustomUnRegister(() => { UnRegister(onEvent); }); + } + + public void UnRegister(Action onEvent) + { + mOnEvent -= onEvent; + } + + public void Trigger(T t, K k) + { + mOnEvent?.Invoke(t, k); + } + } + + public class EasyEvent : IEasyEvent + { + private Action mOnEvent = (t, k, s) => { }; + + public IUnRegister Register(Action onEvent) + { + mOnEvent += onEvent; + return new CustomUnRegister(() => { UnRegister(onEvent); }); + } + + public void UnRegister(Action onEvent) + { + mOnEvent -= onEvent; + } + + public void Trigger(T t, K k, S s) + { + mOnEvent?.Invoke(t, k, s); + } + } + + public class EasyEventSystems + { + private static EasyEventSystems _mGlobalEventSystems = new EasyEventSystems(); + + public static T Get() where T : IEasyEvent + { + return _mGlobalEventSystems.GetEvent(); + } + + + public static void Register() where T : IEasyEvent, new() + { + _mGlobalEventSystems.AddEvent(); + } + + private Dictionary mTypeEvents = new Dictionary(); + + public void AddEvent() where T : IEasyEvent, new() + { + mTypeEvents.Add(typeof(T), new T()); + } + + public T GetEvent() where T : IEasyEvent + { + IEasyEvent e; + + if (mTypeEvents.TryGetValue(typeof(T), out e)) + { + return (T) e; + } + + return default; + } + + public T GetOrAddEvent() where T : IEasyEvent, new() + { + var eType = typeof(T); + if (mTypeEvents.TryGetValue(eType, out var e)) + { + return (T) e; + } + + var t = new T(); + mTypeEvents.Add(eType, t); + return t; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs.meta new file mode 100644 index 0000000..f22960a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e33d19dd11204fbe87eb16c6bc9b2621 +timeCreated: 1658655004 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs new file mode 100644 index 0000000..66482f1 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs @@ -0,0 +1,199 @@ +using System; +using System.Collections.Generic; +namespace Stary.Evo +{ + + + public class EnumEventSystem + { + public static readonly EnumEventSystem Global = new EnumEventSystem(); + + private readonly Dictionary mEvents = new Dictionary(50); + + public EnumEventSystem(){} + + #region 功能函数 + + public IUnRegister Register(T key, Action onEvent)where T : IConvertible + { + var kv = key.ToInt32(null); + if (mEvents.TryGetValue(kv, out var e)) + { + var easyEvent = e.As(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(kv,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(T key, Action onEvent)where T : IConvertible + { + var kv = key.ToInt32(null); + if (mEvents.TryGetValue(kv, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(kv,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(T key, Action onEvent)where T : IConvertible + { + var kv = key.ToInt32(null); + if (mEvents.TryGetValue(kv, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(kv,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(T key, Action onEvent) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(kv, easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(T key, Action onEvent) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(kv, easyEvent); + return easyEvent.Register(onEvent); + } + } + public void UnRegister(T key, Action onEvent) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As()?.UnRegister(onEvent); + } + } + public void UnRegister(T key, Action onEvent) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>()?.UnRegister(onEvent); + } + } + public void UnRegister(T key, Action onEvent) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>()?.UnRegister(onEvent); + } + } + public void UnRegister(T key, Action onEvent) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>()?.UnRegister(onEvent); + } + } + public void UnRegister(T key, Action onEvent) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>()?.UnRegister(onEvent); + } + } + + + + public void UnRegisterAll() + { + mEvents.Clear(); + } + public void Send(T key) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As().Trigger(); + } + } + public void Send(T key, T1 t1) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>().Trigger(t1); + } + } + public void Send(T key, T1 t1,T2 t2) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>().Trigger(t1,t2); + } + } + public void Send(T key, T1 t1,T2 t2 ,T3 t3) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>().Trigger(t1,t2,t3); + } + } + public void Send(T key, params object[] args) where T : IConvertible + { + var kv = key.ToInt32(null); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>().Trigger(kv,args); + } + } + + #endregion + + public void Dispose() + { + mEvents.Clear(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs.meta new file mode 100644 index 0000000..bbcbea0 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0f9c387bd15b741b2a7451be23c992ae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs new file mode 100644 index 0000000..cc6eecc --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ + + public class TypeEventSystem + { + private readonly EasyEventSystems _mEventSystems = new EasyEventSystems(); + + + public static readonly TypeEventSystem Global = new TypeEventSystem(); + + public void Send() where T : new() + { + _mEventSystems.GetEvent>()?.Trigger(new T()); + } + + public void Send(T e) + { + _mEventSystems.GetEvent>()?.Trigger(e); + } + + public IUnRegister Register(Action onEvent) + { + var e = _mEventSystems.GetOrAddEvent>(); + return e.Register(onEvent); + } + + public void UnRegister(Action onEvent) + { + var e = _mEventSystems.GetEvent>(); + if (e != null) + { + e.UnRegister(onEvent); + } + } + } + + public interface IOnEvent + { + void OnEvent(T e); + } + + public static class OnGlobalEventExtension + { + public static IUnRegister RegisterEvent(this IOnEvent self) where T : struct + { + return TypeEventSystem.Global.Register(self.OnEvent); + } + + public static void UnRegisterEvent(this IOnEvent self) where T : struct + { + TypeEventSystem.Global.UnRegister(self.OnEvent); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs.meta new file mode 100644 index 0000000..e407536 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 228453eae0804759b0fd585f7169789c +timeCreated: 1625121334 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs new file mode 100644 index 0000000..bbffce3 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; + +namespace Stary.Evo +{ + [Obsolete("推荐使用 EnumEventSystem",false)] + public class StringEventSystem + { + public static readonly StringEventSystem Global = new StringEventSystem(); + + private Dictionary mEvents = new Dictionary(); + + public IUnRegister Register(string key, Action onEvent) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(key,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(string key, Action onEvent) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(key,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(string key, Action onEvent) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(key,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(string key, Action onEvent) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(key,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(string key, Action onEvent) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As >(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent (); + mEvents.Add(key,easyEvent); + return easyEvent.Register(onEvent); + } + } + public void UnRegister(string key, Action onEvent) + { + + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As(); + easyEvent?.UnRegister(onEvent); + } + } + public void UnRegister(string key, Action onEvent) + { + + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.UnRegister(onEvent); + } + } + public void UnRegister(string key, Action onEvent) + { + + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.UnRegister(onEvent); + } + } + public void UnRegister(string key, Action onEvent) + { + + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.UnRegister(onEvent); + } + } + public void UnRegister(string key, Action onEvent) + { + + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.UnRegister(onEvent); + } + } + public void Send(string key) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As(); + easyEvent?.Trigger(); + } + } + public void Send(string key, T data) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.Trigger(data); + } + } + public void Send(string key, T1 data1, T2 data2) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.Trigger(data1,data2); + } + } + public void Send(string key, T1 data1, T2 data2, T3 data3) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.Trigger(data1,data2,data3); + } + } + public void Send(string key, object[] data) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.Trigger(data); + } + } + public void Dispose() + { + mEvents.Clear(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs.meta new file mode 100644 index 0000000..99e3863 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8502c9eab24d488c950d3eacbfc584b1 +timeCreated: 1649307359 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger.meta new file mode 100644 index 0000000..a80723d --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 64db9a81348a42b8947c551059b8606e +timeCreated: 1658665668 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono.meta new file mode 100644 index 0000000..abc696a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0989f6c357dd66c4e99d135d7f605367 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs new file mode 100644 index 0000000..d5f8e27 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs @@ -0,0 +1,32 @@ +using System; +using UnityEngine; +using Stary.Evo; + +namespace Stary.Evo +{ + public class OnBecameInvisibleEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnBecameInvisibleEvent = new EasyEvent(); + + private void OnBecameInvisible() + { + OnBecameInvisibleEvent.Trigger(); + } + } + + public static class OnBecameInvisibleEventTriggerExtension + { + public static IUnRegister OnBecameInvisibleEvent(this T self, Action onBecameInvisible) + where T : Component + { + return self.GetOrAddComponent().OnBecameInvisibleEvent + .Register(onBecameInvisible); + } + + public static IUnRegister OnBecameInvisibleEvent(this GameObject self, Action onBecameInvisible) + { + return self.GetOrAddComponent().OnBecameInvisibleEvent + .Register(onBecameInvisible); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs.meta new file mode 100644 index 0000000..68131c4 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 82df3683f4d240e48bbb63f36a0eaf10 +timeCreated: 1693460492 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs new file mode 100644 index 0000000..b504a6a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs @@ -0,0 +1,31 @@ +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnBecameVisibleEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnBecameVisibleEvent = new EasyEvent(); + + private void OnBecameVisible() + { + OnBecameVisibleEvent.Trigger(); + } + } + + public static class OnBecameVisibleEventTriggerExtension + { + public static IUnRegister OnBecameVisibleEvent(this T self, Action onBecameVisible) + where T : Component + { + return self.GetOrAddComponent().OnBecameVisibleEvent + .Register(onBecameVisible); + } + + public static IUnRegister OnBecameVisibleEvent(this GameObject self, Action onBecameVisible) + { + return self.GetOrAddComponent().OnBecameVisibleEvent + .Register(onBecameVisible); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs.meta new file mode 100644 index 0000000..36adb1a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d66e5459cb1f420c81fbe74291ee9f24 +timeCreated: 1693460551 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics.meta new file mode 100644 index 0000000..de9d876 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8977daa3a9c64e25a157230677908ea9 +timeCreated: 1684917953 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs new file mode 100644 index 0000000..bb4ae35 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionEnter2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionEnter2DEvent = new EasyEvent(); + private void OnCollisionEnter2D(Collision2D col) + { + OnCollisionEnter2DEvent.Trigger(col); + } + } + + public static class OnCollisionEnter2DEventTriggerExtension + { + public static IUnRegister OnCollisionEnter2DEvent(this T self, Action onCollisionEnter2D) + where T : Component + { + return self.GetOrAddComponent().OnCollisionEnter2DEvent + .Register(onCollisionEnter2D); + } + + public static IUnRegister OnCollisionEnter2DEvent(this GameObject self, Action onCollisionEnter2D) + { + return self.GetOrAddComponent().OnCollisionEnter2DEvent + .Register(onCollisionEnter2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs.meta new file mode 100644 index 0000000..0483a75 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: edcab69f84914ba59bef80b1bedf8c47 +timeCreated: 1671428212 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs new file mode 100644 index 0000000..d39b34b --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionEnterEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionEnterEvent = new EasyEvent(); + private void OnCollisionEnter(Collision col) + { + OnCollisionEnterEvent.Trigger(col); + } + } + + public static class OnCollisionEnterEventTriggerExtension + { + public static IUnRegister OnCollisionEnterEvent(this T self, Action onCollisionEnter) + where T : Component + { + return self.GetOrAddComponent().OnCollisionEnterEvent + .Register(onCollisionEnter); + } + + public static IUnRegister OnCollisionEnterEvent(this GameObject self, Action onCollisionEnter) + { + return self.GetOrAddComponent().OnCollisionEnterEvent + .Register(onCollisionEnter); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs.meta new file mode 100644 index 0000000..127115e --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 82d00be1a2cb39144b87de1036c4e048 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs new file mode 100644 index 0000000..123b63b --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionExit2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionExit2DEvent = new EasyEvent(); + private void OnCollisionExit2D(Collision2D col) + { + OnCollisionExit2DEvent.Trigger(col); + } + } + + public static class OnCollisionExit2DEventTriggerExtension + { + public static IUnRegister OnCollisionExit2DEvent(this T self, Action onCollisionExit2D) + where T : Component + { + return self.GetOrAddComponent().OnCollisionExit2DEvent + .Register(onCollisionExit2D); + } + + public static IUnRegister OnCollisionExit2DEvent(this GameObject self, Action onCollisionExit2D) + { + return self.GetOrAddComponent().OnCollisionExit2DEvent + .Register(onCollisionExit2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs.meta new file mode 100644 index 0000000..3b889e3 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8928ffac271742d0a2b772430abd4dd3 +timeCreated: 1671428509 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs new file mode 100644 index 0000000..b1bf309 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionExitEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionExitEvent = new EasyEvent(); + private void OnCollisionExit(Collision col) + { + OnCollisionExitEvent.Trigger(col); + } + } + + public static class OnCollisionExitEventTriggerExtension + { + public static IUnRegister OnCollisionExitEvent(this T self, Action onCollisionExit) + where T : Component + { + return self.GetOrAddComponent().OnCollisionExitEvent + .Register(onCollisionExit); + } + + public static IUnRegister OnCollisionExitEvent(this GameObject self, Action onCollisionExit) + { + return self.GetOrAddComponent().OnCollisionExitEvent + .Register(onCollisionExit); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs.meta new file mode 100644 index 0000000..93d17ed --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 190fce482f5f92842a9fb5710d7973fb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs new file mode 100644 index 0000000..8a0981f --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionStay2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionStay2DEvent = new EasyEvent(); + private void OnCollisionStay2D(Collision2D col) + { + OnCollisionStay2DEvent.Trigger(col); + } + } + + public static class OnCollisionStay2DEventTriggerExtension + { + public static IUnRegister OnCollisionStay2DEvent(this T self, Action onCollisionStay2D) + where T : Component + { + return self.GetOrAddComponent().OnCollisionStay2DEvent + .Register(onCollisionStay2D); + } + + public static IUnRegister OnCollisionStay2DEvent(this GameObject self, Action onCollisionStay2D) + { + return self.GetOrAddComponent().OnCollisionStay2DEvent + .Register(onCollisionStay2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs.meta new file mode 100644 index 0000000..f074bd5 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 43a766fa65dd42f5ae6cd849163e6a82 +timeCreated: 1671428443 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs new file mode 100644 index 0000000..d8f8256 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionStayEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionStayEvent = new EasyEvent(); + private void OnCollisionStay(Collision col) + { + OnCollisionStayEvent.Trigger(col); + } + } + + public static class OnCollisionStayEventTriggerExtension + { + public static IUnRegister OnCollisionStayEvent(this T self, Action onCollisionStay) + where T : Component + { + return self.GetOrAddComponent().OnCollisionStayEvent + .Register(onCollisionStay); + } + + public static IUnRegister OnCollisionStayEvent(this GameObject self, Action onCollisionStay) + { + return self.GetOrAddComponent().OnCollisionStayEvent + .Register(onCollisionStay); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs.meta new file mode 100644 index 0000000..43d3e42 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 272e5a88646c2eb41b8ee03a717c5adf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs new file mode 100644 index 0000000..3d88951 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerEnter2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerEnter2DEvent = new EasyEvent(); + private void OnTriggerEnter2D(Collider2D collider) + { + OnTriggerEnter2DEvent.Trigger(collider); + } + } + + public static class OnTriggerEnter2DEventTriggerExtension + { + public static IUnRegister OnTriggerEnter2DEvent(this T self, Action onTriggerEnter2D) + where T : Component + { + return self.GetOrAddComponent().OnTriggerEnter2DEvent + .Register(onTriggerEnter2D); + } + + public static IUnRegister OnTriggerEnter2DEvent(this GameObject self, Action onTriggerEnter2D) + { + return self.GetOrAddComponent().OnTriggerEnter2DEvent + .Register(onTriggerEnter2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs.meta new file mode 100644 index 0000000..00665ee --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 476bf1e8119b443fac10813bb49f3598 +timeCreated: 1671428580 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs new file mode 100644 index 0000000..0d92edb --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs @@ -0,0 +1,30 @@ +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerEnterEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerEnterEvent = new EasyEvent(); + private void OnTriggerEnter(Collider collider) + { + OnTriggerEnterEvent.Trigger(collider); + } + } + + public static class OnTriggerEnterEventTriggerExtension + { + public static IUnRegister OnTriggerEnterEvent(this T self, Action onTriggerEnter) + where T : Component + { + return self.GetOrAddComponent().OnTriggerEnterEvent + .Register(onTriggerEnter); + } + + public static IUnRegister OnTriggerEnterEvent(this GameObject self, Action onTriggerEnter) + { + return self.GetOrAddComponent().OnTriggerEnterEvent + .Register(onTriggerEnter); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs.meta new file mode 100644 index 0000000..264cb20 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bd1f6102e00b4c94c92918df44a8568e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs new file mode 100644 index 0000000..e47dbe0 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerExit2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerExit2DEvent = new EasyEvent(); + private void OnTriggerExit2D(Collider2D collider) + { + OnTriggerExit2DEvent.Trigger(collider); + } + } + + public static class OnTriggerExit2DEventTriggerExtension + { + public static IUnRegister OnTriggerExit2DEvent(this T self, Action onTriggerExit2D) + where T : Component + { + return self.GetOrAddComponent().OnTriggerExit2DEvent + .Register(onTriggerExit2D); + } + + public static IUnRegister OnTriggerExit2DEvent(this GameObject self, Action onTriggerExit2D) + { + return self.GetOrAddComponent().OnTriggerExit2DEvent + .Register(onTriggerExit2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs.meta new file mode 100644 index 0000000..c77fa0a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a85117eed9334b2d9bf7cf743b10d7ce +timeCreated: 1671428822 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs new file mode 100644 index 0000000..e4fa802 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerExitEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerExitEvent = new EasyEvent(); + private void OnTriggerExit(Collider collider) + { + OnTriggerExitEvent.Trigger(collider); + } + } + + public static class OnTriggerExitEventTriggerExtension + { + public static IUnRegister OnTriggerExitEvent(this T self, Action onTriggerExit) + where T : Component + { + return self.GetOrAddComponent().OnTriggerExitEvent + .Register(onTriggerExit); + } + + public static IUnRegister OnTriggerExitEvent(this GameObject self, Action onTriggerExit) + { + return self.GetOrAddComponent().OnTriggerExitEvent + .Register(onTriggerExit); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs.meta new file mode 100644 index 0000000..a4c93ff --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 225a25d5b53dfe14fb4193eeb6c96f1e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs new file mode 100644 index 0000000..06bb780 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerStay2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerStay2DEvent = new EasyEvent(); + private void OnTriggerStay2D(Collider2D collider) + { + OnTriggerStay2DEvent.Trigger(collider); + } + } + + public static class OnTriggerStay2DEventTriggerExtension + { + public static IUnRegister OnTriggerStay2DEvent(this T self, Action onTriggerStay2D) + where T : Component + { + return self.GetOrAddComponent().OnTriggerStay2DEvent + .Register(onTriggerStay2D); + } + + public static IUnRegister OnTriggerStay2DEvent(this GameObject self, Action onTriggerStay2D) + { + return self.GetOrAddComponent().OnTriggerStay2DEvent + .Register(onTriggerStay2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs.meta new file mode 100644 index 0000000..2e96fca --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 33cc7e2db07b4904b50f6b37f2d4abf1 +timeCreated: 1671428742 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs new file mode 100644 index 0000000..4fe1fd3 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerStayEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerStayEvent = new EasyEvent(); + private void OnTriggerStay(Collider collider) + { + OnTriggerStayEvent.Trigger(collider); + } + } + + public static class OnTriggerStayEventTriggerExtension + { + public static IUnRegister OnTriggerStayEvent(this T self, Action onTriggerStay) + where T : Component + { + return self.GetOrAddComponent().OnTriggerStayEvent + .Register(onTriggerStay); + } + + public static IUnRegister OnTriggerStayEvent(this GameObject self, Action onTriggerStay) + { + return self.GetOrAddComponent().OnTriggerStayEvent + .Register(onTriggerStay); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs.meta new file mode 100644 index 0000000..608e2f9 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41af1f7985cb62043bea03004f786319 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI.meta new file mode 100644 index 0000000..74cdf0c --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 01eca79e7ef44fd69a8b616f1de7f765 +timeCreated: 1684917968 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs new file mode 100644 index 0000000..4aca5e0 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnBeginDragEventTrigger: MonoBehaviour, IBeginDragHandler + { + public readonly EasyEvent OnBeginDragEvent = new EasyEvent(); + + public void OnBeginDrag(PointerEventData eventData) + { + OnBeginDragEvent.Trigger(eventData); + + } + } + + public static class OnBeginDragEventTriggerExtension + { + public static IUnRegister OnBeginDragEvent(this T self, Action onBeganDrag) + where T : Component + { + return self.GetOrAddComponent().OnBeginDragEvent.Register(onBeganDrag); + } + + public static IUnRegister OnBeginDragEvent(this GameObject self, Action onBeganDrag) + { + return self.GetOrAddComponent().OnBeginDragEvent.Register(onBeganDrag); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs.meta new file mode 100644 index 0000000..25f6437 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: acfd1b7010c94c9aa73d78a56664eee4 +timeCreated: 1684918507 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs new file mode 100644 index 0000000..be4b230 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnCancelEventTrigger: MonoBehaviour, ICancelHandler + { + public readonly EasyEvent OnCancelEvent = new EasyEvent(); + + public void OnCancel(BaseEventData eventData) + { + OnCancelEvent.Trigger(eventData); + + } + } + + public static class OnCancelEventTriggerExtension + { + public static IUnRegister OnCancelEvent(this T self, Action onCancel) + where T : Component + { + return self.GetOrAddComponent().OnCancelEvent.Register(onCancel); + } + + public static IUnRegister OnCancelEvent(this GameObject self, Action onCancel) + { + return self.GetOrAddComponent().OnCancelEvent.Register(onCancel); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs.meta new file mode 100644 index 0000000..1ebf61a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f539c36d39c14257b6ba9751d1594ef4 +timeCreated: 1684921869 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs new file mode 100644 index 0000000..1b5ff11 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnDeselectEventTrigger: MonoBehaviour, IDeselectHandler + { + public readonly EasyEvent OnDeselectEvent = new EasyEvent(); + + + public void OnDeselect(BaseEventData eventData) + { + OnDeselectEvent.Trigger(eventData); + } + } + + public static class OnDeselectEventTriggerExtension + { + public static IUnRegister OnDeselectEvent(this T self, Action onDeselect) + where T : Component + { + return self.GetOrAddComponent().OnDeselectEvent.Register(onDeselect); + } + + public static IUnRegister OnDeselectEvent(this GameObject self, Action onDeselect) + { + return self.GetOrAddComponent().OnDeselectEvent.Register(onDeselect); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs.meta new file mode 100644 index 0000000..674b3c8 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3e53e5c7e26d40dbad3843de24f8ffde +timeCreated: 1684921854 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs new file mode 100644 index 0000000..1f07708 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnDragEventTrigger: MonoBehaviour, IDragHandler + { + public readonly EasyEvent OnDragEvent = new EasyEvent(); + + public void OnDrag(PointerEventData eventData) + { + OnDragEvent.Trigger(eventData); + + } + } + + public static class OnDragEventTriggerExtension + { + public static IUnRegister OnDragEvent(this T self, Action onDrag) + where T : Component + { + return self.GetOrAddComponent().OnDragEvent.Register(onDrag); + } + + public static IUnRegister OnDragEvent(this GameObject self, Action onDrag) + { + return self.GetOrAddComponent().OnDragEvent.Register(onDrag); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs.meta new file mode 100644 index 0000000..66d4034 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cd60a9454b464db398516f09efee052d +timeCreated: 1684918694 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs new file mode 100644 index 0000000..9c3220d --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnDropEventTrigger: MonoBehaviour, IDropHandler + { + public readonly EasyEvent OnDropEvent = new EasyEvent(); + + public void OnDrop(PointerEventData eventData) + { + OnDropEvent.Trigger(eventData); + } + } + + public static class OnDropEventTriggerExtension + { + public static IUnRegister OnDropEvent(this T self, Action onDrop) + where T : Component + { + return self.GetOrAddComponent().OnDropEvent.Register(onDrop); + } + + public static IUnRegister OnDropEvent(this GameObject self, Action onDrop) + { + return self.GetOrAddComponent().OnDropEvent.Register(onDrop); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs.meta new file mode 100644 index 0000000..12cc11b --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 002c533d28c84da895167c036c559b98 +timeCreated: 1684921828 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs new file mode 100644 index 0000000..e60c0ed --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnEndDragEventTrigger: MonoBehaviour, IEndDragHandler + { + public readonly EasyEvent OnEndDragEvent = new EasyEvent(); + + public void OnEndDrag(PointerEventData eventData) + { + OnEndDragEvent.Trigger(eventData); + + } + } + + public static class OnEndDragEventTriggerExtension + { + public static IUnRegister OnEndDragEvent(this T self, Action onEndDrag) + where T : Component + { + return self.GetOrAddComponent().OnEndDragEvent.Register(onEndDrag); + } + + public static IUnRegister OnEndDragEvent(this GameObject self, Action onEndDrag) + { + return self.GetOrAddComponent().OnEndDragEvent.Register(onEndDrag); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs.meta new file mode 100644 index 0000000..ab62a64 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 054da3c9f71e4a48b48df7b881c318aa +timeCreated: 1684918794 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs new file mode 100644 index 0000000..07ca5ad --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnInitializePotentialDragEventTrigger: MonoBehaviour, IInitializePotentialDragHandler + { + public readonly EasyEvent OnInitializePotentialDragEvent = new EasyEvent(); + + + public void OnInitializePotentialDrag(PointerEventData eventData) + { + OnInitializePotentialDragEvent.Trigger(eventData); + } + } + + public static class OnInitializePotentialDragEventTriggerExtension + { + public static IUnRegister OnInitializePotentialDragEvent(this T self, Action onInitializePotentialDrag) + where T : Component + { + return self.GetOrAddComponent().OnInitializePotentialDragEvent.Register(onInitializePotentialDrag); + } + + public static IUnRegister OnInitializePotentialDragEvent(this GameObject self, Action onInitializePotentialDrag) + { + return self.GetOrAddComponent().OnInitializePotentialDragEvent.Register(onInitializePotentialDrag); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs.meta new file mode 100644 index 0000000..f078a43 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1468538519904eb09d28417b06011d67 +timeCreated: 1684921875 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs new file mode 100644 index 0000000..39d6a54 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnMoveEventTrigger: MonoBehaviour, IMoveHandler + { + public readonly EasyEvent OnMoveEvent = new EasyEvent(); + + public void OnMove(AxisEventData eventData) + { + OnMoveEvent.Trigger(eventData); + } + } + + public static class OnMoveEventTriggerExtension + { + public static IUnRegister OnMoveEvent(this T self, Action onMove) + where T : Component + { + return self.GetOrAddComponent().OnMoveEvent.Register(onMove); + } + + public static IUnRegister OnMoveEvent(this GameObject self, Action onMove) + { + return self.GetOrAddComponent().OnMoveEvent.Register(onMove); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs.meta new file mode 100644 index 0000000..b01b930 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 624f894e14aa490db08cf81024600e93 +timeCreated: 1684921859 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs new file mode 100644 index 0000000..d8ac5b4 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnPointerClickEventTrigger : MonoBehaviour, IPointerClickHandler + { + public readonly EasyEvent OnPointerClickEvent = new EasyEvent(); + + public void OnPointerClick(PointerEventData eventData) + { + OnPointerClickEvent.Trigger(eventData); + } + } + + public static class OnPointerClickEventTriggerExtension + { + public static IUnRegister OnPointerClickEvent(this T self, Action onPointerClick) + where T : Component + { + return self.GetOrAddComponent().OnPointerClickEvent.Register(onPointerClick); + } + + public static IUnRegister OnPointerClickEvent(this GameObject self, Action onPointerClick) + { + return self.GetOrAddComponent().OnPointerClickEvent.Register(onPointerClick); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs.meta new file mode 100644 index 0000000..cf7837e --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3ae5dbb0c46a4a828719e58bcf539e09 +timeCreated: 1658665723 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs new file mode 100644 index 0000000..783d8ea --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs @@ -0,0 +1,33 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnPointerDownEventTrigger : MonoBehaviour,IPointerDownHandler + { + public readonly EasyEvent OnPointerDownEvent = new EasyEvent(); + + public void OnPointerDown(PointerEventData eventData) + { + OnPointerDownEvent.Trigger(eventData); + } + } + + public static class OnPointerDownEventTriggerExtension + { + public static IUnRegister OnPointerDownEvent(this T self, Action onPointerDownEvent) + where T : Component + { + return self.GetOrAddComponent().OnPointerDownEvent + .Register(onPointerDownEvent); + } + + public static IUnRegister OnPointerDownEvent(this GameObject self, Action onPointerDownEvent) + { + return self.GetOrAddComponent().OnPointerDownEvent + .Register(onPointerDownEvent); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs.meta new file mode 100644 index 0000000..bb944dc --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7ad55473a3084b0e91aa28972b4739e0 +timeCreated: 1684917989 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs new file mode 100644 index 0000000..d85cc03 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnPointerEnterEventTrigger : MonoBehaviour, IPointerEnterHandler + { + public readonly EasyEvent OnPointerEnterEvent = new EasyEvent(); + + public void OnPointerEnter(PointerEventData eventData) + { + OnPointerEnterEvent.Trigger(eventData); + } + } + + public static class OnPointerEnterEventTriggerExtension + { + public static IUnRegister OnPointerEnterEvent(this T self, Action onPointerEnter) + where T : Component + { + return self.GetOrAddComponent().OnPointerEnterEvent.Register(onPointerEnter); + } + + public static IUnRegister OnPointerEnterEvent(this GameObject self, Action onPointerEnter) + { + return self.GetOrAddComponent().OnPointerEnterEvent.Register(onPointerEnter); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs.meta new file mode 100644 index 0000000..6013cea --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: abdff8ce2d614a1898361669f649034c +timeCreated: 1684921387 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs new file mode 100644 index 0000000..eae816c --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnPointerExitEventTrigger : MonoBehaviour, IPointerExitHandler + { + public readonly EasyEvent OnPointerExitEvent = new EasyEvent(); + + public void OnPointerExit(PointerEventData eventData) + { + OnPointerExitEvent.Trigger(eventData); + } + } + + public static class OnPointerExitEventTriggerExtension + { + public static IUnRegister OnPointerExitEvent(this T self, Action onPointerExit) + where T : Component + { + return self.GetOrAddComponent().OnPointerExitEvent.Register(onPointerExit); + } + + public static IUnRegister OnPointerExitEvent(this GameObject self, Action onPointerExit) + { + return self.GetOrAddComponent().OnPointerExitEvent.Register(onPointerExit); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs.meta new file mode 100644 index 0000000..0ed7e23 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a0b4ce9dfff1418787b11f87638a30f8 +timeCreated: 1684921704 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs new file mode 100644 index 0000000..aaabd3a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs @@ -0,0 +1,33 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnPointerUpEventTrigger : MonoBehaviour,IPointerUpHandler + { + public readonly EasyEvent OnPointerUpEvent = new EasyEvent(); + + public void OnPointerUp(PointerEventData eventData) + { + OnPointerUpEvent.Trigger(eventData); + } + } + + public static class OnPointerUpEventTriggerExtension + { + public static IUnRegister OnPointerUpEvent(this T self, Action onPointerUpEvent) + where T : Component + { + return self.GetOrAddComponent().OnPointerUpEvent + .Register(onPointerUpEvent); + } + + public static IUnRegister OnPointerUpEvent(this GameObject self, Action onPointerUpEvent) + { + return self.GetOrAddComponent().OnPointerUpEvent + .Register(onPointerUpEvent); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs.meta new file mode 100644 index 0000000..50d1f67 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4975092dfacf4edd95cf8142d6d549ca +timeCreated: 1684918304 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs new file mode 100644 index 0000000..f14788f --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnScrollEventTrigger: MonoBehaviour, IScrollHandler + { + public readonly EasyEvent OnScrollEvent = new EasyEvent(); + + public void OnScroll(PointerEventData eventData) + { + OnScrollEvent.Trigger(eventData); + } + } + + public static class OnScrollEventTriggerExtension + { + public static IUnRegister OnScrollEvent(this T self, Action onScroll) + where T : Component + { + return self.GetOrAddComponent().OnScrollEvent.Register(onScroll); + } + + public static IUnRegister OnScrollEvent(this GameObject self, Action onScroll) + { + return self.GetOrAddComponent().OnScrollEvent.Register(onScroll); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs.meta new file mode 100644 index 0000000..5a25c3b --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a5eff617f4604eb7b6439224ffa9bffe +timeCreated: 1684921838 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs new file mode 100644 index 0000000..d65b535 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnSelectEventTrigger: MonoBehaviour, ISelectHandler + { + public readonly EasyEvent OnSelectEvent = new EasyEvent(); + + public void OnSelect(BaseEventData eventData) + { + OnSelectEvent.Trigger(eventData); + } + } + + public static class OnSelectEventTriggerTriggerExtension + { + public static IUnRegister OnSelectEvent(this T self, Action onSelect) + where T : Component + { + return self.GetOrAddComponent().OnSelectEvent.Register(onSelect); + } + + public static IUnRegister OnSelectEvent(this GameObject self, Action onSelect) + { + return self.GetOrAddComponent().OnSelectEvent.Register(onSelect); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs.meta new file mode 100644 index 0000000..854acd7 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c1c1463405ce421b8764390fa5bb764d +timeCreated: 1684921849 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs new file mode 100644 index 0000000..4daf29c --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnSubmitEventTrigger: MonoBehaviour, ISubmitHandler + { + public readonly EasyEvent OnSubmitEvent = new EasyEvent(); + + public void OnSubmit(BaseEventData eventData) + { + OnSubmitEvent.Trigger(eventData); + } + } + + public static class OnSubmitEventTriggerExtension + { + public static IUnRegister OnSubmitEvent(this T self, Action onSubmit) + where T : Component + { + return self.GetOrAddComponent().OnSubmitEvent.Register(onSubmit); + } + + public static IUnRegister OnSubmitEvent(this GameObject self, Action onSubmit) + { + return self.GetOrAddComponent().OnSubmitEvent.Register(onSubmit); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs.meta new file mode 100644 index 0000000..4351ead --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b72c739ccdec4249bf698dee82a4f475 +timeCreated: 1684921864 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs new file mode 100644 index 0000000..d43e373 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnUpdateSelectedEventTrigger: MonoBehaviour, IUpdateSelectedHandler + { + public readonly EasyEvent OnUpdateSelectedEvent = new EasyEvent(); + + + public void OnUpdateSelected(BaseEventData eventData) + { + OnUpdateSelectedEvent.Trigger(eventData); + } + } + + public static class OnUpdateSelectedEventTriggerExtension + { + public static IUnRegister OnUpdateSelectedEvent(this T self, Action onUpdateSelected) + where T : Component + { + return self.GetOrAddComponent().OnUpdateSelectedEvent.Register(onUpdateSelected); + } + + public static IUnRegister OnUpdateSelectedEvent(this GameObject self, Action onUpdateSelected) + { + return self.GetOrAddComponent().OnUpdateSelectedEvent.Register(onUpdateSelected); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs.meta new file mode 100644 index 0000000..0a824e9 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 11b3a438de52430e8f4b435d4a095fb4 +timeCreated: 1684921844 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/EventKit/Example.unitypackage.meta b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Example.unitypackage.meta new file mode 100644 index 0000000..daf4943 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/EventKit/Example.unitypackage.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 194887e39d37cd742a57ffe4cfe1b21b +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI.meta new file mode 100644 index 0000000..4f202cd --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f099e1f5ec77994f97c7988bde11d4f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity.meta new file mode 100644 index 0000000..573936d --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 84dfa4614a74466f938b3c4cfb7f63f0 +timeCreated: 1647443763 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs new file mode 100644 index 0000000..5175dac --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs @@ -0,0 +1,230 @@ +using Stary.Evo; +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Object", 0)] + [APIDescriptionCN("针对 UnityEngine.Object 提供的链式扩展")] + [APIDescriptionEN("The chain extension provided by UnityEngine.Object")] + [APIExampleCode(@" +var gameObject = new GameObject(); +// +gameObject.Instantiate() + .Name(""ExtensionExample"") + .DestroySelf(); +// +gameObject.Instantiate() + .DestroySelfGracefully(); +// +gameObject.Instantiate() + .DestroySelfAfterDelay(1.0f); +// +gameObject.Instantiate() + .DestroySelfAfterDelayGracefully(1.0f); +// +gameObject + .Self(selfObj => Debug.Log(selfObj.name)) + .Name(""TestObj"") + .Self(selfObj => Debug.Log(selfObj.name)) + .Name(""ExtensionExample"") + .DontDestroyOnLoad(); +")] +#endif + public static class UnityEngineObjectExtension + { +#if UNITY_EDITOR + // v1 No.37 + [MethodAPI] + [APIDescriptionCN("Object.Instantiate(Object) 的简单链式封装")] + [APIDescriptionEN("Object.Instantiate(Object) extension")] + [APIExampleCode(@" +prefab.Instantiate(); +")] +#endif + public static T Instantiate(this T selfObj) where T : UnityEngine.Object + { + return UnityEngine.Object.Instantiate(selfObj); + } +#if UNITY_EDITOR + // v1 No.38 + [MethodAPI] + [APIDescriptionCN("Object.Instantiate(Object,Vector3,Quaternion) 的简单链式封装")] + [APIDescriptionEN("Object.Instantiate(Object,Vector3,Quaternion) extension")] + [APIExampleCode(@" +prefab.Instantiate(Vector3.zero,Quaternion.identity); +")] +#endif + public static T Instantiate(this T selfObj, Vector3 position, Quaternion rotation) + where T : UnityEngine.Object + { + return UnityEngine.Object.Instantiate(selfObj, position, rotation); + } + +#if UNITY_EDITOR + // v1 No.39 + [MethodAPI] + [APIDescriptionCN("Object.Instantiate(Object,Vector3,Quaternion,Transform parent) 的简单链式封装")] + [APIDescriptionEN("Object.Instantiate(Object,Vector3,Quaternion,Transform parent) extension")] + [APIExampleCode(@" +prefab.Instantiate(Vector3.zero,Quaternion.identity,transformRoot); +")] +#endif + public static T Instantiate( + this T selfObj, + Vector3 position, + Quaternion rotation, + Transform parent) + where T : UnityEngine.Object + { + return UnityEngine.Object.Instantiate(selfObj, position, rotation, parent); + } + +#if UNITY_EDITOR + // v1 No.40 + [MethodAPI] + [APIDescriptionCN("Object.Instantiate(Transform parent,bool worldPositionStays) 的简单链式封装")] + [APIDescriptionEN("Object.Instantiate(Transform parent,bool worldPositionStays) extension")] + [APIExampleCode(@" +prefab.Instantiate(transformRoot,true); +")] +#endif + public static T InstantiateWithParent(this T selfObj, Transform parent, bool worldPositionStays) + where T : UnityEngine.Object + { + return (T)UnityEngine.Object.Instantiate((UnityEngine.Object)selfObj, parent, worldPositionStays); + } + + public static T InstantiateWithParent(this T selfObj, Component parent, bool worldPositionStays) + where T : UnityEngine.Object + { + return (T)UnityEngine.Object.Instantiate((UnityEngine.Object)selfObj, parent.transform, worldPositionStays); + } +#if UNITY_EDITOR + // v1 No.41 + [MethodAPI] + [APIDescriptionCN("Object.Instantiate(Transform parent) 的简单链式封装")] + [APIDescriptionEN("Object.Instantiate(Transform parent) extension")] + [APIExampleCode(@" +prefab.Instantiate(transformRoot); +")] +#endif + public static T InstantiateWithParent(this T selfObj, Transform parent) where T : UnityEngine.Object + { + return UnityEngine.Object.Instantiate(selfObj, parent, false); + } + + public static T InstantiateWithParent(this T selfObj, Component parent) where T : UnityEngine.Object + { + return UnityEngine.Object.Instantiate(selfObj, parent.transform, false); + } + + +#if UNITY_EDITOR + // v1 No.42 + [MethodAPI] + [APIDescriptionCN("设置名字")] + [APIDescriptionEN("set Object's name")] + [APIExampleCode(@" +scriptableObject.Name(""LevelData""); +Debug.Log(scriptableObject.name); +// LevelData +")] +#endif + public static T Name(this T selfObj, string name) where T : UnityEngine.Object + { + selfObj.name = name; + return selfObj; + } + + +#if UNITY_EDITOR + // v1 No.43 + [MethodAPI] + [APIDescriptionCN("Object.Destroy(Object) 简单链式封装")] + [APIDescriptionEN("Object.Destroy(Object) extension")] + [APIExampleCode(@" +new GameObject().DestroySelf() +")] +#endif + public static void DestroySelf(this T selfObj) where T : UnityEngine.Object + { + UnityEngine.Object.Destroy(selfObj); + } + +#if UNITY_EDITOR + // v1 No.44 + [MethodAPI] + [APIDescriptionCN("Object.Destroy(Object) 简单链式封装")] + [APIDescriptionEN("Object.Destroy(Object) extension")] + [APIExampleCode(@" +GameObject gameObj = null; +gameObj.DestroySelfGracefully(); +// not throw null exception +// 这样写不会报异常(但是不好调试) +")] +#endif + public static T DestroySelfGracefully(this T selfObj) where T : UnityEngine.Object + { + if (selfObj) + { + UnityEngine.Object.Destroy(selfObj); + } + + return selfObj; + } + + +#if UNITY_EDITOR + // v1 No.45 + [MethodAPI] + [APIDescriptionCN("Object.Destroy(Object,float) 简单链式封装")] + [APIDescriptionEN("Object.Destroy(Object,float) extension")] + [APIExampleCode(@" +new GameObject().DestroySelfAfterDelay(5); +")] +#endif + public static T DestroySelfAfterDelay(this T selfObj, float afterDelay) where T : UnityEngine.Object + { + UnityEngine.Object.Destroy(selfObj, afterDelay); + return selfObj; + } + +#if UNITY_EDITOR + // v1 No.46 + [MethodAPI] + [APIDescriptionCN("Object.Destroy(Object,float) 简单链式封装")] + [APIDescriptionEN("Object.Destroy(Object,float) extension")] + [APIExampleCode(@" +GameObject gameObj = null; +gameObj.DestroySelfAfterDelayGracefully(5); +// not throw exception +// 不会报异常 +")] +#endif + public static T DestroySelfAfterDelayGracefully(this T selfObj, float delay) where T : UnityEngine.Object + { + if (selfObj) + { + UnityEngine.Object.Destroy(selfObj, delay); + } + + return selfObj; + } + +#if UNITY_EDITOR + // v1 No.47 + [MethodAPI] + [APIDescriptionCN("Object.DontDestroyOnLoad 简单链式封装")] + [APIDescriptionEN("Object.DontDestroyOnLoad extension")] + [APIExampleCode(@" +new GameObject().DontDestroyOnLoad(); +")] +#endif + public static T DontDestroyOnLoad(this T selfObj) where T : UnityEngine.Object + { + UnityEngine.Object.DontDestroyOnLoad(selfObj); + return selfObj; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs.meta new file mode 100644 index 0000000..03f4e74 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5f82c097d6fc40e3ba52585f53920178 +timeCreated: 1647487579 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs new file mode 100644 index 0000000..764fc6d --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs @@ -0,0 +1,334 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.GameObject", 1)] + [APIDescriptionCN("针对 UnityEngine.GameObject 提供的链式扩展")] + [APIDescriptionEN("The chain extension provided by UnityEngine.Object.")] + [APIExampleCode(@" +var gameObject = new GameObject(); +var transform = gameObject.transform; +var selfScript = gameObject.AddComponent(); +var boxCollider = gameObject.AddComponent(); +// +gameObject.Show(); // gameObject.SetActive(true) +selfScript.Show(); // this.gameObject.SetActive(true) +boxCollider.Show(); // boxCollider.gameObject.SetActive(true) +gameObject.transform.Show(); // transform.gameObject.SetActive(true) +// +gameObject.Hide(); // gameObject.SetActive(false) +selfScript.Hide(); // this.gameObject.SetActive(false) +boxCollider.Hide(); // boxCollider.gameObject.SetActive(false) +transform.Hide(); // transform.gameObject.SetActive(false) +// +selfScript.DestroyGameObj(); +boxCollider.DestroyGameObj(); +]transform.DestroyGameObj(); +// +selfScript.DestroyGameObjGracefully(); +boxCollider.DestroyGameObjGracefully(); +transform.DestroyGameObjGracefully(); +// +selfScript.DestroyGameObjAfterDelay(1.0f); +boxCollider.DestroyGameObjAfterDelay(1.0f); +transform.DestroyGameObjAfterDelay(1.0f); +// +selfScript.DestroyGameObjAfterDelayGracefully(1.0f); +boxCollider.DestroyGameObjAfterDelayGracefully(1.0f); +transform.DestroyGameObjAfterDelayGracefully(1.0f); +// +gameObject.Layer(0); +selfScript.Layer(0); +boxCollider.Layer(0); +transform.Layer(0); +// +gameObject.Layer(""Default""); +selfScript.Layer(""Default""); +boxCollider.Layer(""Default""); +transform.Layer(""Default""); +")] +#endif + public static class UnityEngineGameObjectExtension + { +#if UNITY_EDITOR + // v1 No.48 + [MethodAPI] + [APIDescriptionCN("gameObject.SetActive(true)")] + [APIDescriptionEN("gameObject.SetActive(true)")] + [APIExampleCode(@" +new GameObject().Show(); +")] +#endif + public static GameObject Show(this GameObject selfObj) + { + selfObj.SetActive(true); + return selfObj; + } +#if UNITY_EDITOR + // v1 No.49 + [MethodAPI] + [APIDescriptionCN("script.gameObject.SetActive(true)")] + [APIDescriptionEN("script.gameObject.SetActive(true)")] + [APIExampleCode(@" +GetComponent().Show(); +")] +#endif + public static T Show(this T selfComponent) where T : Component + { + selfComponent.gameObject.Show(); + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.50 + [MethodAPI] + [APIDescriptionCN("gameObject.SetActive(false)")] + [APIDescriptionEN("gameObject.SetActive(false)")] + [APIExampleCode(@" +gameObject.Hide(); +")] +#endif + public static GameObject Hide(this GameObject selfObj) + { + selfObj.SetActive(false); + return selfObj; + } + +#if UNITY_EDITOR + // v1 No.51 + [MethodAPI] + [APIDescriptionCN("myScript.gameObject.SetActive(false)")] + [APIDescriptionEN("myScript.gameObject.SetActive(false)")] + [APIExampleCode(@" +GetComponent().Hide(); +")] +#endif + public static T Hide(this T selfComponent) where T : Component + { + selfComponent.gameObject.Hide(); + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.52 + [MethodAPI] + [APIDescriptionCN("Destroy(myScript.gameObject)")] + [APIDescriptionEN("Destroy(myScript.gameObject)")] + [APIExampleCode(@" +myScript.DestroyGameObj(); +")] +#endif + public static void DestroyGameObj(this T selfBehaviour) where T : Component + { + selfBehaviour.gameObject.DestroySelf(); + } + + +#if UNITY_EDITOR + // v1 No.53 + [MethodAPI] + [APIDescriptionCN("if (myScript) Destroy(myScript.gameObject)")] + [APIDescriptionEN("if (myScript) Destroy(myScript.gameObject)")] + [APIExampleCode(@" +myScript.DestroyGameObjGracefully(); +")] +#endif + public static void DestroyGameObjGracefully(this T selfBehaviour) where T : Component + { + if (selfBehaviour && selfBehaviour.gameObject) + { + selfBehaviour.gameObject.DestroySelfGracefully(); + } + } + +#if UNITY_EDITOR + // v1 No.54 + [MethodAPI] + [APIDescriptionCN("Object.Destroy(myScript.gameObject,delaySeconds)")] + [APIDescriptionEN("Object.Destroy(myScript.gameObject,delaySeconds)")] + [APIExampleCode(@" +myScript.DestroyGameObjAfterDelay(5); +")] +#endif + public static T DestroyGameObjAfterDelay(this T selfBehaviour, float delay) where T : Component + { + selfBehaviour.gameObject.DestroySelfAfterDelay(delay); + return selfBehaviour; + } + +#if UNITY_EDITOR + // v1 No.55 + [MethodAPI] + [APIDescriptionCN("if (myScript && myScript.gameObject) Object.Destroy(myScript.gameObject,delaySeconds)")] + [APIDescriptionEN("if (myScript && myScript.gameObject) Object.Destroy(myScript.gameObject,delaySeconds)")] + [APIExampleCode(@" +myScript.DestroyGameObjAfterDelayGracefully(5); +")] +#endif + public static T DestroyGameObjAfterDelayGracefully(this T selfBehaviour, float delay) where T : Component + { + if (selfBehaviour && selfBehaviour.gameObject) + { + selfBehaviour.gameObject.DestroySelfAfterDelay(delay); + } + + return selfBehaviour; + } + + +#if UNITY_EDITOR + // v1 No.56 + [MethodAPI] + [APIDescriptionCN("gameObject.layer = layer")] + [APIDescriptionEN("gameObject.layer = layer")] + [APIExampleCode(@" +new GameObject().Layer(0); +")] +#endif + public static GameObject Layer(this GameObject selfObj, int layer) + { + selfObj.layer = layer; + return selfObj; + } + +#if UNITY_EDITOR + // v1 No.57 + [MethodAPI] + [APIDescriptionCN("component.gameObject.layer = layer")] + [APIDescriptionEN("component.gameObject.layer = layer")] + [APIExampleCode(@" +rigidbody2D.Layer(0); +")] +#endif + public static T Layer(this T selfComponent, int layer) where T : Component + { + selfComponent.gameObject.layer = layer; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.58 + [MethodAPI] + [APIDescriptionCN("gameObj.layer = LayerMask.NameToLayer(layerName)")] + [APIDescriptionEN("gameObj.layer = LayerMask.NameToLayer(layerName)")] + [APIExampleCode(@" +new GameObject().Layer(""Default""); +")] +#endif + + public static GameObject Layer(this GameObject selfObj, string layerName) + { + selfObj.layer = LayerMask.NameToLayer(layerName); + return selfObj; + } + +#if UNITY_EDITOR + // v1 No.59 + [MethodAPI] + [APIDescriptionCN("component.gameObject.layer = LayerMask.NameToLayer(layerName)")] + [APIDescriptionEN("component.gameObject.layer = LayerMask.NameToLayer(layerName)")] + [APIExampleCode(@" +spriteRenderer.Layer(""Default""); +")] +#endif + public static T Layer(this T selfComponent, string layerName) where T : Component + { + selfComponent.gameObject.layer = LayerMask.NameToLayer(layerName); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.60 + [MethodAPI] + [APIDescriptionCN("layerMask 中的层级是否包含 gameObj 所在的层级")] + [APIDescriptionEN("Whether the layer in layerMask contains the same layer as gameObj")] + [APIExampleCode(@" +gameObj.IsInLayerMask(layerMask); +")] +#endif + public static bool IsInLayerMask(this GameObject selfObj, LayerMask layerMask) + { + return LayerMaskUtility.IsInLayerMask(selfObj, layerMask); + } + +#if UNITY_EDITOR + // v1 No.61 + [MethodAPI] + [APIDescriptionCN("layerMask 中的层级是否包含 component.gameObject 所在的层级")] + [APIDescriptionEN("Whether the layer in layerMask contains the same layer as component.gameObject")] + [APIExampleCode(@" +spriteRenderer.IsInLayerMask(layerMask); +")] +#endif + public static bool IsInLayerMask(this T selfComponent, LayerMask layerMask) where T : Component + { + return LayerMaskUtility.IsInLayerMask(selfComponent.gameObject, layerMask); + } + + +#if UNITY_EDITOR + // v1 No.62 + [MethodAPI] + [APIDescriptionCN("获取组件,没有则添加再返回")] + [APIDescriptionEN("Get component, add and return if not")] + [APIExampleCode(@" +gameObj.GetOrAddComponent(); +")] +#endif + public static T GetOrAddComponent(this GameObject self) where T : Component + { + var comp = self.gameObject.GetComponent(); + return comp ? comp : self.gameObject.AddComponent(); + } + +#if UNITY_EDITOR + // v1 No.63 + [MethodAPI] + [APIDescriptionCN("获取组件,没有则添加再返回")] + [APIDescriptionEN("Get component, add and return if not")] + [APIExampleCode(@" +component.GetOrAddComponent(); +")] +#endif + public static T GetOrAddComponent(this Component component) where T : Component + { + return component.gameObject.GetOrAddComponent(); + } + +#if UNITY_EDITOR + // v1 No.64 + [MethodAPI] + [APIDescriptionCN("获取组件,没有则添加再返回")] + [APIDescriptionEN("Get component, add and return if not")] + [APIExampleCode(@" +gameObj.GetOrAddComponent(typeof(SpriteRenderer)); +")] +#endif + public static Component GetOrAddComponent(this GameObject self, Type type) + { + var component = self.gameObject.GetComponent(type); + return component ? component : self.gameObject.AddComponent(type); + } + } + + public static class LayerMaskUtility + { + public static bool IsInLayerMask(int layer, LayerMask layerMask) + { + var objLayerMask = 1 << layer; + return (layerMask.value & objLayerMask) == objLayerMask; + } + + public static bool IsInLayerMask(GameObject gameObj, LayerMask layerMask) + { + // 根据Layer数值进行移位获得用于运算的Mask值 + var objLayerMask = 1 << gameObj.layer; + return (layerMask.value & objLayerMask) == objLayerMask; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs.meta new file mode 100644 index 0000000..fc8dfd6 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 36146f65e25b4ec79d3030f3babbc6cc +timeCreated: 1647490642 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs new file mode 100644 index 0000000..377a68f --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs @@ -0,0 +1,1743 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Transform", 2)] + [APIDescriptionCN("针对 UnityEngine.GameObject 提供的链式扩展")] + [APIDescriptionEN("The chain extension provided by UnityEngine.Object.")] + [APIExampleCode(@" +var selfScript = new GameObject().AddComponent(); +var transform = selfScript.transform; + +transform + .Parent(null) + .LocalIdentity() + .LocalPositionIdentity() + .LocalRotationIdentity() + .LocalScaleIdentity() + .LocalPosition(Vector3.zero) + .LocalPosition(0, 0, 0) + .LocalPosition(0, 0) + .LocalPositionX(0) + .LocalPositionY(0) + .LocalPositionZ(0) + .LocalRotation(Quaternion.identity) + .LocalScale(Vector3.one) + .LocalScaleX(1.0f) + .LocalScaleY(1.0f) + .Identity() + .PositionIdentity() + .RotationIdentity() + .Position(Vector3.zero) + .PositionX(0) + .PositionY(0) + .PositionZ(0) + .Rotation(Quaternion.identity) + .DestroyChildren() + .AsLastSibling() + .AsFirstSibling() + .SiblingIndex(0); + +selfScript + .Parent(null) + .LocalIdentity() + .LocalPositionIdentity() + .LocalRotationIdentity() + .LocalScaleIdentity() + .LocalPosition(Vector3.zero) + .LocalPosition(0, 0, 0) + .LocalPosition(0, 0) + .LocalPositionX(0) + .LocalPositionY(0) + .LocalPositionZ(0) + .LocalRotation(Quaternion.identity) + .LocalScale(Vector3.one) + .LocalScaleX(1.0f) + .LocalScaleY(1.0f) + .Identity() + .PositionIdentity() + .RotationIdentity() + .Position(Vector3.zero) + .PositionX(0) + .PositionY(0) + .PositionZ(0) + .Rotation(Quaternion.identity) + .DestroyChildren() + .AsLastSibling() + .AsFirstSibling() + .SiblingIndex(0); +")] +#endif + public static class UnityEngineTransformExtension + { +#if UNITY_EDITOR + // v1 No.65 + [MethodAPI] + [APIDescriptionCN("component.transform.SetParent(parent)")] + [APIDescriptionEN("component.transform.SetParent(parent)")] + [APIExampleCode(@" +myScript.Parent(rootGameObj); +")] +#endif + public static T Parent(this T self, Component parent) where T : Component + { + self.transform.SetParent(parent == null ? null : parent.transform); + return self; + } + +#if UNITY_EDITOR + // v1 No.66 + [MethodAPI] + [APIDescriptionCN("gameObject.transform.SetParent(parent)")] + [APIDescriptionEN("gameObject.transform.SetParent(parent)")] + [APIExampleCode(@" +gameObj.SetParent(null); +")] +#endif + public static GameObject Parent(this GameObject self, Component parent) + { + self.transform.SetParent(parent == null ? null : parent.transform); + return self; + } + +#if UNITY_EDITOR + // v1 No.67 + [MethodAPI] + [APIDescriptionCN("component.transform.SetParent(null)")] + [APIDescriptionEN("component.transform.SetParent(null)")] + [APIExampleCode(@" +component.AsRootTransform(); +")] +#endif + public static T AsRootTransform(this T self) where T : Component + { + self.transform.SetParent(null); + return self; + } + +#if UNITY_EDITOR + // v1 No.68 + [MethodAPI] + [APIDescriptionCN("gameObject.transform.SetParent(null)")] + [APIDescriptionEN("gameObject.transform.SetParent(null)")] + [APIExampleCode(@" +gameObject.AsRootGameObject(); +")] +#endif + public static GameObject AsRootGameObject(this GameObject self) + { + self.transform.SetParent(null); + return self; + } + + +#if UNITY_EDITOR + // v1 No.69 + [MethodAPI] + [APIDescriptionCN("设置本地位置为 0、本地角度为 0、本地缩放为 1")] + [APIDescriptionEN("set local pos:0 local angle:0 local scale:1")] + [APIExampleCode(@" +myScript.LocalIdentity(); +")] +#endif + public static T LocalIdentity(this T self) where T : Component + { + self.transform.localPosition = Vector3.zero; + self.transform.localRotation = Quaternion.identity; + self.transform.localScale = Vector3.one; + return self; + } + +#if UNITY_EDITOR + // v1 No.70 + [MethodAPI] + [APIDescriptionCN("设置 gameObject 的本地位置为 0、本地角度为 0、本地缩放为 1")] + [APIDescriptionEN("set gameObject's local pos:0 local angle:0 local scale:1")] + [APIExampleCode(@" +myScript.LocalIdentity(); +")] +#endif + public static GameObject LocalIdentity(this GameObject self) + { + self.transform.localPosition = Vector3.zero; + self.transform.localRotation = Quaternion.identity; + self.transform.localScale = Vector3.one; + return self; + } + + +#if UNITY_EDITOR + // v1 No.71 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition = localPosition")] + [APIDescriptionEN("component.transform.localPosition = localPosition")] + [APIExampleCode(@" +spriteRenderer.LocalPosition(new Vector3(0,100,0)); +")] +#endif + public static T LocalPosition(this T selfComponent, Vector3 localPos) where T : Component + { + selfComponent.transform.localPosition = localPos; + return selfComponent; + } +#if UNITY_EDITOR + // v1 No.72 + [MethodAPI] + [APIDescriptionCN("gameObject.transform.localPosition = localPosition")] + [APIDescriptionEN("gameObject.transform.localPosition = localPosition")] + [APIExampleCode(@" +new GameObject().LocalPosition(new Vector3(0,100,0)); +")] +#endif + public static GameObject LocalPosition(this GameObject self, Vector3 localPos) + { + self.transform.localPosition = localPos; + return self; + } + +#if UNITY_EDITOR + // v1 No.73 + [MethodAPI] + [APIDescriptionCN("return component.transform.localPosition")] + [APIDescriptionEN("return component.transform.localPosition")] + [APIExampleCode(@" +var localPosition = spriteRenderer.LocalPosition(); +")] +#endif + public static Vector3 LocalPosition(this T selfComponent) where T : Component + { + return selfComponent.transform.localPosition; + } + +#if UNITY_EDITOR + // v1 No.74 + [MethodAPI] + [APIDescriptionCN("return gameObject.transform.localPosition")] + [APIDescriptionEN("return gameObject.transform.localPosition")] + [APIExampleCode(@" +Debug.Log(new GameObject().LocalPosition()); +")] +#endif + public static Vector3 LocalPosition(this GameObject self) + { + return self.transform.localPosition; + } + + +#if UNITY_EDITOR + // v1 No.75 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition = new Vector3(x,y,z)")] + [APIDescriptionEN("component.transform.localPosition = new Vector3(x,y,z)")] + [APIExampleCode(@" +myScript.LocalPosition(0,0,-10); +")] +#endif + public static T LocalPosition(this T selfComponent, float x, float y, float z) where T : Component + { + selfComponent.transform.localPosition = new Vector3(x, y, z); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.76 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition = new Vector3(x,y,z)")] + [APIDescriptionEN("gameObj.transform.localPosition = new Vector3(x,y,z)")] + [APIExampleCode(@" +new GameObject().LocalPosition(0,0,-10); +")] +#endif + public static GameObject LocalPosition(this GameObject self, float x, float y, float z) + { + self.transform.localPosition = new Vector3(x, y, z); + return self; + } + + +#if UNITY_EDITOR + // v1 No.77 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition = new Vector3(x,y,component.transform.localPosition.z)")] + [APIDescriptionEN("component.transform.localPosition = new Vector3(x,y,component.transform.localPosition.z)")] + [APIExampleCode(@" +myScript.LocalPosition(0,0); +")] +#endif + public static T LocalPosition(this T selfComponent, float x, float y) where T : Component + { + var localPosition = selfComponent.transform.localPosition; + localPosition.x = x; + localPosition.y = y; + selfComponent.transform.localPosition = localPosition; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.78 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition = new Vector3(x,y,gameObj.transform.localPosition.z)")] + [APIDescriptionEN("gameObj.transform.localPosition = new Vector3(x,y,gameObj.transform.localPosition.z)")] + [APIExampleCode(@" +new GameObject().LocalPosition(0,0); +")] +#endif + public static GameObject LocalPosition(this GameObject self, float x, float y) + { + var localPosition = self.transform.localPosition; + localPosition.x = x; + localPosition.y = y; + self.transform.localPosition = localPosition; + return self; + } + +#if UNITY_EDITOR + // v1 No.79 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition.x = x")] + [APIDescriptionEN("component.transform.localPosition.x = x")] + [APIExampleCode(@" +component.LocalPositionX(10); +")] +#endif + public static T LocalPositionX(this T selfComponent, float x) where T : Component + { + var localPosition = selfComponent.transform.localPosition; + localPosition.x = x; + selfComponent.transform.localPosition = localPosition; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.80 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition.x = x")] + [APIDescriptionEN("gameObj.transform.localPosition.x = x")] + [APIExampleCode(@" +gameObj.LocalPositionX(10); +")] +#endif + public static GameObject LocalPositionX(this GameObject self, float x) + { + var localPosition = self.transform.localPosition; + localPosition.x = x; + self.transform.localPosition = localPosition; + return self; + } + +#if UNITY_EDITOR + // v1 No.81 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition.y = y")] + [APIDescriptionEN("component.transform.localPosition.y = y")] + [APIExampleCode(@" +component.LocalPositionY(10); +")] +#endif + public static T LocalPositionY(this T selfComponent, float y) where T : Component + { + var localPosition = selfComponent.transform.localPosition; + localPosition.y = y; + selfComponent.transform.localPosition = localPosition; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.82 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition.y = y")] + [APIDescriptionEN("gameObj.transform.localPosition.y = y")] + [APIExampleCode(@" +gameObj.LocalPositionY(10); +")] +#endif + + public static GameObject LocalPositionY(this GameObject selfComponent, float y) + { + var localPosition = selfComponent.transform.localPosition; + localPosition.y = y; + selfComponent.transform.localPosition = localPosition; + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.83 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition.z = z")] + [APIDescriptionEN("component.transform.localPosition.z = z")] + [APIExampleCode(@" +component.LocalPositionZ(10); +")] +#endif + public static T LocalPositionZ(this T selfComponent, float z) where T : Component + { + var localPosition = selfComponent.transform.localPosition; + localPosition.z = z; + selfComponent.transform.localPosition = localPosition; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.84 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition.z = z")] + [APIDescriptionEN("gameObj.transform.localPosition.z = z")] + [APIExampleCode(@" +gameObj.LocalPositionZ(10); +")] +#endif + public static GameObject LocalPositionZ(this GameObject self, float z) + { + var localPosition = self.transform.localPosition; + localPosition.z = z; + self.transform.localPosition = localPosition; + return self; + } + + +#if UNITY_EDITOR + // v1 No.85 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition = Vector3.zero")] + [APIDescriptionEN("component.transform.localPosition = Vector3.zero")] + [APIExampleCode(@" +component.LocalPositionIdentity(); +")] +#endif + public static T LocalPositionIdentity(this T selfComponent) where T : Component + { + selfComponent.transform.localPosition = Vector3.zero; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.86 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition = Vector3.zero")] + [APIDescriptionEN("gameObj.transform.localPosition = Vector3.zero")] + [APIExampleCode(@" +gameObj.LocalPositionIdentity(); +")] +#endif + public static GameObject LocalPositionIdentity(this GameObject self) + { + self.transform.localPosition = Vector3.zero; + return self; + } + + +#if UNITY_EDITOR + // v1 No.87 + [MethodAPI] + [APIDescriptionCN("return component.transform.localRotation")] + [APIDescriptionEN("return component.transform.localRotation")] + [APIExampleCode(@" +var localRotation = myScript.LocalRotation(); +")] +#endif + public static Quaternion LocalRotation(this T selfComponent) where T : Component + { + return selfComponent.transform.localRotation; + } + +#if UNITY_EDITOR + // v1 No.88 + [MethodAPI] + [APIDescriptionCN("return gameObj.transform.localRotation")] + [APIDescriptionEN("return gameObj.transform.localRotation")] + [APIExampleCode(@" +var localRotation = gameObj.LocalRotation(); +")] +#endif + public static Quaternion LocalRotation(this GameObject self) + { + return self.transform.localRotation; + } + +#if UNITY_EDITOR + // v1 No.89 + [MethodAPI] + [APIDescriptionCN("component.transform.localRotation = localRotation")] + [APIDescriptionEN("component.transform.localRotation = localRotation")] + [APIExampleCode(@" +myScript.LocalRotation(Quaternion.identity); +")] +#endif + public static T LocalRotation(this T selfComponent, Quaternion localRotation) where T : Component + { + selfComponent.transform.localRotation = localRotation; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.90 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localRotation = localRotation")] + [APIDescriptionEN("gameObj.transform.localRotation = localRotation")] + [APIExampleCode(@" +gameObj.LocalRotation(Quaternion.identity); +")] +#endif + public static GameObject LocalRotation(this GameObject selfComponent, Quaternion localRotation) + { + selfComponent.transform.localRotation = localRotation; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.91 + [MethodAPI] + [APIDescriptionCN("component.transform.localRotation = Quaternion.identity")] + [APIDescriptionEN("component.transform.localRotation = Quaternion.identity")] + [APIExampleCode(@" +component.LocalRotationIdentity(); +")] +#endif + public static T LocalRotationIdentity(this T selfComponent) where T : Component + { + selfComponent.transform.localRotation = Quaternion.identity; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.92 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localRotation = Quaternion.identity")] + [APIDescriptionEN("gameObj.transform.localRotation = Quaternion.identity")] + [APIExampleCode(@" +gameObj.LocalRotationIdentity(); +")] +#endif + public static GameObject LocalRotationIdentity(this GameObject selfComponent) + { + selfComponent.transform.localRotation = Quaternion.identity; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.93 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = scale")] + [APIDescriptionEN("component.transform.localScale = scale")] + [APIExampleCode(@" +component.LocalScale(Vector3.one); +")] +#endif + public static T LocalScale(this T selfComponent, Vector3 scale) where T : Component + { + selfComponent.transform.localScale = scale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.94 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale = scale")] + [APIDescriptionEN("gameObj.transform.localScale = scale")] + [APIExampleCode(@" +gameObj.LocalScale(Vector3.one); +")] +#endif + public static GameObject LocalScale(this GameObject self, Vector3 scale) + { + self.transform.localScale = scale; + return self; + } + + +#if UNITY_EDITOR + // v1 No.95 + [MethodAPI] + [APIDescriptionCN("return component.transform.localScale")] + [APIDescriptionEN("return component.transform.localScale")] + [APIExampleCode(@" +var localScale = myScript.LocalScale(); +")] +#endif + public static Vector3 LocalScale(this T selfComponent) where T : Component + { + return selfComponent.transform.localScale; + } + +#if UNITY_EDITOR + // v1 No.96 + [MethodAPI] + [APIDescriptionCN("return gameObj.transform.localScale")] + [APIDescriptionEN("return gameObj.transform.localScale")] + [APIExampleCode(@" +var localScale = gameObj.LocalScale(); +")] +#endif + public static Vector3 LocalScale(this GameObject self) + { + return self.transform.localScale; + } + + +#if UNITY_EDITOR + // v1 No.97 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = new Vector3(xyz,xyz,xyz)")] + [APIDescriptionEN("component.transform.localScale = new Vector3(xyz,xyz,xyz)")] + [APIExampleCode(@" +myScript.LocalScale(1); +")] +#endif + public static T LocalScale(this T selfComponent, float xyz) where T : Component + { + selfComponent.transform.localScale = Vector3.one * xyz; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.98 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale = new Vector3(scale,scale,scale)")] + [APIDescriptionEN("gameObj.transform.localScale = new Vector3(scale,scale,scale)")] + [APIExampleCode(@" +gameObj.LocalScale(1); +")] +#endif + public static GameObject LocalScale(this GameObject self, float xyz) + { + self.transform.localScale = Vector3.one * xyz; + return self; + } + +#if UNITY_EDITOR + // v1 No.99 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = new Vector3(x,y,z)")] + [APIDescriptionEN("component.transform.localScale = new Vector3(x,y,z)")] + [APIExampleCode(@" +myScript.LocalScale(2,2,2); +")] +#endif + public static T LocalScale(this T selfComponent, float x, float y, float z) where T : Component + { + var localScale = selfComponent.transform.localScale; + localScale.x = x; + localScale.y = y; + localScale.z = z; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.100 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale = new Vector3(x,y,z)")] + [APIDescriptionEN("gameObj.transform.localScale = new Vector3(x,y,z)")] + [APIExampleCode(@" +gameObj.LocalScale(2,2,2); +")] +#endif + public static GameObject LocalScale(this GameObject selfComponent, float x, float y, float z) + { + var localScale = selfComponent.transform.localScale; + localScale.x = x; + localScale.y = y; + localScale.z = z; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.101 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = new Vector3(x,y,component.transform.localScale.z)")] + [APIDescriptionEN("component.transform.localScale = new Vector3(x,y,component.transform.localScale.z)")] + [APIExampleCode(@" +component.LocalScale(2,2); +")] +#endif + public static T LocalScale(this T selfComponent, float x, float y) where T : Component + { + var localScale = selfComponent.transform.localScale; + localScale.x = x; + localScale.y = y; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.102 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale = new Vector3(x,y,gameObj.transform.localScale.z)")] + [APIDescriptionEN("gameObj.transform.localScale = new Vector3(x,y,gameObj.transform.localScale.z)")] + [APIExampleCode(@" +gameObj.LocalScale(2,2); +")] +#endif + public static GameObject LocalScale(this GameObject selfComponent, float x, float y) + { + var localScale = selfComponent.transform.localScale; + localScale.x = x; + localScale.y = y; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.103 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.x = x")] + [APIDescriptionEN("component.transform.localScale.x = x)")] + [APIExampleCode(@" +component.LocalScaleX(10); +")] +#endif + public static T LocalScaleX(this T selfComponent, float x) where T : Component + { + var localScale = selfComponent.transform.localScale; + localScale.x = x; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.104 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.x = x")] + [APIDescriptionEN("gameObj.transform.localScale.x = x)")] + [APIExampleCode(@" +gameObj.LocalScaleX(10); +")] +#endif + public static GameObject LocalScaleX(this GameObject self, float x) + { + var localScale = self.transform.localScale; + localScale.x = x; + self.transform.localScale = localScale; + return self; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.x")] + [APIDescriptionEN("gameObj.transform.localScale.x)")] + [APIExampleCode(@" +var scaleX = gameObj.LocalScaleX(); +")] +#endif + public static float LocalScaleX(this GameObject self) + { + return self.transform.localScale.x; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.x")] + [APIDescriptionEN("component.transform.localScale.x)")] + [APIExampleCode(@" +var scaleX = component.LocalScaleX(); +")] +#endif + public static float LocalScaleX(this T self) where T : Component + { + return self.transform.localScale.x; + } + + +#if UNITY_EDITOR + // v1 No.105 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.y = y")] + [APIDescriptionEN("component.transform.localScale.y = y)")] + [APIExampleCode(@" +component.LocalScaleY(10); +")] +#endif + public static T LocalScaleY(this T self, float y) where T : Component + { + var localScale = self.transform.localScale; + localScale.y = y; + self.transform.localScale = localScale; + return self; + } + +#if UNITY_EDITOR + // v1 No.106 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.y = y")] + [APIDescriptionEN("gameObj.transform.localScale.y = y)")] + [APIExampleCode(@" +gameObj.LocalScaleY(10); +")] +#endif + public static GameObject LocalScaleY(this GameObject self, float y) + { + var localScale = self.transform.localScale; + localScale.y = y; + self.transform.localScale = localScale; + return self; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.y")] + [APIDescriptionEN("component.transform.localScale.y)")] + [APIExampleCode(@" +var scaleY = component.LocalScaleY(10); +")] +#endif + public static float LocalScaleY(this T self) where T : Component + { + return self.transform.localScale.y; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.y")] + [APIDescriptionEN("gameObj.transform.localScale.y)")] + [APIExampleCode(@" +var scaleY = gameObj.LocalScaleY(); +")] +#endif + public static float LocalScaleY(this GameObject self) + { + return self.transform.localScale.y; + } + + +#if UNITY_EDITOR + // v1 No.107 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.z = z")] + [APIDescriptionEN("component.transform.localScale.z = z)")] + [APIExampleCode(@" +component.LocalScaleZ(10); +")] +#endif + public static T LocalScaleZ(this T selfComponent, float z) where T : Component + { + var localScale = selfComponent.transform.localScale; + localScale.z = z; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.108 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.z = z")] + [APIDescriptionEN("gameObj.transform.localScale.z = z)")] + [APIExampleCode(@" +gameObj.LocalScaleZ(10); +")] +#endif + public static GameObject LocalScaleZ(this GameObject selfComponent, float z) + { + var localScale = selfComponent.transform.localScale; + localScale.z = z; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.z")] + [APIDescriptionEN("component.transform.localScale.z)")] + [APIExampleCode(@" +var scaleZ = component.LocalScaleZ(); +")] +#endif + public static float LocalScaleZ(this T self) where T : Component + { + return self.transform.localScale.z; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.z")] + [APIDescriptionEN("gameObj.transform.localScale.z)")] + [APIExampleCode(@" +var scaleZ = gameObj.LocalScaleZ(); +")] +#endif + public static float LocalScaleZ(this GameObject self) + { + return self.transform.localScale.z; + } + + +#if UNITY_EDITOR + // v1 No.109 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = Vector3.one")] + [APIDescriptionEN("component.transform.localScale = Vector3.one)")] + [APIExampleCode(@" +component.LocalScaleIdentity(); +")] +#endif + public static T LocalScaleIdentity(this T selfComponent) where T : Component + { + selfComponent.transform.localScale = Vector3.one; + return selfComponent; + } +#if UNITY_EDITOR + // v1 No.110 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = Vector3.one")] + [APIDescriptionEN("component.transform.localScale = Vector3.one)")] + [APIExampleCode(@" +component.LocalScaleIdentity(); +")] +#endif + public static GameObject LocalScaleIdentity(this GameObject selfComponent) + { + selfComponent.transform.localScale = Vector3.one; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.111 + [MethodAPI] + [APIDescriptionCN("设置世界位置:0 角度:0 缩放:1")] + [APIDescriptionEN("set world pos:0 rotation:0 scale:1")] + [APIExampleCode(@" +component.Identity(); +")] +#endif + public static T Identity(this T selfComponent) where T : Component + { + selfComponent.transform.position = Vector3.zero; + selfComponent.transform.rotation = Quaternion.identity; + selfComponent.transform.localScale = Vector3.one; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.112 + [MethodAPI] + [APIDescriptionCN("设置世界位置:0 角度:0 缩放:1")] + [APIDescriptionEN("set world pos:0 rotation:0 scale:1")] + [APIExampleCode(@" +component.Identity(); +")] +#endif + public static GameObject Identity(this GameObject self) + { + self.transform.position = Vector3.zero; + self.transform.rotation = Quaternion.identity; + self.transform.localScale = Vector3.one; + return self; + } + +#if UNITY_EDITOR + // v1 No.113 + [MethodAPI] + [APIDescriptionCN("component.transform.position = position")] + [APIDescriptionEN("component.transform.position = position")] + [APIExampleCode(@" +component.Position(Vector3.zero); +")] +#endif + public static T Position(this T selfComponent, Vector3 position) where T : Component + { + selfComponent.transform.position = position; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.114 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.position = position")] + [APIDescriptionEN("gameObj.transform.position = position")] + [APIExampleCode(@" +gameObj.Position(Vector3.zero); +")] +#endif + public static GameObject Position(this GameObject self, Vector3 position) + { + self.transform.position = position; + return self; + } + + +#if UNITY_EDITOR + // v1 No.115 + [MethodAPI] + [APIDescriptionCN("return component.transform.position")] + [APIDescriptionEN("return component.transform.position")] + [APIExampleCode(@" +var pos = myScript.Position(); +")] +#endif + public static Vector3 Position(this T selfComponent) where T : Component + { + return selfComponent.transform.position; + } + +#if UNITY_EDITOR + // v1 No.116 + [MethodAPI] + [APIDescriptionCN("return gameObj.transform.position")] + [APIDescriptionEN("return gameObj.transform.position")] + [APIExampleCode(@" +var pos = gameObj.Position(); +")] +#endif + public static Vector3 Position(this GameObject self) + { + return self.transform.position; + } + +#if UNITY_EDITOR + // v1 No.117 + [MethodAPI] + [APIDescriptionCN("component.transform.position = new Vector3(x,y,z)")] + [APIDescriptionEN("component.transform.position = new Vector3(x,y,z)")] + [APIExampleCode(@" +myScript.Position(0,0,-10); +")] +#endif + public static T Position(this T selfComponent, float x, float y, float z) where T : Component + { + selfComponent.transform.position = new Vector3(x, y, z); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.118 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.position = new Vector3(x,y,z)")] + [APIDescriptionEN("gameObj.transform.position = new Vector3(x,y,z)")] + [APIExampleCode(@" +gameObj.Position(0,0,-10); +")] +#endif + public static GameObject Position(this GameObject self, float x, float y, float z) + { + self.transform.position = new Vector3(x, y, z); + return self; + } + +#if UNITY_EDITOR + // v1 No.119 + [MethodAPI] + [APIDescriptionCN("component.transform.position = new Vector3(x,y,原来的 z)")] + [APIDescriptionEN("component.transform.position = new Vector3(x,y,origin z)")] + [APIExampleCode(@" +component.Position(0,0); +")] +#endif + public static T Position(this T selfComponent, float x, float y) where T : Component + { + var position = selfComponent.transform.position; + position.x = x; + position.y = y; + selfComponent.transform.position = position; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.120 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.position = new Vector3(x,y,原来的 z)")] + [APIDescriptionEN("gameObj.transform.position = new Vector3(x,y,origin z)")] + [APIExampleCode(@" +gameObj.Position(0,0,-10); +")] +#endif + public static GameObject Position(this GameObject selfComponent, float x, float y) + { + var position = selfComponent.transform.position; + position.x = x; + position.y = y; + selfComponent.transform.position = position; + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.121 + [MethodAPI] + [APIDescriptionCN("component.transform.position = Vector3.zero")] + [APIDescriptionEN("component.transform.position = Vector3.zero")] + [APIExampleCode(@" +component.PositionIdentity(); +")] +#endif + public static T PositionIdentity(this T selfComponent) where T : Component + { + selfComponent.transform.position = Vector3.zero; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.122 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.position = Vector3.zero")] + [APIDescriptionEN("gameObj.transform.position = Vector3.zero")] + [APIExampleCode(@" +gameObj.PositionIdentity(); +")] +#endif + public static GameObject PositionIdentity(this GameObject selfComponent) + { + selfComponent.transform.position = Vector3.zero; + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.121 + [MethodAPI] + [APIDescriptionCN("component.transform.position.x = x")] + [APIDescriptionEN("component.transform.position.x = x")] + [APIExampleCode(@" +component.PositionX(x); +")] +#endif + public static T PositionX(this T selfComponent, float x) where T : Component + { + var position = selfComponent.transform.position; + position.x = x; + selfComponent.transform.position = position; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.122 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.position.x = x")] + [APIDescriptionEN("gameObj.transform.position.x = x")] + [APIExampleCode(@" +gameObj.PositionX(x); +")] +#endif + public static GameObject PositionX(this GameObject self, float x) + { + var position = self.transform.position; + position.x = x; + self.transform.position = position; + return self; + } + + +#if UNITY_EDITOR + // v1 No.123 + [MethodAPI] + [APIDescriptionCN("将 positionX 的计算结果设置给 position.x")] + [APIDescriptionEN("Sets the positionX calculation to position.x")] + [APIExampleCode(@" +component.PositionX(x=>x * 5); +")] +#endif + public static T PositionX(this T selfComponent, Func xSetter) where T : Component + { + var position = selfComponent.transform.position; + position.x = xSetter(position.x); + selfComponent.transform.position = position; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.124 + [MethodAPI] + [APIDescriptionCN("将 positionX 的计算结果设置给 position.x")] + [APIDescriptionEN("Sets the positionX calculation to position.x")] + [APIExampleCode(@" +gameObj.PositionX(x=>x * 5); +")] +#endif + public static GameObject PositionX(this GameObject self, Func xSetter) + { + var position = self.transform.position; + position.x = xSetter(position.x); + self.transform.position = position; + return self; + } + + +#if UNITY_EDITOR + // v1 No.125 + [MethodAPI] + [APIDescriptionCN("component.transform.position.y = y")] + [APIDescriptionEN("component.transform.position.y = y")] + [APIExampleCode(@" +myScript.PositionY(10); +")] +#endif + public static T PositionY(this T selfComponent, float y) where T : Component + { + var position = selfComponent.transform.position; + position.y = y; + selfComponent.transform.position = position; + return selfComponent; + } +#if UNITY_EDITOR + // v1 No.126 + [MethodAPI] + [APIDescriptionCN("component.transform.position.y = y")] + [APIDescriptionEN("component.transform.position.y = y")] + [APIExampleCode(@" +myScript.PositionY(10); +")] +#endif + public static GameObject PositionY(this GameObject self, float y) + { + var position = self.transform.position; + position.y = y; + self.transform.position = position; + return self; + } + +#if UNITY_EDITOR + // v1 No.127 + [MethodAPI] + [APIDescriptionCN("将 positionY 的计算结果设置给 position.y")] + [APIDescriptionEN("Sets the positionY calculation to position.y")] + [APIExampleCode(@" +component.PositionY(y=>y * 5); +")] +#endif + public static T PositionY(this T selfComponent, Func ySetter) where T : Component + { + var position = selfComponent.transform.position; + position.y = ySetter(position.y); + selfComponent.transform.position = position; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.128 + [MethodAPI] + [APIDescriptionCN("将 positionY 的计算结果设置给 position.y")] + [APIDescriptionEN("Sets the positionY calculation to position.y")] + [APIExampleCode(@" +gameObj.PositionY(y=>y * 5); +")] +#endif + public static GameObject PositionY(this GameObject self, Func ySetter) + { + var position = self.transform.position; + position.y = ySetter(position.y); + self.transform.position = position; + return self; + } + +#if UNITY_EDITOR + // v1 No.129 + [MethodAPI] + [APIDescriptionCN("component.transform.position.z = z")] + [APIDescriptionEN("component.transform.position.z = z")] + [APIExampleCode(@" +component.PositionZ(10); +")] +#endif + public static T PositionZ(this T selfComponent, float z) where T : Component + { + var position = selfComponent.transform.position; + position.z = z; + selfComponent.transform.position = position; + return selfComponent; + } +#if UNITY_EDITOR + // v1 No.130 + [MethodAPI] + [APIDescriptionCN("component.transform.position.z = z")] + [APIDescriptionEN("component.transform.position.z = z")] + [APIExampleCode(@" +component.PositionZ(10); +")] +#endif + public static GameObject PositionZ(this GameObject self, float z) + { + var position = self.transform.position; + position.z = z; + self.transform.position = position; + return self; + } + +#if UNITY_EDITOR + // v1 No.131 + [MethodAPI] + [APIDescriptionCN("将 positionZ 的计算结果设置给 position.z")] + [APIDescriptionEN("Sets the positionZ calculation to position.z")] + [APIExampleCode(@" +component.PositionZ(z=>z * 5); +")] +#endif + public static T PositionZ(this T self, Func zSetter) where T : Component + { + var position = self.transform.position; + position.z = zSetter(position.z); + self.transform.position = position; + return self; + } + +#if UNITY_EDITOR + // v1 No.132 + [MethodAPI] + [APIDescriptionCN("将 positionZ 的计算结果设置给 position.z")] + [APIDescriptionEN("Sets the positionZ calculation to position.z")] + [APIExampleCode(@" +component.PositionZ(z=>z * 5); +")] +#endif + public static GameObject PositionZ(this GameObject self, Func zSetter) + { + var position = self.transform.position; + position.z = zSetter(position.z); + self.transform.position = position; + return self; + } + + +#if UNITY_EDITOR + // v1 No.133 + [MethodAPI] + [APIDescriptionCN("component.transform.rotation = Quaternion.identity")] + [APIDescriptionEN("component.transform.rotation = Quaternion.identity")] + [APIExampleCode(@" +component.RotationIdentity(); +")] +#endif + public static T RotationIdentity(this T selfComponent) where T : Component + { + selfComponent.transform.rotation = Quaternion.identity; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.134 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.rotation = Quaternion.identity")] + [APIDescriptionEN("gameObj.transform.rotation = Quaternion.identity")] + [APIExampleCode(@" +gameObj.RotationIdentity(); +")] +#endif + public static GameObject RotationIdentity(this GameObject selfComponent) + { + selfComponent.transform.rotation = Quaternion.identity; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.135 + [MethodAPI] + [APIDescriptionCN("component.transform.rotation = rotation")] + [APIDescriptionEN("component.transform.rotation = rotation")] + [APIExampleCode(@" +component.Rotation(Quaternion.identity); +")] +#endif + public static T Rotation(this T selfComponent, Quaternion rotation) where T : Component + { + selfComponent.transform.rotation = rotation; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.136 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.rotation = rotation")] + [APIDescriptionEN("gameObj.transform.rotation = rotation")] + [APIExampleCode(@" +gameObj.Rotation(Quaternion.identity); +")] +#endif + public static GameObject Rotation(this GameObject self, Quaternion rotation) + { + self.transform.rotation = rotation; + return self; + } + +#if UNITY_EDITOR + // v1 No.137 + [MethodAPI] + [APIDescriptionCN("return component.transform.rotation")] + [APIDescriptionEN("return component.transform.rotation")] + [APIExampleCode(@" +var rotation = myScript.Rotation(); +")] +#endif + public static Quaternion Rotation(this T selfComponent) where T : Component + { + return selfComponent.transform.rotation; + } + +#if UNITY_EDITOR + // v1 No.138 + [MethodAPI] + [APIDescriptionCN("return gameObj.transform.rotation")] + [APIDescriptionEN("return gameObj.transform.rotation")] + [APIExampleCode(@" +var rotation = gameObj.Rotation(); +")] +#endif + public static Quaternion Rotation(this GameObject self) + { + return self.transform.rotation; + } + + +#if UNITY_EDITOR + // v1 No.139 + [MethodAPI] + [APIDescriptionCN("return component.transform.lossyScale")] + [APIDescriptionEN("return component.transform.lossyScale")] + [APIExampleCode(@" +var scale = component.Scale(); +")] +#endif + public static Vector3 Scale(this T selfComponent) where T : Component + { + return selfComponent.transform.lossyScale; + } + +#if UNITY_EDITOR + // v1 No.140 + [MethodAPI] + [APIDescriptionCN("return gameObj.transform.lossyScale")] + [APIDescriptionEN("return gameObj.transform.lossyScale")] + [APIExampleCode(@" +var scale = gameObj.Scale(); +")] +#endif + public static Vector3 Scale(this GameObject selfComponent) + { + return selfComponent.transform.lossyScale; + } + + +#if UNITY_EDITOR + // v1 No.141 + [MethodAPI] + [APIDescriptionCN("Destroy 掉所有的子 GameObject")] + [APIDescriptionEN("destroy all child gameObjects")] + [APIExampleCode(@" +rootTransform.DestroyChildren(); +")] +#endif + public static T DestroyChildren(this T selfComponent) where T : Component + { + var childCount = selfComponent.transform.childCount; + + for (var i = childCount - 1; i >= 0; i--) + { + selfComponent.transform.GetChild(i).DestroyGameObjGracefully(); + } + + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.141.1 + [MethodAPI] + [APIDescriptionCN("根据条件 Destroy 掉所有的子 GameObject ")] + [APIDescriptionEN("destroy all child gameObjects if condition matched")] + [APIExampleCode(@" +rootTransform.DestroyChildrenWithCondition(child=>child != other); +")] +#endif + public static T DestroyChildrenWithCondition(this T selfComponent, Func condition) + where T : Component + { + var childCount = selfComponent.transform.childCount; + + for (var i = childCount - 1; i >= 0; i--) + { + var child = selfComponent.transform.GetChild(i); + if (condition(child)) + { + child.DestroyGameObjGracefully(); + } + } + + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.142 + [MethodAPI] + [APIDescriptionCN("Destroy 掉所有的子 GameObject")] + [APIDescriptionEN("destroy all child gameObjects")] + [APIExampleCode(@" +rootGameObj.DestroyChildren(); +")] +#endif + public static GameObject DestroyChildren(this GameObject selfGameObj) + { + var childCount = selfGameObj.transform.childCount; + + for (var i = childCount - 1; i >= 0; i--) + { + selfGameObj.transform.GetChild(i).DestroyGameObjGracefully(); + } + + return selfGameObj; + } + + +#if UNITY_EDITOR + // v1 No.143 + [MethodAPI] + [APIDescriptionCN("component.transform.SetAsLastSibling()")] + [APIDescriptionEN("component.transform.SetAsLastSibling()")] + [APIExampleCode(@" +myScript.AsLastSibling(); +")] +#endif + public static T AsLastSibling(this T selfComponent) where T : Component + { + selfComponent.transform.SetAsLastSibling(); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.144 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.SetAsLastSibling()")] + [APIDescriptionEN("gameObj.transform.SetAsLastSibling()")] + [APIExampleCode(@" +gameObj.AsLastSibling(); +")] +#endif + public static GameObject AsLastSibling(this GameObject self) + { + self.transform.SetAsLastSibling(); + return self; + } + +#if UNITY_EDITOR + // v1 No.145 + [MethodAPI] + [APIDescriptionCN("component.transform.SetAsFirstSibling()")] + [APIDescriptionEN("component.transform.SetAsFirstSibling()")] + [APIExampleCode(@" +component.AsFirstSibling(); +")] +#endif + public static T AsFirstSibling(this T selfComponent) where T : Component + { + selfComponent.transform.SetAsFirstSibling(); + return selfComponent; + } +#if UNITY_EDITOR + // v1 No.146 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.SetAsFirstSibling()")] + [APIDescriptionEN("gameObj.transform.SetAsFirstSibling()")] + [APIExampleCode(@" +gameObj.AsFirstSibling(); +")] +#endif + public static GameObject AsFirstSibling(this GameObject selfComponent) + { + selfComponent.transform.SetAsFirstSibling(); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.147 + [MethodAPI] + [APIDescriptionCN("component.transform.SetSiblingIndex(index)")] + [APIDescriptionEN("component.transform.SetSiblingIndex(index)")] + [APIExampleCode(@" +myScript.SiblingIndex(10); +")] +#endif + public static T SiblingIndex(this T selfComponent, int index) where T : Component + { + selfComponent.transform.SetSiblingIndex(index); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.148 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.SetSiblingIndex(index)")] + [APIDescriptionEN("gameObj.transform.SetSiblingIndex(index)")] + [APIExampleCode(@" +gameObj.SiblingIndex(10); +")] +#endif + public static GameObject SiblingIndex(this GameObject selfComponent, int index) + { + selfComponent.transform.SetSiblingIndex(index); + return selfComponent; + } + + public static Vector2 Position2D(this GameObject self) => new Vector2(self.transform.position.x, self.transform.position.y); + + public static Vector2 Position2D(this Component self) => new Vector2(self.transform.position.x, self.transform.position.y); + + public static GameObject Position2D(this GameObject self, Vector2 position) => self.Position(position.x, position.y); + + public static GameObject Position2D(this GameObject self, float x, float y) => self.Position(x, y); + + public static T Position2D(this T self, float x,float y) where T : Component => self.Position(x, y); + + public static T Position2D(this T self, Vector2 position) where T : Component => self.Position(position.x, position.y); + + public static Vector2 LocalPosition2D(this GameObject self) => new Vector2(self.transform.localPosition.x, self.transform.localPosition.y); + + public static Vector2 LocalPosition2D(this Component self) => new Vector2(self.transform.localPosition.x, self.transform.localPosition.y); + + public static GameObject LocalPosition2D(this GameObject self, Vector2 position) => self.LocalPosition(position.x, position.y); + + public static T LocalPosition2D(this T self, Vector2 position) where T : Component => self.LocalPosition(position.x, position.y); + + public static GameObject SyncPositionFrom(this GameObject self, GameObject from) => self.Position(from.Position()); + + public static T SyncPositionFrom(this T self, GameObject from) where T : Component => self.Position(from.Position()); + + public static GameObject SyncPositionFrom(this GameObject self, Component from) where T : Component => self.Position(from.Position()); + + public static T SyncPositionFrom(this T self, Component from) where T : Component => self.Position(from.Position()); + + public static GameObject SyncPosition2DFrom(this GameObject self, GameObject from) => + self.Position2D(from.Position2D()); + + public static T SyncPosition2DFrom(this T self, GameObject from) where T : Component => + self.Position2D(from.Position2D()); + + public static GameObject SyncPosition2DFrom(this GameObject self, Component from) => + self.Position2D(from.Position2D()); + + public static T SyncPosition2DFrom(this T self, Component from) where T : Component => + self.Position2D(from.Position2D()); + + + public static GameObject SyncPositionTo(this GameObject self, GameObject to) + { + to.Position(self.Position()); + return self; + } + + public static GameObject SyncPositionTo(this GameObject self, Component to) + { + to.Position(self.Position()); + return self; + } + + public static T SyncPositionTo(this T self, GameObject to) where T : Component + { + to.Position(self.Position()); + return self; + } + + public static T SyncPositionTo(this T self, Component to) where T : Component + { + to.Position(self.Position()); + return self; + } + + public static GameObject SyncPosition2DTo(this GameObject self, GameObject to) + { + to.Position2D(self.Position2D()); + return self; + } + + public static GameObject SyncPosition2DTo(this GameObject self, Component to) + { + to.Position2D(self.Position2D()); + return self; + } + + public static T SyncPosition2DTo(this T self, GameObject to) where T : Component + { + to.Position2D(self.Position2D()); + return self; + } + + public static T SyncPosition2DTo(this T self, Component to) where T : Component + { + to.Position2D(self.Position2D()); + return self; + } + + public static float PositionX(this GameObject self) => self.transform.position.x; + + public static float PositionX(this Component self) => self.transform.position.x; + + public static float PositionY(this GameObject self) => self.transform.position.y; + + public static float PositionY(this Component self) => self.transform.position.y; + + public static float PositionZ(this GameObject self) => self.transform.position.z; + + public static float PositionZ(this Component self) => self.transform.position.z; + + public static float LocalPositionX(this GameObject self) => self.transform.localPosition.x; + + public static float LocalPositionX(this Component self) => self.transform.localPosition.x; + + public static float LocalPositionY(this GameObject self) => self.transform.localPosition.y; + + public static float LocalPositionY(this Component self) => self.transform.localPosition.y; + + public static float LocalPositionZ(this GameObject self) => self.transform.localPosition.z; + + public static float LocalPositionZ(this Component self) => self.transform.localPosition.z; + public static Vector3 LocalEulerAngles(this GameObject self) => self.transform.localEulerAngles; + public static Vector3 LocalEulerAngles(this Component self) => self.transform.localEulerAngles; + + public static GameObject LocalEulerAngles(this GameObject self, Vector3 localEulerAngles) + { + self.transform.localEulerAngles = localEulerAngles; + return self; + } + + public static T LocalEulerAngles(this T self, Vector3 localEulerAngles) where T : Component + { + self.transform.localEulerAngles = localEulerAngles; + return self; + } + + public static GameObject LocalEulerAnglesZ(this GameObject self, float z) + { + self.LocalEulerAngles(self.LocalEulerAngles().Z(z)); + return self; + } + + public static T LocalEulerAnglesZ(this T self, float z) where T : Component + { + self.LocalEulerAngles(self.LocalEulerAngles().Z(z)); + return self; + } + + + public static Vector3 EulerAngles(this GameObject self) => self.transform.eulerAngles; + public static Vector3 EulerAngles(this Component self) => self.transform.eulerAngles; + + public static GameObject EulerAngles(this GameObject self, Vector3 eulerAngles) + { + self.transform.eulerAngles = eulerAngles; + return self; + } + + public static T EulerAngles(this T self, Vector3 eulerAngles) where T : Component + { + self.transform.eulerAngles = eulerAngles; + return self; + } + + public static GameObject EulerAnglesZ(this GameObject self, float z) + { + self.EulerAngles(self.EulerAngles().Z(z)); + return self; + } + + public static T EulerAnglesZ(this T self, float z) where T : Component + { + self.EulerAngles(self.EulerAngles().Z(z)); + return self; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs.meta new file mode 100644 index 0000000..b55f277 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a4b2070a7f53455e8ecc24c4d79c0a22 +timeCreated: 1647492399 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs new file mode 100644 index 0000000..c7b9d83 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs @@ -0,0 +1,52 @@ + +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.MonoBehaviour", 3)] + [APIDescriptionCN("MonoBehaviour 静态扩展")] + [APIDescriptionEN("MonoBehaviour extension")] +#endif + public static class UnityEngineMonoBehaviourExtension + { + public static void Example() + { + var gameObject = new GameObject(); + var component = gameObject.GetComponent(); + + component.Enable(); // component.enabled = true + component.Disable(); // component.enabled = false + } + +#if UNITY_EDITOR + // v1 No.149 + [MethodAPI] + [APIDescriptionCN("monoBehaviour.enable = true")] + [APIDescriptionEN("monoBehaviour.enable = true)")] + [APIExampleCode(@" +myScript.Enable(); +")] +#endif + public static T Enable(this T selfBehaviour, bool enable = true) where T : Behaviour + { + selfBehaviour.enabled = enable; + return selfBehaviour; + } + +#if UNITY_EDITOR + // v1 No.150 + [MethodAPI] + [APIDescriptionCN("monoBehaviour.enable = false")] + [APIDescriptionEN("monoBehaviour.enable = false")] + [APIExampleCode(@" +myScript.Disable(); +")] +#endif + public static T Disable(this T selfBehaviour) where T : Behaviour + { + selfBehaviour.enabled = false; + return selfBehaviour; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs.meta new file mode 100644 index 0000000..e30204b --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8de3fdd3a4964430b98cbc29c78e56f3 +timeCreated: 1647507236 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs new file mode 100644 index 0000000..de09d7f --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs @@ -0,0 +1,41 @@ + +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Camera", 4)] + [APIDescriptionCN("UnityEngine.Camera 静态扩展")] + [APIDescriptionEN("UnityEngine.Camera extension")] +#endif + public static class UnityEngineCameraExtension + { +#if UNITY_EDITOR + // v1 No.151 + [MethodAPI] + [APIDescriptionCN("截图")] + [APIDescriptionEN("captureScreen")] + [APIExampleCode(@" +Camera.main.CaptureCamera(new Rect(0, 0, Screen.width, Screen.height)); +")] +#endif + public static Texture2D CaptureCamera(this Camera camera, Rect rect) + { + var renderTexture = new RenderTexture(Screen.width, Screen.height, 0); + camera.targetTexture = renderTexture; + camera.Render(); + + RenderTexture.active = renderTexture; + + var screenShot = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGB24, false); + screenShot.ReadPixels(rect, 0, 0); + screenShot.Apply(); + + camera.targetTexture = null; + RenderTexture.active = null; + UnityEngine.Object.Destroy(renderTexture); + + return screenShot; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs.meta new file mode 100644 index 0000000..43e474a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 20fcd7ffbe7a4e6eb0a874c17e9d20ac +timeCreated: 1647507743 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs new file mode 100644 index 0000000..a0033f0 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs @@ -0,0 +1,29 @@ + +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Color", 5)] + [APIDescriptionCN("UnityEngine.Color 静态扩展")] + [APIDescriptionEN("UnityEngine.Color extension")] +#endif + public static class UnityEngineColorExtension + { +#if UNITY_EDITOR + // v1 No.152 + [MethodAPI] + [APIDescriptionCN("HTML string(#000000) 转 Color")] + [APIDescriptionEN("HTML string(like #000000)")] + [APIExampleCode(@" +var color = ""#C5563CFF"".HtmlStringToColor(); +Debug.Log(color);" + )] +#endif + public static Color HtmlStringToColor(this string htmlString) + { + var parseSucceed = ColorUtility.TryParseHtmlString(htmlString, out var retColor); + return parseSucceed ? retColor : Color.black; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs.meta new file mode 100644 index 0000000..514212e --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 373d8df28d2643bc823a4326ba396126 +timeCreated: 1647507950 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs new file mode 100644 index 0000000..635baaf --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs @@ -0,0 +1,54 @@ + +using UnityEngine.UI; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Graphic", 6)] + [APIDescriptionCN("UnityEngine.UI.Graphic 静态扩展")] + [APIDescriptionEN("UnityEngine.UI.Graphic extension")] +#endif + public static class UnityEngineUIGraphicExtension + { +#if UNITY_EDITOR + // v1 No.153 + [MethodAPI] + [APIDescriptionCN("设置 Graphic 的 alpha 值 ")] + [APIDescriptionEN("set graphic's alpha value")] + [APIExampleCode(@" +var gameObject = new GameObject(); +var image = gameObject.AddComponent(); +var rawImage = gameObject.AddComponent(); + + +image.ColorAlpha(1.0f); +rawImage.ColorAlpha(1.0f); +")] +#endif + public static T ColorAlpha(this T selfGraphic, float alpha) where T : Graphic + { + var color = selfGraphic.color; + color.a = alpha; + selfGraphic.color = color; + return selfGraphic; + } + +#if UNITY_EDITOR + // v1 No.154 + [MethodAPI] + [APIDescriptionCN("设置 image 的 fillAmount 值")] + [APIDescriptionEN("set image's fillAmount value")] + [APIExampleCode(@" +var gameObject = new GameObject(); +var image1 = gameObject.AddComponent(); + +image1.FillAmount(0.0f); +")] +#endif + public static Image FillAmount(this Image selfImage, float fillAmount) + { + selfImage.fillAmount = fillAmount; + return selfImage; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs.meta new file mode 100644 index 0000000..75c04b9 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ffdcff2f9c014047bc785723bc292477 +timeCreated: 1647508258 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs new file mode 100644 index 0000000..ba7535a --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs @@ -0,0 +1,321 @@ + +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Others", 8)] + [APIDescriptionCN("其他的一些静态扩展")] + [APIDescriptionEN("other extension")] +#endif + public static class UnityEngineOthersExtension + { +#if UNITY_EDITOR + // v1 No.155 + [MethodAPI] + [APIDescriptionCN("随机 List 中的一个元素")] + [APIDescriptionEN("get random item in a list")] + [APIExampleCode(@" +new List(){ 1,2,3 }.GetRandomItem(); +")] +#endif + public static T GetRandomItem(this List list) + { + return list[UnityEngine.Random.Range(0, list.Count)]; + } + +#if UNITY_EDITOR + // v1.0.34 + [MethodAPI] + [APIDescriptionCN("随机获取并删除 List 中的一个元素")] + [APIDescriptionEN("get and remove random item in a list")] + [APIExampleCode(@" +new List(){ 1,2,3 }.GetAndRemoveRandomItem(); +")] +#endif + public static T GetAndRemoveRandomItem(this List list) + { + var randomIndex = UnityEngine.Random.Range(0, list.Count); + var randomItem = list[randomIndex]; + list.RemoveAt(randomIndex); + return randomItem; + } + +#if UNITY_EDITOR + // v1 + [MethodAPI] + [APIDescriptionCN("为 SpriteRender 设置 alpha 值")] + [APIDescriptionEN("set SpriteRender's alpha value")] + [APIExampleCode(@" +mySprRender.Alpha(0.5f); +")] +#endif + public static SpriteRenderer Alpha(this SpriteRenderer self, float alpha) + { + var color = self.color; + color.a = alpha; + self.color = color; + return self; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("Mathf.Lerp")] + [APIDescriptionEN("Mathf.Lerp")] + [APIExampleCode(@" +var v = 0.5f.Lerp(0.1f,0.5f); +// v is 0.3f +")] +#endif + public static float Lerp(this float self, float a, float b) + { + return Mathf.Lerp(a, b, self); + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("Mathf.Abs")] + [APIDescriptionEN("Mathf.Abs")] + [APIExampleCode(@" +var absValue = -1.0f.Abs(); +// absValue is 1.0f +")] +#endif + public static float Abs(this float self) + { + return Mathf.Abs(self); + } + + public static float Abs(this int self) + { + return Mathf.Abs(self); + } + + +#if UNITY_EDITOR + // Added in v1.0.150 + [MethodAPI] + [APIDescriptionCN("Mathf.Exp")] + [APIDescriptionEN("Mathf.Exp")] + [APIExampleCode(@" +var expValue = 1.0f.Exp(); // Mathf.Exp(1.0f) +")] +#endif + public static float Exp(this float self) + { + return Mathf.Exp(self); + } + + public static float Exp(this int self) + { + return Mathf.Exp(self); + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("Mathf.Sign")] + [APIDescriptionEN("Mathf.Sign")] + [APIExampleCode(@" +var sign = -5.0f.Sign(); +// sign is 5.0f +")] +#endif + public static float Sign(this float self) + { + return Mathf.Sign(self); + } + + public static float Sign(this int self) + { + return Mathf.Sign(self); + } + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Cos")] + [APIDescriptionEN("Mathf.Cos")] + [APIExampleCode(@" +var cos = (90.0f * Mathf.Deg2Rad).Cos(); +// cos is 0f +")] +#endif + public static float Cos(this float self) + { + return Mathf.Cos(self); + } + + public static float Cos(this int self) + { + return Mathf.Cos(self); + } + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Sin")] + [APIDescriptionEN("Mathf.Sin")] + [APIExampleCode(@" +var sin = (90.0f * Mathf.Deg2Rad).Sin(); +// sin is 1f +")] +#endif + public static float Sin(this float self) + { + return Mathf.Sin(self); + } + + public static float Sin(this int self) + { + return Mathf.Sin(self); + } + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Cos(x * Mathf.Deg2Rad)")] + [APIDescriptionEN("Mathf.Cos(x * Mathf.Deg2Rad)")] + [APIExampleCode(@" +var cos = 90.0f.CosAngle(); +// cos is 0f +")] +#endif + public static float CosAngle(this float self) + { + return Mathf.Cos(self * Mathf.Deg2Rad); + } + + public static float CosAngle(this int self) + { + return Mathf.Cos(self * Mathf.Deg2Rad); + } + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Sin(x * Mathf.Deg2Rad)")] + [APIDescriptionEN("Mathf.Sin(x * Mathf.Deg2Rad)")] + [APIExampleCode(@" +var sin = 90.0f.SinAngle(); +// sin is 1f +")] +#endif + public static float SinAngle(this float self) + { + return Mathf.Sin(self * Mathf.Deg2Rad); + } + + public static float SinAngle(this int self) + { + return Mathf.Sin(self * Mathf.Deg2Rad); + } + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Deg2Rad")] + [APIDescriptionEN("Mathf.Deg2Rad")] + [APIExampleCode(@" +var radius = 90.0f.Deg2Rad(); +// radius is 1.57f +")] +#endif + public static float Deg2Rad(this float self) + { + return self * Mathf.Deg2Rad; + } + + public static float Deg2Rad(this int self) + { + return self * Mathf.Deg2Rad; + } + + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Rad2Deg")] + [APIDescriptionEN("Mathf.Rad2Deg")] + [APIExampleCode(@" +var degree = 1.57f.Rad2Deg(); +// degree is 90f +")] +#endif + public static float Rad2Deg(this float self) + { + return self * Mathf.Rad2Deg; + } + + public static float Rad2Deg(this int self) + { + return self * Mathf.Rad2Deg; + } + +#if UNITY_EDITOR + // Added in v1.0.129 + [MethodAPI] + [APIDescriptionCN("将欧拉角转换为方向向量(Vector2)")] + [APIDescriptionEN("Convert Degree To Direction(Vector2)")] + [APIExampleCode(@" +var direction = 90.AngleToDirection2D(); +// Vector2(1,0) +")] +#endif + + public static Vector2 AngleToDirection2D(this int self) + { + return new Vector2(self.CosAngle(), self.SinAngle()); + } + + public static Vector2 AngleToDirection2D(this float self) + { + return new Vector2(self.CosAngle(), self.SinAngle()); + } + +#if UNITY_EDITOR + // Added in v1.0.129 + [MethodAPI] + [APIDescriptionCN("将方向(Vector2)转换为欧拉角")] + [APIDescriptionEN("Convert Direction To Degrees")] + [APIExampleCode(@" +var direction = Vector2.right.ToAngle(); +// Vector2(1,0) +")] +#endif + public static float ToAngle(this Vector2 self) + { + return Mathf.Atan2(self.y, self.x).Rad2Deg(); + } + } + +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Random", 7)] + [APIDescriptionCN("针对随机做的一些封装")] + [APIDescriptionEN("wrapper for random")] +#endif + public static class RandomUtility + { +#if UNITY_EDITOR + // v1 + [MethodAPI] + [APIDescriptionCN("随机选择")] + [APIDescriptionEN("RandomChoose")] + [APIExampleCode(@" +var result = RandomUtility.Choose(1,1,1,2,2,2,2,3,3); + +if (result == 3) +{ + // todo ... +} +")] +#endif + public static T Choose(params T[] args) + { + return args[UnityEngine.Random.Range(0, args.Length)]; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs.meta new file mode 100644 index 0000000..1f4ce85 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 095d03eec50f4f77828198360c9193d3 +timeCreated: 1647508997 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs new file mode 100644 index 0000000..bfc5656 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs @@ -0,0 +1,313 @@ + +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Vector2/3", 8)] + [APIDescriptionCN("针对 Vector2/Vector3 封装的函数")] + [APIDescriptionEN("wrapper function for Vector2/Vector3")] + [APIExampleCode(@" + gameObjA.DirectionFrom(gameObjB); + myComponentA.DirectionFrom(gameObjB); + gameObjA.DirectionFrom(myComponentB); + myComponentA.DirectionFrom(myComponentB); + + // also support DirectionTo/ NormalizedDirectionFrom /NormalizedDirectionTo +")] +#endif + public static class UnityEngineVectorExtension + { + #if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("to.transform.position - self.transform.position")] + [APIDescriptionEN("to.transform.position - self.transform.position")] + [APIExampleCode(@" +gameObj/otherComponent.DirectionTo(otherGameObj/otherComponent) +")] +#endif + public static Vector3 DirectionTo(this Component self, Component to) => + to.transform.position - self.transform.position; + + public static Vector3 DirectionTo(this GameObject self, GameObject to) => + to.transform.position - self.transform.position; + + public static Vector3 DirectionTo(this Component self, GameObject to) => + to.transform.position - self.transform.position; + + public static Vector3 DirectionTo(this GameObject self, Component to) => + to.transform.position - self.transform.position; + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("self.transform.position - from.transform.position")] + [APIDescriptionEN("self.transform.position - from.transform.position")] + [APIExampleCode(@" +gameObj/otherComponent.DirectionFrom(otherGameObj/otherComponent) +")] +#endif + public static Vector3 DirectionFrom(this Component self, Component from) => + self.transform.position - from.transform.position; + + public static Vector3 DirectionFrom(this GameObject self, GameObject from) => + self.transform.position - from.transform.position; + + public static Vector3 DirectionFrom(this GameObject self, Component from) => + self.transform.position - from.transform.position; + + public static Vector3 DirectionFrom(this Component self, GameObject from) => + self.transform.position - from.transform.position; + + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("(to.transform.position - self.transform.position).normalized")] + [APIDescriptionEN("(to.transform.position - self.transform.position).normalized")] + [APIExampleCode(@" +gameObj/otherComponent.NormalizedDirectionTo(otherGameObj/otherComponent) +")] +#endif + public static Vector3 NormalizedDirectionTo(this Component self, Component to) => + self.DirectionTo(to).normalized; + + public static Vector3 NormalizedDirectionTo(this GameObject self, GameObject to) => + self.DirectionTo(to).normalized; + + public static Vector3 NormalizedDirectionTo(this Component self, GameObject to) => + self.DirectionTo(to).normalized; + + public static Vector3 NormalizedDirectionTo(this GameObject self, Component to) => + self.DirectionTo(to).normalized; + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("(self.transform.position - from.transform.position).normalized")] + [APIDescriptionEN("(self.transform.position - from.transform.position).normalized")] + [APIExampleCode(@" +gameObj/otherComponent.NormalizedDirectionTo(otherGameObj/otherComponent) +")] +#endif + public static Vector3 NormalizedDirectionFrom(this Component self, Component from) => + self.DirectionFrom(from).normalized; + + public static Vector3 NormalizedDirectionFrom(this GameObject self, GameObject from) => + self.DirectionFrom(from).normalized; + + public static Vector3 NormalizedDirectionFrom(this GameObject self, Component from) => + self.DirectionFrom(from).normalized; + + public static Vector3 NormalizedDirectionFrom(this Component self, GameObject from) => + self.DirectionFrom(from).normalized; + + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("(Vector2)(to.transform.position - self.transform.position)")] + [APIDescriptionEN("(Vector2)(to.transform.position - self.transform.position)")] + [APIExampleCode(@" +gameObj/otherComponent.Direction2DTo(otherGameObj/otherComponent) +")] +#endif + public static Vector2 Direction2DTo(this Component self, Component to) => + to.transform.position - self.transform.position; + + public static Vector2 Direction2DTo(this GameObject self, GameObject to) => + to.transform.position - self.transform.position; + + public static Vector2 Direction2DTo(this Component self, GameObject to) => + to.transform.position - self.transform.position; + + public static Vector2 Direction2DTo(this GameObject self, Component to) => + to.transform.position - self.transform.position; + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("(Vector2)(self.transform.position - from.transform.position)")] + [APIDescriptionEN("(Vector2)(self.transform.position - from.transform.position)")] + [APIExampleCode(@" +gameObj/otherComponent.Direction2DFrom(otherGameObj/otherComponent) +")] +#endif + public static Vector2 Direction2DFrom(this Component self, Component from) => + self.transform.position - from.transform.position; + + public static Vector2 Direction2DFrom(this GameObject self, GameObject from) => + self.transform.position - from.transform.position; + + public static Vector2 Direction2DFrom(this GameObject self, Component from) => + self.transform.position - from.transform.position; + + public static Vector2 Direction2DFrom(this Component self, GameObject from) => + self.transform.position - from.transform.position; + + + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("((Vector2)(to.transform.position - self.transform.position)).normalized")] + [APIDescriptionEN("((Vector2)(to.transform.position - self.transform.position)).normalized")] + [APIExampleCode(@" +gameObj/otherComponent.NormalizedDirection2DTo(otherGameObj/otherComponent) +")] +#endif + public static Vector2 NormalizedDirection2DTo(this Component self, Component to) => + self.Direction2DTo(to).normalized; + + public static Vector2 NormalizedDirection2DTo(this GameObject self, GameObject to) => + self.Direction2DTo(to).normalized; + + public static Vector2 NormalizedDirection2DTo(this Component self, GameObject to) => + self.Direction2DTo(to).normalized; + + public static Vector2 NormalizedDirection2DTo(this GameObject self, Component to) => + self.Direction2DTo(to).normalized; + + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("((Vector2)(self.transform.position - from.transform.position)).normalized")] + [APIDescriptionEN("((Vector2)(self.transform.position - from.transform.position)).normalized")] + [APIExampleCode(@" +gameObj/otherComponent.NormalizedDirection2DFrom(otherGameObj/otherComponent) +")] +#endif + public static Vector2 NormalizedDirection2DFrom(this Component self, Component from) => + self.Direction2DFrom(from).normalized; + + public static Vector2 NormalizedDirection2DFrom(this GameObject self, GameObject from) => + self.Direction2DFrom(from).normalized; + + public static Vector2 NormalizedDirection2DFrom(this GameObject self, Component from) => + self.Direction2DFrom(from).normalized; + + public static Vector2 NormalizedDirection2DFrom(this Component self, GameObject from) => + self.Direction2DFrom(from).normalized; + + + public static Vector2 ToVector2(this Vector3 self) => new Vector2(self.x, self.y); + + public static Vector3 ToVector3(this Vector2 self, float z = 0) + { + return new Vector3(self.x, self.y, z); + } + + public static Vector3 X(this Vector3 self,float x) + { + self.x = x; + return self; + } + + public static Vector3 Y(this Vector3 self,float y) + { + self.y = y; + return self; + } + + public static Vector3 Z(this Vector3 self,float z) + { + self.z = z; + return self; + } + + + public static Vector2 X(this Vector2 self,float x) + { + self.x = x; + return self; + } + + public static Vector2 Y(this Vector2 self,float y) + { + self.y = y; + return self; + } + + public static float Distance(this GameObject self, GameObject other) + { + return Vector3.Distance(self.Position(), other.Position()); + } + + public static float Distance(this Component self, GameObject other) + { + return Vector3.Distance(self.Position(), other.Position()); + } + + public static float Distance(this GameObject self, Component other) + { + return Vector3.Distance(self.Position(), other.Position()); + } + + public static float Distance(this Component self, Component other) + { + return Vector3.Distance(self.Position(), other.Position()); + } + + public static float Distance2D(this GameObject self, GameObject other) + { + return Vector2.Distance(self.Position2D(), other.Position2D()); + } + + public static float Distance2D(this Component self, GameObject other) + { + return Vector2.Distance(self.Position2D(), other.Position2D()); + } + + public static float Distance2D(this GameObject self, Component other) + { + return Vector2.Distance(self.Position2D(), other.Position2D()); + } + + public static float Distance2D(this Component self, Component other) + { + return Vector2.Distance(self.Position2D(), other.Position2D()); + } + + public static float LocalDistance(this GameObject self, GameObject other) + { + return Vector3.Distance(self.LocalPosition(), other.LocalPosition()); + } + + public static float LocalDistance(this Component self, GameObject other) + { + return Vector3.Distance(self.LocalPosition(), other.LocalPosition()); + } + + public static float LocalDistance(this GameObject self, Component other) + { + return Vector3.Distance(self.LocalPosition(), other.LocalPosition()); + } + + public static float LocalDistance(this Component self, Component other) + { + return Vector3.Distance(self.LocalPosition(), other.LocalPosition()); + } + + public static float LocalDistance2D(this GameObject self, GameObject other) + { + return Vector2.Distance(self.LocalPosition2D(), other.LocalPosition2D()); + } + + public static float LocalDistance2D(this Component self, GameObject other) + { + return Vector2.Distance(self.LocalPosition2D(), other.LocalPosition2D()); + } + + public static float LocalDistance2D(this GameObject self, Component other) + { + return Vector2.Distance(self.LocalPosition2D(), other.LocalPosition2D()); + } + + public static float LocalDistance2D(this Component self, Component other) + { + return Vector2.Distance(self.LocalPosition2D(), other.LocalPosition2D()); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs.meta new file mode 100644 index 0000000..d85086e --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fb2654f2feb44ad6b264c2d6a8c8a2de +timeCreated: 1693400243 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs new file mode 100644 index 0000000..d284f23 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs @@ -0,0 +1,30 @@ + +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.RectTransform", 9)] + [APIDescriptionCN("针对 RectTransform 封装的函数")] + [APIDescriptionEN("wrapper function for RectTransform")] +#endif + public static class UnityEngineRectTransformExtension + { +#if UNITY_EDITOR + // v1.0.167 + [MethodAPI] + [APIDescriptionCN("设置 rectTransform.anchoredPosition.y 值")] + [APIDescriptionEN("set rectTransform.anchoredPosition.y value")] + [APIExampleCode(@" +text.rectTransform.AnchoredPositionY(5); +")] +#endif + public static RectTransform AnchoredPositionY(this RectTransform selfRectTrans, float anchoredPositionY) + { + var anchorPos = selfRectTrans.anchoredPosition; + anchorPos.y = anchoredPositionY; + selfRectTrans.anchoredPosition = anchorPos; + return selfRectTrans; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs.meta new file mode 100644 index 0000000..3558559 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 76b337d0ece04cab994eb2f50c6bd9aa +timeCreated: 1733116027 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp.meta new file mode 100644 index 0000000..69ccaef --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 820be0af14a349f38700b599aa5252e3 +timeCreated: 1647422394 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs new file mode 100644 index 0000000..befd2c4 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs @@ -0,0 +1,103 @@ + +using System; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("01.FluentAPI.CSharp", "System.Object", 0)] + [APIDescriptionCN("针对 System.Object 提供的链式扩展,理论上任何对象都可以使用")] + [APIDescriptionEN("The chain extension provided by System.object can theoretically be used by any Object")] +#endif + public static class SystemObjectExtension + { +#if UNITY_EDITOR + // v1 No.1 + [MethodAPI] + [APIDescriptionCN("将自己传到 Action 委托中")] + [APIDescriptionEN("apply self to the Action delegate")] + [APIExampleCode(@" +new GameObject() + .Self(gameObj=>gameObj.name = ""Enemy"") + .Self(gameObj=>{ + Debug.Log(gameObj.name); + });" + )] +#endif + public static T Self(this T self, Action onDo) + { + onDo?.Invoke(self); + return self; + } + +#if UNITY_EDITOR + // v1 No.1.1 + [MethodAPI] + [APIDescriptionCN("将自己传到 Func 委托中,然后返回自己")] + [APIDescriptionEN("apply self to the Func delegate")] + [APIExampleCode(@" +new GameObject() + .Self(gameObj=>gameObj.name = ""Enemy"") + .Self(gameObj=>{ + Debug.Log(gameObj.name); + });" + )] +#endif + public static T Self(this T self, Func onDo) + { + return onDo.Invoke(self); + } + + +#if UNITY_EDITOR + // v1 No.2 + [MethodAPI] + [APIDescriptionCN("判断是否为空")] + [APIDescriptionEN("Check Is Null,return true or false")] + [APIExampleCode(@" +var simpleObject = new object(); + +if (simpleObject.IsNull()) // simpleObject == null +{ + // do sth +}")] +#endif + public static bool IsNull(this T selfObj) where T : class + { + return null == selfObj; + } + +#if UNITY_EDITOR + // v1 No.3 + [MethodAPI] + [APIDescriptionCN("判断不是为空")] + [APIDescriptionEN("Check Is Not Null,return true or false")] + [APIExampleCode(@" +var simpleObject = new object(); + +if (simpleObject.IsNotNull()) // simpleObject != null +{ + // do sth +}")] +#endif + public static bool IsNotNull(this T selfObj) where T : class + { + return null != selfObj; + } + +#if UNITY_EDITOR + // v1 No.36 + [MethodAPI] + [APIDescriptionCN("转型")] + [APIDescriptionEN("cast")] + [APIExampleCode(@" +int a = 10; +Debug.Log(a.As()) +// 10 +")] +#endif + public static T As(this object selfObj) where T : class + { + return selfObj as T; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs.meta new file mode 100644 index 0000000..73db8e8 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8ef786a6b2b044b69fcc6abb9e695619 +timeCreated: 1647422404 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs new file mode 100644 index 0000000..5570ca5 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs @@ -0,0 +1,275 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("01.FluentAPI.CSharp", "System.String", 1)] + [APIDescriptionCN("针对 System.String 提供的链式扩展,理论上任何集合都可以使用")] + [APIDescriptionEN("The chain extension provided by System.Collections can theoretically be used by any collection")] +#endif + public static class SystemStringExtension + { +#if UNITY_EDITOR + // v1 No.18 + [MethodAPI] + [APIDescriptionCN("检测是否为空或 Empty")] + [APIDescriptionEN("Check Whether string is null or empty")] + [APIExampleCode(@" +Debug.Log(string.Empty.IsNullOrEmpty()); +// true + ")] +#endif + public static bool IsNullOrEmpty(this string selfStr) + { + return string.IsNullOrEmpty(selfStr); + } + + +#if UNITY_EDITOR + // v1 No.19 + [MethodAPI] + [APIDescriptionCN("检测是否为非空且非Empty")] + [APIDescriptionEN("Checks both not null and non-empty")] + [APIExampleCode(@" +Debug.Log(""Hello"".IsNotNullAndEmpty()); +// true + ")] +#endif + public static bool IsNotNullAndEmpty(this string selfStr) + { + return !string.IsNullOrEmpty(selfStr); + } + +#if UNITY_EDITOR + // v1 No.20 + [MethodAPI] + [APIDescriptionCN("去掉两端空格后,检测是否为空或 Empty")] + [APIDescriptionEN("Check if it is Empty or Empty after removing whitespace from both sides")] + [APIExampleCode(@" +Debug.Log("" "".IsTrimNullOrEmpty()); +// true + ")] +#endif + public static bool IsTrimNullOrEmpty(this string selfStr) + { + return selfStr == null || string.IsNullOrEmpty(selfStr.Trim()); + } + + /// + /// Check Whether string trim is null or empty + /// + /// + /// +#if UNITY_EDITOR + // v1 No.21 + [MethodAPI] + [APIDescriptionCN("去掉两端空格后,检测是否为非 null 且非 Empty")] + [APIDescriptionEN("After removing whitespace from both sides, check whether it is non-null and non-empty")] + [APIExampleCode(@" +Debug.Log("" 123 "".IsTrimNotNullAndEmpty()); +// true + ")] +#endif + public static bool IsTrimNotNullAndEmpty(this string selfStr) + { + return selfStr != null && !string.IsNullOrEmpty(selfStr.Trim()); + } + + + /// + /// 缓存 + /// + private static readonly char[] mCachedSplitCharArray = { '.' }; + +#if UNITY_EDITOR + // v1 No.22 + [MethodAPI] + [APIDescriptionCN("字符串分割")] + [APIDescriptionEN("String splitting")] + [APIExampleCode(@" +""1.2.3.4.5"".Split('.').ForEach(str=>Debug.Log(str)); +// 1 2 3 4 5 + ")] +#endif + public static string[] Split(this string selfStr, char splitSymbol) + { + mCachedSplitCharArray[0] = splitSymbol; + return selfStr.Split(mCachedSplitCharArray); + } + +#if UNITY_EDITOR + // v1 No.23 + [MethodAPI] + [APIDescriptionCN("格式化字符串填充参数")] + [APIDescriptionEN("The format string populates the parameters")] + [APIExampleCode(@" + +var newStr = ""{0},{1}"".FillFormat(1,2); +Debug.Log(newStr); +// 1,2 + ")] +#endif + public static string FillFormat(this string selfStr, params object[] args) + { + return string.Format(selfStr, args); + } + +#if UNITY_EDITOR + // v1 No.24 + [MethodAPI] + [APIDescriptionCN("返回包含此字符串的 StringBuilder")] + [APIDescriptionEN("Returns a StringBuilder containing this string")] + [APIExampleCode(@" +var builder = ""Hello"".Builder(); +builder.Append("" QF""); +Debug.Log(builder.ToString()); +// Hello QF + ")] +#endif + public static StringBuilder Builder(this string selfStr) + { + return new StringBuilder(selfStr); + } + +#if UNITY_EDITOR + // v1 No.25 + [MethodAPI] + [APIDescriptionCN("StringBuilder 添加前缀")] + [APIDescriptionEN("StringBuilder insert prefix string")] + [APIExampleCode(@" +var builder = ""I'm liangxie"".Builder().AddPrefix(""Hi!"") ; +Debug.Log(builder.ToString()); +// Hi!I'm liangxie + ")] +#endif + public static StringBuilder AddPrefix(this StringBuilder self, string prefixString) + { + self.Insert(0, prefixString); + return self; + } + + +#if UNITY_EDITOR + // v1 No.26 + [MethodAPI] + [APIDescriptionCN("字符串解析成 Int")] + [APIDescriptionEN("parse string to int")] + [APIExampleCode(@" +var number = ""123456"".ToInt(); +Debug.Log(number); +// 123456 +// notice unsafe +// 不安全 + ")] +#endif + public static int ToInt(this string selfStr, int defaulValue = 0) + { + var retValue = defaulValue; + return int.TryParse(selfStr, out retValue) ? retValue : defaulValue; + } + + public static long ToLong(this string self, long defaultValue = 0) + { + var retValue = defaultValue; + return long.TryParse(self, out retValue) ? retValue : defaultValue; + } + +#if UNITY_EDITOR + // v1 No.27 + [MethodAPI] + [APIDescriptionCN("字符串解析成 Int")] + [APIDescriptionEN("parse string to int")] + [APIExampleCode(@" +DateTime.Now.ToString().ToDataTime(); + ")] +#endif + public static DateTime ToDateTime(this string selfStr, DateTime defaultValue = default(DateTime)) + { + return DateTime.TryParse(selfStr, out var retValue) ? retValue : defaultValue; + } + + +#if UNITY_EDITOR + // v1 No.28 + [MethodAPI] + [APIDescriptionCN("字符串解析成 float")] + [APIDescriptionEN("parse string to float")] + [APIExampleCode(@" +var number = ""123456f"".ToInt(); +Debug.Log(number); +// 123456 +// notice unsafe +// 不安全 + ")] +#endif + public static float ToFloat(this string selfStr, float defaultValue = 0) + { + return float.TryParse(selfStr, out var retValue) ? retValue : defaultValue; + } + +#if UNITY_EDITOR + // v1 No.29 + [MethodAPI] + [APIDescriptionCN("是否存在中文字符")] + [APIDescriptionEN("check string contains chinese or not")] + [APIExampleCode(@" +Debug.Log(""你好"".HasChinese()); +// true +")] +#endif + public static bool HasChinese(this string input) + { + return Regex.IsMatch(input, @"[\u4e00-\u9fa5]"); + } + +#if UNITY_EDITOR + // v1 No.30 + [MethodAPI] + [APIDescriptionCN("是否存在空格")] + [APIDescriptionEN("check string contains space or not")] + [APIExampleCode(@" +Debug.Log(""你好 "".HasSpace()); +// true +")] +#endif + public static bool HasSpace(this string input) + { + return input.Contains(" "); + } + +#if UNITY_EDITOR + // v1 No.31 + [MethodAPI] + [APIDescriptionCN("remove string")] + [APIDescriptionEN("check string contains space or not")] + [APIExampleCode(@" +Debug.Log(""Hello World "".RemoveString(""Hello"","" "")); +// World +")] +#endif + public static string RemoveString(this string str, params string[] targets) + { + return targets.Aggregate(str, (current, t) => current.Replace(t, string.Empty)); + } + +#if UNITY_EDITOR + // v1.0.39 + [MethodAPI] + [APIDescriptionCN("join string")] + [APIDescriptionEN("join string")] + [APIExampleCode(@" +Debug.Log(new List() { ""1"",""2"",""3""}.StringJoin("","")); +// 1,2,3 +")] +#endif + public static string StringJoin(this IEnumerable self, string separator) + { + return string.Join(separator, self); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs.meta new file mode 100644 index 0000000..eba9f9d --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 16f9643181cd400085f8615855718a05 +timeCreated: 1647445231 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs new file mode 100644 index 0000000..1dac716 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs @@ -0,0 +1,183 @@ + +using System.IO; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("01.FluentAPI.CSharp", "System.IO", 2)] + [APIDescriptionCN("针对 System.IO 提供的链式扩展,主要是文件和文件夹的一些 IO 操作")] + [APIDescriptionEN("IO chain extension for system. IO, mainly file and folder IO operations")] +#endif + public static class SystemIOExtension + { +#if UNITY_EDITOR + // v1 No.10 + [MethodAPI] + [APIDescriptionCN("创建文件夹,如果存在则不创建")] + [APIDescriptionEN("Create folder or not if it exists")] + [APIExampleCode(@" +var testDir = ""Assets/TestFolder""; +testDir.CreateDirIfNotExists();" + )] +#endif + public static string CreateDirIfNotExists(this string dirFullPath) + { + if (!Directory.Exists(dirFullPath)) + { + Directory.CreateDirectory(dirFullPath); + } + + return dirFullPath; + } + +#if UNITY_EDITOR + // v1 No.11 + [MethodAPI] + [APIDescriptionCN("删除文件夹,如果存在")] + [APIDescriptionEN("Delete the folder if it exists")] + [APIExampleCode(@" +var testDir =""Assets/TestFolder""; +testDir.DeleteDirIfExists(); + ")] +#endif + public static void DeleteDirIfExists(this string dirFullPath) + { + if (Directory.Exists(dirFullPath)) + { + Directory.Delete(dirFullPath, true); + } + } + +#if UNITY_EDITOR + // v1 No.12 + [MethodAPI] + [APIDescriptionCN("清空 Dir(保留目录),如果存在")] + [APIDescriptionEN("Clear Dir (reserved directory), if exists")] + [APIExampleCode(@" +var testDir = ""Assets/TestFolder""; +testDir.EmptyDirIfExists(); + ")] +#endif + public static void EmptyDirIfExists(this string dirFullPath) + { + if (Directory.Exists(dirFullPath)) + { + Directory.Delete(dirFullPath, true); + } + + Directory.CreateDirectory(dirFullPath); + } + +#if UNITY_EDITOR + // v1 No.13 + [MethodAPI] + [APIDescriptionCN("删除文件 如果存在")] + [APIDescriptionEN("Delete the file if it exists")] + [APIExampleCode(@" +var filePath = ""Assets/Test.txt""; +File.Create(""Assets/Test""); +filePath.DeleteFileIfExists(); + ")] +#endif + public static bool DeleteFileIfExists(this string fileFullPath) + { + if (File.Exists(fileFullPath)) + { + File.Delete(fileFullPath); + return true; + } + + return false; + } + + +#if UNITY_EDITOR + // v1 No.14 + [MethodAPI] + [APIDescriptionCN("合并路径")] + [APIDescriptionEN("Combine path")] + [APIExampleCode(@" +var path = Application.dataPath.CombinePath(""Resources""); +Debug.Log(Path) +// projectPath/Assets/Resources + ")] +#endif + public static string CombinePath(this string selfPath, string toCombinePath) + { + return Path.Combine(selfPath, toCombinePath); + } + + +#if UNITY_EDITOR + // v1 No.15 + [MethodAPI] + [APIDescriptionCN("根据路径获取文件名")] + [APIDescriptionEN("get file name by path")] + [APIExampleCode(@" +var fileName =""/abc/def/b.txt"".GetFileName(); +Debug.Log(fileName0); +// b.txt + ")] +#endif + public static string GetFileName(this string filePath) + { + return Path.GetFileName(filePath); + } + +#if UNITY_EDITOR + // v1 No.16 + [MethodAPI] + [APIDescriptionCN("根据路径获取文件名,不包含文件扩展名")] + [APIDescriptionEN("Get the file name based on the path, excluding the file name extension")] + [APIExampleCode(@" +var fileName =""/abc/def/b.txt"".GetFileNameWithoutExtend(); +Debug.Log(fileName0); +// b + ")] +#endif + + public static string GetFileNameWithoutExtend(this string filePath) + { + return Path.GetFileNameWithoutExtension(filePath); + } + +#if UNITY_EDITOR + // v1 No.17 + [MethodAPI] + [APIDescriptionCN("根据路径获取文件扩展名")] + [APIDescriptionEN("Get the file extension based on the path")] + [APIExampleCode(@" +var fileName =""/abc/def/b.txt"".GetFileExtendName(); +Debug.Log(fileName0); +// .txt + ")] +#endif + public static string GetFileExtendName(this string filePath) + { + return Path.GetExtension(filePath); + } + + +#if UNITY_EDITOR + // v1 No.156 + [MethodAPI] + [APIDescriptionCN("获取文件夹路径")] + [APIDescriptionEN("get filePath's folder path")] + [APIExampleCode(@" +var folderPath =""/abc/def/b.txt"".GetFolderPath(); +Debug.Log(fileName0); +// /abs/def + ")] +#endif + public static string GetFolderPath(this string path) + { + if (string.IsNullOrEmpty(path)) + { + return string.Empty; + } + + return Path.GetDirectoryName(path); + } + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs.meta new file mode 100644 index 0000000..d682024 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 214fbbb4fd6f426f8e9867263025a775 +timeCreated: 1647438572 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs new file mode 100644 index 0000000..a756073 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs @@ -0,0 +1,188 @@ + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("01.FluentAPI.CSharp", "System.Collections", 3)] + [APIDescriptionCN("针对 System.Collections 提供的链式扩展,理论上任何集合都可以使用")] + [APIDescriptionEN("The chain extension provided by System.Collections can theoretically be used by any collection")] +#endif + public static class CollectionsExtension + { +#if UNITY_EDITOR + // v1 No.4 + [MethodAPI] + [APIDescriptionCN("遍历 IEnumerable")] + [APIDescriptionEN("ForEach for IEnumerable")] + [APIExampleCode(@" +IEnumerable testIEnumerable = new List { 1, 2, 3 }; +testIEnumerable.ForEach(number => Debug.Log(number)); +// output +// 1 +// 2 +// 3 +new Dictionary() +{ + {""name"",""liangxie""}, + {""company"",""liangxiegame"" } +} +.ForEach(keyValue => Debug.LogFormat(""key:{0},value:{1}"", keyValue.Key, keyValue.Value)); +// key:name,value:liangxie +// key:company,value:liangxiegame")] +#endif + public static IEnumerable ForEach(this IEnumerable self, Action action) + { + foreach (var item in self) + { + action(item); + } + + return self; + } + +#if UNITY_EDITOR + // v1 No.5 + [MethodAPI] + [APIDescriptionCN("List 倒序遍历")] + [APIDescriptionEN("Reverse ForEach for List")] + [APIExampleCode(@" +var testList = new List { 1, 2, 3 }; +testList.ForEachReverse(number => number.LogInfo()); +// 3 2 1 +")] +#endif + public static List ForEachReverse(this List selfList, Action action) + { + for (var i = selfList.Count - 1; i >= 0; --i) + action(selfList[i]); + + return selfList; + } + + +#if UNITY_EDITOR + // v1 No.6 + [MethodAPI] + [APIDescriptionCN("遍历 List (可获得索引)")] + [APIDescriptionEN("foreach List (can get index)")] + [APIExampleCode(@" +var testList = new List {""a"", ""b"", ""c"" }; +testList.Foreach((c,index)=>Debug.Log(index)); +// 1, 2, 3, +")] +#endif + public static void ForEach(this List list, Action action) + { + for (var i = 0; i < list.Count; i++) + { + action(i, list[i]); + } + } + + +#if UNITY_EDITOR + // v1 No.7 + [MethodAPI] + [APIDescriptionCN("遍历字典")] + [APIDescriptionEN("ForEach Dictionary")] + [APIExampleCode(@" +var infos = new Dictionary {{""name"",""liangxie""},{""age"",""18""}}; +infos.ForEach((key,value)=> Debug.LogFormat(""{0}:{1}"",key,value); +// name:liangxie +// age:18 +")] +#endif + public static void ForEach(this Dictionary dict, Action action) + { + var dictE = dict.GetEnumerator(); + + while (dictE.MoveNext()) + { + var current = dictE.Current; + action(current.Key, current.Value); + } + + dictE.Dispose(); + } + + +#if UNITY_EDITOR + // v1 No.8 + [MethodAPI] + [APIDescriptionCN("合并字典")] + [APIDescriptionEN("Merge Dictionaries")] + [APIExampleCode(@" +var dictionary1 = new Dictionary { { ""1"", ""2"" } }; +var dictionary2 = new Dictionary { { ""3"", ""4"" } }; +var dictionary3 = dictionary1.Merge(dictionary2); +dictionary3.ForEach(pair => Debug.LogFormat(""{0}:{1}"", pair.Key, pair.Value)); +// 1:2 +// 3:4 + +// notice: duplicate keys are not supported. +// 注意:不支持重复的 key。 +")] +#endif + public static Dictionary Merge(this Dictionary dictionary, + params Dictionary[] dictionaries) + { + return dictionaries.Aggregate(dictionary, + (current, dict) => current.Union(dict).ToDictionary(kv => kv.Key, kv => kv.Value)); + } + +#if UNITY_EDITOR + // v1 No.9 + [MethodAPI] + [APIDescriptionCN("字典添加新的字典")] + [APIDescriptionEN("Dictionary Adds a new dictionary")] + [APIExampleCode(@" +var dictionary1 = new Dictionary { { ""1"", ""2"" } }; +var dictionary2 = new Dictionary { { ""1"", ""4"" } }; +var dictionary3 = dictionary1.AddRange(dictionary2,true); // true means override +dictionary3.ForEach(pair => Debug.LogFormat(""{0}:{1}"", pair.Key, pair.Value)); +// 1:2 +// 3:4 + +// notice: duplicate keys are supported. +// 注意:支持重复的 key。 +")] +#endif + public static void AddRange(this Dictionary dict, Dictionary addInDict, + bool isOverride = false) + { + var enumerator = addInDict.GetEnumerator(); + + while (enumerator.MoveNext()) + { + var current = enumerator.Current; + if (dict.ContainsKey(current.Key)) + { + if (isOverride) + dict[current.Key] = current.Value; + continue; + } + + dict.Add(current.Key, current.Value); + } + + enumerator.Dispose(); + } + + + // TODO: + public static bool IsNullOrEmpty(this T[] collection) => collection == null || collection.Length == 0; + // TODO: + public static bool IsNullOrEmpty(this IList collection) => collection == null || collection.Count == 0; + // TODO: + public static bool IsNullOrEmpty(this IEnumerable collection) => collection == null || !collection.Any(); + // TODO: + public static bool IsNotNullAndEmpty(this T[] collection) => !IsNullOrEmpty(collection); + // TODO: + public static bool IsNotNullAndEmpty(this IList collection) => !IsNullOrEmpty(collection); + // TODO: + public static bool IsNotNullAndEmpty(this IEnumerable collection) => !IsNullOrEmpty(collection); + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs.meta new file mode 100644 index 0000000..e0c8be6 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b1be94df70e04fbf880352766fa84326 +timeCreated: 1647436071 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs new file mode 100644 index 0000000..2d2966e --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs @@ -0,0 +1,300 @@ + + +using System; +using System.Linq; +using System.Reflection; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("01.FluentAPI.CSharp", "System.Reflection", 4)] + [APIDescriptionCN("针对 System.Reflection 提供的链式扩展")] + [APIDescriptionEN("Chain extension provided for System.Reflection")] +#endif + public static class SystemReflectionExtension + { + // [UnityEditor.MenuItem("QF/Test")] + // public static void Test() + // { + // "/abc/e.txt".GetFileExtendName().LogInfo(); + // } + +#if UNITY_EDITOR + [MethodAPI] + [APIDescriptionCN("通过 Type 创建 Instance")] + [APIDescriptionEN("Create Instance By Type")] + [APIExampleCode(@" + +interface IA +{ + +} + +class A +{ +} + +IA a = typeof(A).CreateInstance(); + +")] +#endif + public static T CreateInstance(this Type self) where T : class + { + // 获取构造函数 + var constructorInfos = self.GetConstructors(BindingFlags.Instance | BindingFlags.Public); + + // 获取无参构造函数 + var ctor = Array.Find(constructorInfos, c => c.GetParameters().Length == 0); + + return ctor.Invoke(null) as T; + } + + +#if UNITY_EDITOR + // v1 No.32 + [MethodAPI] + [APIDescriptionCN("通过反射的方式调用私有方法")] + [APIDescriptionEN("call private method by reflection")] + [APIExampleCode(@" +class A +{ + private void Say() { Debug.Log(""I'm A!"") } +} + +new A().ReflectionCallPrivateMethod(""Say""); +// I'm A! +")] +#endif + public static object ReflectionCallPrivateMethod(this T self, string methodName, params object[] args) + { + var type = typeof(T); + var methodInfo = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic); + + return methodInfo?.Invoke(self, args); + } + +#if UNITY_EDITOR + // v1 No.33 + [MethodAPI] + [APIDescriptionCN("通过反射的方式调用私有方法,有返回值")] + [APIDescriptionEN("call private method by reflection,return the result")] + [APIExampleCode(@" +class A +{ + private bool Add(int a,int b) { return a + b; } +} + +Debug.Log(new A().ReflectionCallPrivateMethod(""Add"",1,2)); +// 3 +")] +#endif + public static TReturnType ReflectionCallPrivateMethod(this T self, string methodName, + params object[] args) + { + return (TReturnType)self.ReflectionCallPrivateMethod(methodName, args); + } + + +#if UNITY_EDITOR + // v1 No.34 + [MethodAPI] + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] + [APIExampleCode(@" +[DisplayName(""A Class"") +class A +{ + [DisplayName(""A Number"") + public int Number; + + [DisplayName(""Is Complete?"") + private bool Complete => Number > 100; + + [DisplayName(""Say complete result?"") + public void SayComplete() + { + Debug.Log(Complete); + } +} + +var aType = typeof(A); +// +Debug.Log(aType.HasAttribute(typeof(DisplayNameAttribute)); +// true +Debug.Log(aType.HasAttribute()); +// true + +// also support MethodInfo、PropertyInfo、FieldInfo +// 同时 也支持 MethodInfo、PropertyInfo、FieldInfo +")] +#endif + public static bool HasAttribute(this Type type, bool inherit = false) where T : Attribute + { + return type.GetCustomAttributes(typeof(T), inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this Type type, Type attributeType, bool inherit = false) + { + return type.GetCustomAttributes(attributeType, inherit).Any(); + } +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this PropertyInfo prop, bool inherit = false) where T : Attribute + { + return prop.GetCustomAttributes(typeof(T), inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this PropertyInfo prop, Type attributeType, bool inherit = false) + { + return prop.GetCustomAttributes(attributeType, inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this FieldInfo field, bool inherit = false) where T : Attribute + { + return field.GetCustomAttributes(typeof(T), inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this FieldInfo field, Type attributeType, bool inherit) + { + return field.GetCustomAttributes(attributeType, inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this MethodInfo method, bool inherit = false) where T : Attribute + { + return method.GetCustomAttributes(typeof(T), inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this MethodInfo method, Type attributeType, bool inherit = false) + { + return method.GetCustomAttributes(attributeType, inherit).Any(); + } + + +#if UNITY_EDITOR + // v1 No.35 + [MethodAPI] + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] + [APIExampleCode(@" +[DisplayName(""A Class"") +class A +{ + [DisplayName(""A Number"") + public int Number; + + [DisplayName(""Is Complete?"") + private bool Complete => Number > 100; + + [DisplayName(""Say complete result?"") + public void SayComplete() + { + Debug.Log(Complete); + } +} + +var aType = typeof(A); +// +Debug.Log(aType.GetAttribute(typeof(DisplayNameAttribute)); +// DisplayNameAttribute +Debug.Log(aType.GetAttribute()); +// DisplayNameAttribute + +// also support MethodInfo、PropertyInfo、FieldInfo +// 同时 也支持 MethodInfo、PropertyInfo、FieldInfo +")] +#endif + public static T GetAttribute(this Type type, bool inherit = false) where T : Attribute + { + return type.GetCustomAttributes(inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static object GetAttribute(this Type type, Type attributeType, bool inherit = false) + { + return type.GetCustomAttributes(attributeType, inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static T GetAttribute(this MethodInfo method, bool inherit = false) where T : Attribute + { + return method.GetCustomAttributes(inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static object GetAttribute(this MethodInfo method, Type attributeType, bool inherit = false) + { + return method.GetCustomAttributes(attributeType, inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static T GetAttribute(this FieldInfo field, bool inherit = false) where T : Attribute + { + return field.GetCustomAttributes(inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static object GetAttribute(this FieldInfo field, Type attributeType, bool inherit = false) + { + return field.GetCustomAttributes(attributeType, inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static T GetAttribute(this PropertyInfo prop, bool inherit = false) where T : Attribute + { + return prop.GetCustomAttributes(inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static object GetAttribute(this PropertyInfo prop, Type attributeType, bool inherit = false) + { + return prop.GetCustomAttributes(attributeType, inherit).FirstOrDefault(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs.meta new file mode 100644 index 0000000..1d3a5ba --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4ad1fb17a7ff4016be06cd22911d23f9 +timeCreated: 1647484400 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Tool/HashMap.cs b/Assets/00.StaryEvo/Runtime/Tool/HashMap.cs new file mode 100644 index 0000000..610dc7d --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/HashMap.cs @@ -0,0 +1,178 @@ +using System.Collections.Generic; +using System; +using System.Collections; +using System.Linq; + +public class HashMap : IDictionary, IEnumerable +{ + Dictionary HashMapData = new Dictionary(); + public TValue this[TKey key] + { + get + { + return HashMapData[key]; + } + + set + { + if (HashMapData.ContainsKey(key)) + { + HashMapData[key] = value; + } + else + { + HashMapData.Add(key, value); + } + } + } + + public int Count + { + get + { + return HashMapData.Count; + } + } + + //如果 true 是只读的,则为 IDictionary;否则为 false。 在 Dictionary 的默认实现中,此属性始终返回 false。 + public bool IsReadOnly + { + get + { + return false; + } + } + + public ICollection Keys + { + get + { + return HashMapData.Keys; + } + } + + public ICollection Values + { + get + { + return HashMapData.Values; + } + } + + public void Add(KeyValuePair item) + { + if (item.Key == null) + { + throw new ArgumentNullException("key can't be null."); + } + if (HashMapData.ContainsKey(item.Key)) + { + HashMapData[item.Key] = item.Value; + } + else + { + HashMapData.Add(item.Key, item.Value); + } + } + + public void Add(TKey key, TValue value) + { + if (key == null) + { + throw new ArgumentNullException("key can't be null."); + } + if (HashMapData.ContainsKey(key)) + { + HashMapData[key] = value; + } + else + { + HashMapData.Add(key, value); + } + } + + public void Clear() + { + HashMapData.Clear(); + } + + public bool Contains(KeyValuePair item) + { + return HashMapData.Contains(item); + } + + public bool ContainsKey(TKey key) + { + return HashMapData.ContainsKey(key); + } + + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + if (array == null) + { + return; + } + if (array.Length <= arrayIndex) + { + return; + } + int count = array.Length; + for (int i = 0; i < count; i++) + { + if (HashMapData.ContainsKey(array[i].Key)) + { + HashMapData[array[i].Key] = array[i].Value; + } + else + { + HashMapData.Add(array[i].Key, array[i].Value); + } + } + } + + public IEnumerator> GetEnumerator() + { + return HashMapData.GetEnumerator(); + } + + public bool Remove(KeyValuePair item) + { + if (HashMapData.ContainsKey(item.Key) && HashMapData.ContainsValue(item.Value)) + { + return HashMapData.Remove(item.Key); + } + return false; + } + + public bool Remove(TKey key) + { + return HashMapData.Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + try + { + if (HashMapData.ContainsKey(key)) + { + value = HashMapData[key]; + return true; + } + else + { + value = default(TValue); + return false; + } + } + catch + { + value = default(TValue); + return false; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return HashMapData.GetEnumerator(); + } +} diff --git a/Assets/00.StaryEvo/Runtime/Tool/HashMap.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/HashMap.cs.meta new file mode 100644 index 0000000..957055b --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Tool/HashMap.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7d18bd5b88649b44191b5f1575b4bade +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Utility.meta b/Assets/00.StaryEvo/Runtime/Utility.meta new file mode 100644 index 0000000..08b2c5d --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 53f7976066b694d44b1051e824e56919 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Utility/FSM.meta b/Assets/00.StaryEvo/Runtime/Utility/FSM.meta new file mode 100644 index 0000000..33044aa --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility/FSM.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 21faa0c1703071142a9c56c1b5a96cfc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMIState.cs b/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMIState.cs new file mode 100644 index 0000000..fbb9233 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMIState.cs @@ -0,0 +1,39 @@ +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public interface FSMIState { + IFsmSystem FsmSystem { get; } + string Name { get; } + float Timer { get; set; } + //进入该状态时调用 + void OnEnter(); + //每帧调用 + void OnUpdate(); + //退出该状态时调用 + void OnExit(); + } + + public abstract class AbstractFSMIState : FSMIState + { + public IFsmSystem FsmSystem { get; } + public string Name { get; } + public abstract float Timer { get; set; } + + public AbstractFSMIState(IFsmSystem system) + { + FsmSystem = system; + Name = GetType().Name; + } + + public abstract void OnEnter(); + + public virtual void OnUpdate() + { + Timer += Time.deltaTime; + } + + public abstract void OnExit(); + } +} diff --git a/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMIState.cs.meta b/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMIState.cs.meta new file mode 100644 index 0000000..84003c9 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMIState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1dc351fc8dc35ec4ca388c24444a80a8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMISystem.cs b/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMISystem.cs new file mode 100644 index 0000000..d1dee9b --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMISystem.cs @@ -0,0 +1,70 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ + public interface IFsmSystem + { + FSMIState CurState { get; set; } + void AddState(FSMIState state); + void RemoveState(FSMIState state); + void SetCurState(string name); + FSMIState GetStateWithName(string name); + HashMap States { get; set; } + } + + public class FsmSystem : IFsmSystem + { + public FSMIState CurState { get; set; } + public HashMap States { get; set; } + + public FsmSystem() + { + States = new HashMap(); + } + + public void AddState(FSMIState state) + { + Debug.Log(state.Name); + if (!States.ContainsKey(state.Name)) + { + States.Add(state.Name, state); + } + else + { + Debug.LogErrorFormat("States状态机容器里已存在名字为--【{0}】--的状态", state.Name.ToString()); + } + } + + public void RemoveState(FSMIState state) + { + if (States.ContainsKey(state.Name)) + { + States.Remove(state.Name); + } + else + { + Debug.LogErrorFormat("States状态机容器里不存在名字为--【{0}】--的状态", state.Name.ToString()); + } + } + + public void SetCurState(string name) + { + if (CurState != null) + CurState.OnExit(); + FSMIState state = GetStateWithName(name); + CurState = state; + CurState.OnEnter(); + } + + public FSMIState GetStateWithName(string name) + { + if (States.ContainsKey(name)) + { + return States[name]; + } + + return null; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMISystem.cs.meta b/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMISystem.cs.meta new file mode 100644 index 0000000..6752dc0 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility/FSM/FSMISystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 572d20e55965479cb8846f9fad4873a2 +timeCreated: 1625997700 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Utility/RemoteServices.cs b/Assets/00.StaryEvo/Runtime/Utility/RemoteServices.cs new file mode 100644 index 0000000..7494e70 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility/RemoteServices.cs @@ -0,0 +1,24 @@ +using YooAsset; + +namespace Stary.Evo +{ + public class RemoteServices : IRemoteServices + { + private readonly string _defaultHostServer; + private readonly string _fallbackHostServer; + + public RemoteServices(string defaultHostServer, string fallbackHostServer) + { + _defaultHostServer = defaultHostServer; + _fallbackHostServer = fallbackHostServer; + } + string IRemoteServices.GetRemoteMainURL(string fileName) + { + return $"{_defaultHostServer}/{fileName}"; + } + string IRemoteServices.GetRemoteFallbackURL(string fileName) + { + return $"{_fallbackHostServer}/{fileName}"; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Utility/RemoteServices.cs.meta b/Assets/00.StaryEvo/Runtime/Utility/RemoteServices.cs.meta new file mode 100644 index 0000000..c1c1d57 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility/RemoteServices.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 24f14ead8b7e46eaa0eddd6e68db8d56 +timeCreated: 1741248220 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Utility/RemoteServicesWithAuth.cs b/Assets/00.StaryEvo/Runtime/Utility/RemoteServicesWithAuth.cs new file mode 100644 index 0000000..5de6214 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility/RemoteServicesWithAuth.cs @@ -0,0 +1,51 @@ +using YooAsset; +using System.Collections; +using Stary.Evo; +using UnityEngine.Networking; + +public class RemoteServicesWithAuth : IRemoteServices +{ + private readonly string _defaultHostServer; + private readonly string _fallbackHostServer; + private string _authToken; + private string _authServiceUrl; + + public string CurrentToken { get; private set; } + + public RemoteServicesWithAuth(string defaultHostServer, + string fallbackHostServer, + string authToken, + string authServiceUrl) + { + _defaultHostServer = defaultHostServer; + _fallbackHostServer = fallbackHostServer; + _authToken = authToken; + _authServiceUrl = authServiceUrl; + RefreshToken(); + } + + private void RefreshToken() + { + // 这里实现具体的token刷新逻辑 + CurrentToken = _authToken; // 简单示例直接使用初始token + // 实际项目应该通过authServiceUrl获取新token + } + + string IRemoteServices.GetRemoteMainURL(string fileName) + { + // 在原始URL后附加鉴权参数 + return $"{_defaultHostServer}/{fileName}?token={CurrentToken}"; + } + + public string GetRemoteFallbackURL(string fileName) + { + return $"{_fallbackHostServer}/{fileName}?token={CurrentToken}"; + } + + // UnityWebRequest CreateRequest(string url) + // { + // var request = base.CreateRequest(url); + // request.SetRequestHeader("Authorization", $"Bearer {CurrentToken}"); + // return request; + // } +} diff --git a/Assets/00.StaryEvo/Runtime/Utility/RemoteServicesWithAuth.cs.meta b/Assets/00.StaryEvo/Runtime/Utility/RemoteServicesWithAuth.cs.meta new file mode 100644 index 0000000..cdc26a3 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility/RemoteServicesWithAuth.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6dc545bfe9be45789ff05152e3679e20 +timeCreated: 1741319247 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Utility/WebRequestSystem.cs b/Assets/00.StaryEvo/Runtime/Utility/WebRequestSystem.cs new file mode 100644 index 0000000..f2eddba --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility/WebRequestSystem.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using Cysharp.Threading.Tasks; +using UnityEngine; +using UnityEngine.Networking; + +namespace Stary.Evo +{ + public interface IWebRequestSystem + { + UniTask Post(string url, string postData); + UniTask Get(string url, string token=null); + + } + + public class WebRequestSystem : IWebRequestSystem + { + /// + /// POST请求数据 + /// + /// 获取Token值的服务URL地址(很重要) + /// 传入请求的参数,此处参数为JOSN格式 + /// + public async UniTask Post(string url, string postData) + { + using (UnityWebRequest webRequest = UnityWebRequest.Post(url, postData)) //第二种写法此行注释 + { + byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(postData); + webRequest.uploadHandler = (UploadHandler)new UploadHandlerRaw(postBytes); + webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); + webRequest.SetRequestHeader("Content-Type", "application/json"); + + await webRequest.SendWebRequest(); + // 更新错误检查方式 + if (webRequest.result == UnityWebRequest.Result.ConnectionError || + webRequest.result == UnityWebRequest.Result.ProtocolError) + { + Debug.LogError(webRequest.error); + return webRequest.error; + } + else + { + return webRequest.downloadHandler.text; + } + } + } + + /// + /// GET请求数据 + /// + /// 请求数据的URL地址 + /// token验证的参数,此处为authorization + /// + public async UniTask Get(string url, string token=null) + { + try + { + using (UnityWebRequest webRequest = UnityWebRequest.Get(url)) + { + webRequest.downloadHandler = new DownloadHandlerBuffer(); + if (token != null) + webRequest.SetRequestHeader("Authorization", token); // 修正请求头名称规范 + + await webRequest.SendWebRequest(); + + // 增强错误处理 + if (webRequest.result != UnityWebRequest.Result.Success) + { + var errorMsg = $"HTTP {webRequest.responseCode}\n" + + $"URL: {url}\n" + + $"Error: {webRequest.error}\n" + + $"Response: {webRequest.downloadHandler.text}"; + + Debug.LogError(errorMsg); + return null; + } + return webRequest.downloadHandler.text; // 添加返回值 + } + + } + catch (Exception e) + { + Debug.LogError(e); + } + return null; + } + + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Runtime/Utility/WebRequestSystem.cs.meta b/Assets/00.StaryEvo/Runtime/Utility/WebRequestSystem.cs.meta new file mode 100644 index 0000000..aa13487 --- /dev/null +++ b/Assets/00.StaryEvo/Runtime/Utility/WebRequestSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 213225eda91d466eacd34d1b2211aa09 +timeCreated: 1741230908 \ No newline at end of file diff --git a/Assets/02.InformationSave/RunTime/InformationSave.RunTime.asmdef b/Assets/00.StaryEvo/Runtime/com.stary.evo.runtime.asmdef similarity index 52% rename from Assets/02.InformationSave/RunTime/InformationSave.RunTime.asmdef rename to Assets/00.StaryEvo/Runtime/com.stary.evo.runtime.asmdef index 7729102..1eb4959 100644 --- a/Assets/02.InformationSave/RunTime/InformationSave.RunTime.asmdef +++ b/Assets/00.StaryEvo/Runtime/com.stary.evo.runtime.asmdef @@ -1,10 +1,14 @@ { - "name": "InformationSave.RunTime", + "name": "com.stary.evo.runtime", "rootNamespace": "", - "references": [], + "references": [ + "GUID:e34a5702dd353724aa315fb8011f08c3", + "GUID:f51ebe6a0ceec4240a699833d6309b23", + "GUID:5c01796d064528144a599661eaab93a6" + ], "includePlatforms": [], "excludePlatforms": [], - "allowUnsafeCode": false, + "allowUnsafeCode": true, "overrideReferences": false, "precompiledReferences": [], "autoReferenced": true, diff --git a/Assets/02.InformationSave/Editor/InformationSave.Editor.asmdef.meta b/Assets/00.StaryEvo/Runtime/com.stary.evo.runtime.asmdef.meta similarity index 76% rename from Assets/02.InformationSave/Editor/InformationSave.Editor.asmdef.meta rename to Assets/00.StaryEvo/Runtime/com.stary.evo.runtime.asmdef.meta index 862920a..52c86eb 100644 --- a/Assets/02.InformationSave/Editor/InformationSave.Editor.asmdef.meta +++ b/Assets/00.StaryEvo/Runtime/com.stary.evo.runtime.asmdef.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 31bb7766059e37c42b8898e180dc877f +guid: d1a793c2b6959e04ea45b972eaa369c8 AssemblyDefinitionImporter: externalObjects: {} userData: diff --git a/Assets/00.StaryEvo/Samples.meta b/Assets/00.StaryEvo/Samples.meta new file mode 100644 index 0000000..3b5b5ff --- /dev/null +++ b/Assets/00.StaryEvo/Samples.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1f85c3e3e6e5da644b65960afc09211b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Samples/Runtime.meta b/Assets/00.StaryEvo/Samples/Runtime.meta new file mode 100644 index 0000000..08a8577 --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 810a1400946cf2a4591b544ec7c6113d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp.meta b/Assets/00.StaryEvo/Samples/Runtime/CounterApp.meta new file mode 100644 index 0000000..fdd3a08 --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bf9eb356dc195004ea58a696dda5559e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script.meta b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script.meta new file mode 100644 index 0000000..4c83796 --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3808b39e00871be43bda11114e415f3f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/AchievementSystem.cs b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/AchievementSystem.cs new file mode 100644 index 0000000..cb30f36 --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/AchievementSystem.cs @@ -0,0 +1,41 @@ + +using UnityEngine; + +namespace Stary.Evo.Example.Counter +{ + public interface IAchievementSystem : ISystem + { + + } + + public class AchievementSystem : AbstractSystem, IAchievementSystem + { + public IArchitecture Architecture { get; set; } + + public override void Dispose() + { + + } + + protected override void OnInit() + { + var counterData = this.GetData(); + + var previousCount = counterData.Count.Value; + + counterData.Count.Register(newCount => + { + if (newCount >= 10 && previousCount < 10) + { + Debug.Log("解锁 10 次点击成就"); + } + else if (newCount >= 20 && previousCount < 20) + { + Debug.Log("解锁 20 次点击成就"); + } + + previousCount = newCount; + }); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/AchievementSystem.cs.meta b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/AchievementSystem.cs.meta new file mode 100644 index 0000000..3abcc58 --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/AchievementSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f241abf86b6647ea93571ad2f92c913a +timeCreated: 1624955512 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandAnd.cs b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandAnd.cs new file mode 100644 index 0000000..6745bc8 --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandAnd.cs @@ -0,0 +1,13 @@ + + +namespace Stary.Evo.Example.Counter +{ + public class CommandAnd : AbstractCommand + { + protected override void OnExecute() + { + this.GetData().Count.Value++; + } + } + +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandAnd.cs.meta b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandAnd.cs.meta new file mode 100644 index 0000000..063ea8b --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandAnd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ca5d6aa1e6bbab64dbbdeace6b015b23 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandSub.cs b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandSub.cs new file mode 100644 index 0000000..7174862 --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandSub.cs @@ -0,0 +1,12 @@ + + +namespace Stary.Evo.Example.Counter +{ + public class CommandSub : AbstractCommand + { + protected override void OnExecute() + { + CounterApp.Interface.GetData().Count.Value--; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandSub.cs.meta b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandSub.cs.meta new file mode 100644 index 0000000..8ca4dc7 --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CommandSub.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b07fd1086f5d247448c730438ab61e75 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterApp.cs b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterApp.cs new file mode 100644 index 0000000..aaddb46 --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterApp.cs @@ -0,0 +1,15 @@ + + +namespace Stary.Evo.Example.Counter +{ + public class CounterApp : Architecture + { + protected override void Init() + { + RegisterSystem(new AchievementSystem()); + RegisterData(new CounterData()); + RegisterUtility(new PlayerPrefsStorage()); + } + } + +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterApp.cs.meta b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterApp.cs.meta new file mode 100644 index 0000000..4e47fd8 --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterApp.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4b9e1b9962882b647b727dc4749d40dd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterModel.cs b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterModel.cs new file mode 100644 index 0000000..0e3bdcf --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterModel.cs @@ -0,0 +1,32 @@ + + +namespace Stary.Evo.Example.Counter +{ + + public interface ICounterData : IData + { + BindableProperty Count { get; } + } + + public class CounterData : AbstractData, ICounterData + { + public override void Dispose() + { + + } + + protected override void OnInit() + { + var storage = this.GetUtility(); + Count.Value = storage.LoadInt("COUNTER_COUNT", 0); + + Count.Register( count => { storage.SaveInt("COUNTER_COUNT", count); }); + } + + public BindableProperty Count { get; } = new BindableProperty() + { + Value = 0 + }; + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterModel.cs.meta b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterModel.cs.meta new file mode 100644 index 0000000..2b9975e --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterModel.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 10c86a7a3c934d4796a6ec85a27f5a81 +timeCreated: 1624948547 \ No newline at end of file diff --git a/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterViewController.cs b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterViewController.cs new file mode 100644 index 0000000..f3a9d7e --- /dev/null +++ b/Assets/00.StaryEvo/Samples/Runtime/CounterApp/Script/CounterViewController.cs @@ -0,0 +1,53 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace Stary.Evo.Example.Counter +{ + public class CounterViewController : MonoBehaviour, IController + { + private Text _countText; + private ICounterData mCounterData; + + void Start() + { + // 获取 + mCounterData = this.GetData(); + mCounterData.Count.Register(UpdateView); + _countText = transform.Find("CountText").GetComponent(); + _countText.text = mCounterData.Count.Value.ToString(); + transform.Find("ButtonAdd").GetComponent