9个文件已修改
227个文件已删除
34个文件已添加
| | |
| | | Assets/ThirdParty.meta |
| | | LuaDebuggee.dll |
| | | Assets/XLua/Gen.meta |
| | | Assets/ILRuntime/Generated/ |
| | |
| | | EditorApplication.delayCall += ExcuteBuildPatch; |
| | | } |
| | | |
| | | if (GUILayout.Button("logic")) |
| | | { |
| | | EditorApplication.delayCall += ExcuteBuildLogic; |
| | | } |
| | | |
| | | EditorGUILayout.EndHorizontal(); |
| | | |
| | | EditorGUILayout.Space(); |
| | |
| | | ExcuteBuildBuiltIn(); |
| | | ExcuteBuildLua(); |
| | | ExcuteBuildPatch(); |
| | | ExcuteBuildLogic(); |
| | | |
| | | AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); |
| | | |
| | |
| | | DirectoryCopy(sourcePath, outputPath, ".meta"); |
| | | } |
| | | |
| | | private void ExcuteBuildLogic() |
| | | { |
| | | var outputPath = Application.dataPath.Replace("Assets", m_UserData.m_OutputPath); |
| | | outputPath = StringUtility.Contact(outputPath, "/logic"); |
| | | if (Directory.Exists(outputPath)) |
| | | Directory.Delete(outputPath, true); |
| | | var dllFile = ResourcesPath.ResourcesOutAssetPath + "logic/Logic.dll.bytes"; |
| | | var outDllFile = StringUtility.Contact(outputPath, "/Logic.dll.bytes"); |
| | | var pdbFile = ResourcesPath.ResourcesOutAssetPath + "logic/Logic.pdb"; |
| | | var outPdbFile = StringUtility.Contact(outputPath, "/Logic.pdb"); |
| | | if (!File.Exists(dllFile)) |
| | | { |
| | | DebugEx.LogErrorFormat("æå
é误ï¼{0} ä¸åå¨", dllFile); |
| | | return; |
| | | } |
| | | FileExtersion.MakeSureDirectory(outDllFile); |
| | | File.Copy(dllFile, outDllFile); |
| | | File.Copy(pdbFile, outPdbFile); |
| | | } |
| | | |
| | | private void ExcuteBuildLevels() |
| | | { |
| | | UpdateLevelSetting.SetAllLevelAssetBundleName(); |
| | |
| | | AssetSource.uiFromEditor = EditorGUILayout.Toggle("uiFromEditor:", AssetSource.uiFromEditor); |
| | | AssetSource.builtInFromEditor = EditorGUILayout.Toggle("builtInFromEditor:", AssetSource.builtInFromEditor); |
| | | AssetSource.patchFromEditor = EditorGUILayout.Toggle("patchFromEditor:", AssetSource.patchFromEditor); |
| | | AssetSource.logicFromEditor = EditorGUILayout.Toggle("logicFromEditor:", AssetSource.logicFromEditor); |
| | | EditorGUILayout.Space(); |
| | | if (GUILayout.Button("å
¨é¨åæ¢")) |
| | | { |
| New file |
| | |
| | | using UnityEditor; |
| | | using UnityEngine; |
| | | |
| | | public class ClearAllLocalSaveTool |
| | | { |
| | | |
| | | [MenuItem("Tools/æ¸
é¤LocalSave")] |
| | | public static void ClearAllLocalSave() |
| | | { |
| | | LocalSave.DeleteAll(); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 44556fe6ad0f763438fceaa932d50e8a |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| | |
| | | /// <param name="_replace">iosæå
导åºxcodeå·¥ç¨æ¨¡å¼ï¼AppendåReplace</param>
|
| | | public static void BuildPublishers(string _sdkPath, string _assetBundlePath, string _output, string _publisherString, int _buildIndex, bool _development, bool _replace)
|
| | | {
|
| | |
|
| | | var publisherIds = new List<string>();
|
| | | var tempStrings = _publisherString.Split(StringUtility.splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
| | |
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | //åé¤è¡¨èµæº
|
| | | if (!includeConfig)
|
| | | {
|
| | |
| | |
|
| | | private static void PreBuild(string _publisher, int _buildIndex)
|
| | | {
|
| | | try
|
| | | var newVersionConfigPath = StringUtility.Contact("Assets/Resources/VersionConfig", ".asset");
|
| | | var versionName = string.Empty;
|
| | | var fromVersionConfig = GetVersionConfig(_publisher, out versionName);
|
| | | var newVersionConfig = ScriptableObject.CreateInstance<VersionConfig>();
|
| | | if (File.Exists(newVersionConfigPath))
|
| | | {
|
| | | var newVersionConfigPath = StringUtility.Contact("Assets/Resources/VersionConfig", ".asset");
|
| | | var versionName = string.Empty;
|
| | | var fromVersionConfig = GetVersionConfig(_publisher, out versionName);
|
| | | var newVersionConfig = ScriptableObject.CreateInstance<VersionConfig>();
|
| | | if (File.Exists(newVersionConfigPath))
|
| | | {
|
| | | AssetDatabase.DeleteAsset(newVersionConfigPath);
|
| | | }
|
| | |
|
| | | VersionConfig.Copy(fromVersionConfig, newVersionConfig);
|
| | | newVersionConfig.buildTime = DateTime.Now.ToString("yy/MM/dd--HH:mm");
|
| | | newVersionConfig.buildIndex = _buildIndex;
|
| | |
|
| | | if (File.Exists(Application.dataPath + "/Resources/Game.txt"))
|
| | | {
|
| | | File.Delete(Application.dataPath + "/Resources/Game.txt");
|
| | | }
|
| | |
|
| | | File.WriteAllText(Application.dataPath + "/Resources/Game.txt", GetGameId(_publisher));
|
| | |
|
| | | AssetDatabase.CreateAsset(newVersionConfig, newVersionConfigPath);
|
| | | EditorUtility.SetDirty(newVersionConfig);
|
| | |
|
| | | SetIconAndSplashImage(versionName);
|
| | | //SetCreateRoleAnimation();
|
| | |
|
| | | PlayerSettings.companyName = "TheSecondWorld";
|
| | | PlayerSettings.productName = newVersionConfig.productName;
|
| | | PlayerSettings.applicationIdentifier = newVersionConfig.bundleIdentifier;
|
| | | PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation;
|
| | | PlayerSettings.allowedAutorotateToLandscapeLeft = true;
|
| | | PlayerSettings.allowedAutorotateToLandscapeRight = true;
|
| | | PlayerSettings.allowedAutorotateToPortrait = false;
|
| | | PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;
|
| | | PlayerSettings.bundleVersion = VersionConfig.GetVersionNumber(newVersionConfig.version).ToString();
|
| | |
|
| | | if (GetBuildTarget() == BuildTargetGroup.Android)
|
| | | {
|
| | | CSObjectWrapEditor.Generator.ClearAll();
|
| | | CSObjectWrapEditor.Generator.GenAll();
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Debug.Log(ex);
|
| | | }
|
| | | finally
|
| | | {
|
| | | AssetDatabase.SaveAssets();
|
| | | AssetDatabase.Refresh();
|
| | | AssetDatabase.DeleteAsset(newVersionConfigPath);
|
| | | }
|
| | |
|
| | | VersionConfig.Copy(fromVersionConfig, newVersionConfig);
|
| | | newVersionConfig.buildTime = DateTime.Now.ToString("yy/MM/dd--HH:mm");
|
| | | newVersionConfig.buildIndex = _buildIndex;
|
| | |
|
| | | if (File.Exists(Application.dataPath + "/Resources/Game.txt"))
|
| | | {
|
| | | File.Delete(Application.dataPath + "/Resources/Game.txt");
|
| | | }
|
| | |
|
| | | File.WriteAllText(Application.dataPath + "/Resources/Game.txt", GetGameId(_publisher));
|
| | |
|
| | | AssetDatabase.CreateAsset(newVersionConfig, newVersionConfigPath);
|
| | | EditorUtility.SetDirty(newVersionConfig);
|
| | |
|
| | | SetIconAndSplashImage(versionName);
|
| | | //SetCreateRoleAnimation();
|
| | |
|
| | | PlayerSettings.companyName = "TheSecondWorld";
|
| | | PlayerSettings.productName = newVersionConfig.productName;
|
| | | PlayerSettings.applicationIdentifier = newVersionConfig.bundleIdentifier;
|
| | | PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation;
|
| | | PlayerSettings.allowedAutorotateToLandscapeLeft = true;
|
| | | PlayerSettings.allowedAutorotateToLandscapeRight = true;
|
| | | PlayerSettings.allowedAutorotateToPortrait = false;
|
| | | PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;
|
| | | PlayerSettings.bundleVersion = VersionConfig.GetVersionNumber(newVersionConfig.version).ToString();
|
| | |
|
| | | //çæILruntiemd CLR ç»å®ä»£ç
|
| | | ILRuntimeCLRBinding.GenerateCLRBinding();
|
| | |
|
| | | AssetDatabase.SaveAssets();
|
| | | AssetDatabase.Refresh();
|
| | | }
|
| | |
|
| | | static VersionConfig GetVersionConfig(string _publisher, out string _versionName)
|
| | |
| | | /// <param name="setPath"></param>
|
| | | private static void PathCache(string setPath = "")
|
| | | {
|
| | | DebugEx.Log("è·¯å¾ç¼å:" + setPath);
|
| | | string configPath = UnityEngine.Application.dataPath;
|
| | | configPath = configPath + "/ResourcesOut/Refdata/Config/PathCache/TablePath.txt";
|
| | | FileStream configPathTxt = File.Open(configPath, FileMode.Open);
|
| | |
| | | 9998 xmyjgame xmyjgame 1 1.100.2 aaa 4 xbqy 1 1 ä»éæåº com.xfzc.yj.quick mengxiandao mengxiandao2020 mengxiandao mengxiandao2020 0 0 (-15,64) åºçåä½åç§°:天津çµååºç社æéå
¬å¸ èä½æäººåç§°:广å·ç§ä¹ç½ç»ç§ææéå
¬å¸</r>è¿è¥åä½:å¹¿å·æ¸¸è·¯ç½ç»ç§ææéå
¬å¸ 游æå
容类å«:ç§»å¨æ¸¸æ æ¹æå·:彿°åºå®¡[2019]1132å· æ¸¸æçå·:ISBN 978-7-498-06329-8 xmyjgame 0 |
| | | 9527 TheSecondWorld test 0 1.100.1 aaa 911 xbqy 2 0 ä»å®å¥ç¼ com.secondworld.snxxz thesecondworld thesecondworld2018 thesecondworld thesecondworld2018 1 0 (-32,144) 0 |
| | | 9528 gtgame gtgame 1 1.100.1 aaa 1 xbqy 3 0 é®é訣 com.sanxiagame.zmjgp gtgame Fjsx123123 Key0 Fjsx123123 1 0 (0,80) gtgame 0 1 |
| | | 911 TheSecondWorld test 0 1.100.1 aaa 911 xbqy 2 0 ä»å®å¥ç¼ com.secondworld.snxxz thesecondworld thesecondworld2018 thesecondworld thesecondworld2018 1 0 (-32,144) 0 |
| | | 911 TheSecondWorld test 0 1.100.1 aaa 911 xbqy 0 0 ä»å®å¥ç¼ com.secondworld.snxxz thesecondworld thesecondworld2018 thesecondworld thesecondworld2018 1 0 (-32,144) 0 |
| | |
| | | get |
| | | { |
| | | return (from type in Assembly.Load("Assembly-CSharp").GetTypes() |
| | | where type.Namespace == null || (!type.Namespace.StartsWith("XLua") && !type.Namespace.StartsWith("IFix")) |
| | | where type.Namespace == null || |
| | | (!type.Namespace.StartsWith("XLua") && |
| | | !type.Namespace.StartsWith("IFix") && |
| | | type.Namespace != "ILRuntime.Runtime.Generated") |
| | | select type); |
| | | } |
| | | } |
| | | |
| | | [Filter] |
| | | static bool Filter(System.Reflection.MethodInfo methodInfo) |
| | | { |
| | | return methodInfo.DeclaringType.FullName == "Test" |
| | | && (methodInfo.Name == "Div" || methodInfo.Name == "Mult"); |
| | | } |
| | | } |
| | | |
| | | //æ¾ç½®é
ç½®ç |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: dea2d610c46c63249bbfd24044a6c75f |
| | | folderAsset: yes |
| | | DefaultImporter: |
| | | externalObjects: {} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: a2619b749b100f847a3fdbddc509bebc |
| | | folderAsset: yes |
| | | DefaultImporter: |
| | | externalObjects: {} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | #if UNITY_EDITOR |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using ILCrossBinding; |
| | | using Snxxz.UI; |
| | | using UnityEditor; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | [System.Reflection.Obfuscation(Exclude = true)] |
| | | public class ILRuntimeCLRBinding |
| | | { |
| | | const string genPath = "Assets/ILRuntime/Generated"; |
| | | |
| | | //éè¦çæç»å®ä»£ç çç±», litjson å c# system ä¸ç代ç ä¸è¦å¨è¿çæï¼ä¼æé®é¢ |
| | | //æ¤å¤é
ç½®çç±»ï¼çæä»£ç ä¼è¦çèªå¨çæçã |
| | | static List<Type> types = new List<Type> |
| | | { |
| | | //Unityç¸å
³ |
| | | typeof(Transform), |
| | | typeof(RectTransform), |
| | | typeof(GameObject), |
| | | typeof(Component), |
| | | typeof(UnityEngine.Object), |
| | | typeof(MonoBehaviour), |
| | | typeof(Behaviour), |
| | | typeof(Text), |
| | | typeof(Button), |
| | | typeof(Image), |
| | | //主工ç¨ç¸å
³ |
| | | typeof(Redpoint), |
| | | typeof(Int2), |
| | | typeof(Int3), |
| | | typeof(UILoader), |
| | | typeof(ComponentExtersion), |
| | | typeof(TransformExtension), |
| | | typeof(LocalSave), |
| | | typeof(ILBehaviourProxy), |
| | | typeof(WidgetBehavior), |
| | | typeof(ILWindowProxy), |
| | | typeof(ILOneLevelWindowProxy), |
| | | typeof(ModelCenter), |
| | | typeof(Singleton<ModelCenter>), |
| | | typeof(WindowCenter), |
| | | typeof(SingletonMonobehaviour<WindowCenter>), |
| | | typeof(WindowJumpMgr), |
| | | typeof(Singleton<WindowJumpMgr>), |
| | | typeof(DebugEx), |
| | | typeof(TextEx), |
| | | typeof(ButtonEx), |
| | | typeof(ImageEx), |
| | | typeof(TimeUtility), |
| | | typeof(HttpRequest), |
| | | typeof(SingletonMonobehaviour<HttpRequest>), |
| | | typeof(SysNotifyMgr), |
| | | typeof(SingletonMonobehaviour<SysNotifyMgr>), |
| | | typeof(PackageRegedit), |
| | | typeof(GameNetSystem), |
| | | typeof(Singleton<GameNetSystem>), |
| | | typeof(GameNetPackBasic), |
| | | typeof(OperationTimeHepler), |
| | | typeof(Singleton<OperationTimeHepler>), |
| | | typeof(DtcBasic), |
| | | typeof(PlayerDatas), |
| | | typeof(Singleton<PlayerDatas>), |
| | | typeof(PlayerBaseData), |
| | | typeof(Language), |
| | | typeof(TimeMgr), |
| | | typeof(SingletonMonobehaviour<TimeMgr>), |
| | | typeof(CommonItemBaisc), |
| | | typeof(ItemCell), |
| | | typeof(ItemTipUtility), |
| | | typeof(SkillModel), |
| | | typeof(VipModel), |
| | | typeof(ItemCellModel), |
| | | typeof(ItemModel), |
| | | typeof(PackModel), |
| | | typeof(EquipModel), |
| | | //表 |
| | | typeof(ItemConfig), |
| | | typeof(FuncConfigConfig), |
| | | typeof(SysInfoConfig) |
| | | }; |
| | | |
| | | //éè¦æé¤çæ¹æ³ |
| | | static List<object[]> excludeMethods = new List<object[]>() |
| | | { |
| | | new object[]{typeof(Text),"OnRebuildRequested"}, |
| | | new object[]{typeof(MonoBehaviour),"get_runInEditMode"}, |
| | | new object[]{typeof(MonoBehaviour),"set_runInEditMode"}, |
| | | }; |
| | | |
| | | static HashSet<MethodBase> GetExcludeMethod() |
| | | { |
| | | var set = new HashSet<MethodBase>(); |
| | | foreach (var objs in excludeMethods) |
| | | { |
| | | var type = (Type)objs[0]; |
| | | var m = type.GetMethod((string)objs[1]); |
| | | set.Add(m); |
| | | } |
| | | return set; |
| | | } |
| | | |
| | | [MenuItem("ILRuntime/æ¸
é¤CLRç»å®")] |
| | | static void ClearCLRBinding() |
| | | { |
| | | if (Directory.Exists(genPath)) |
| | | { |
| | | Directory.Delete(genPath, true); |
| | | } |
| | | AssetDatabase.Refresh(); |
| | | } |
| | | |
| | | [MenuItem("ILRuntime/çæCLRç»å®")] |
| | | public static void GenerateCLRBinding() |
| | | { |
| | | ClearCLRBinding(); |
| | | GenerateCLRBindingByAnalysis(); |
| | | GenerateCLRBindingByTypes(); |
| | | MergeGenerated(); |
| | | AssetDatabase.Refresh(); |
| | | DebugEx.Log("ILRuntime CLRç»å®ä»£ç çææåï¼"); |
| | | } |
| | | |
| | | // [MenuItem("ILRuntime/èªå¨åæDllçæCLRç»å®")] |
| | | static void GenerateCLRBindingByAnalysis() |
| | | { |
| | | var path = genPath + "/Analysis"; |
| | | //ç¨çæ´dllè°ç¨å¼ç¨æ¥çæç»å®ä»£ç |
| | | ILRuntime.Runtime.Enviorment.AppDomain domain = new ILRuntime.Runtime.Enviorment.AppDomain(); |
| | | using (System.IO.FileStream fs = new System.IO.FileStream("Assets/ResourcesOut/logic/Logic.dll.bytes", System.IO.FileMode.Open, System.IO.FileAccess.Read)) |
| | | { |
| | | domain.LoadAssembly(fs); |
| | | //Crossbind Adapter is needed to generate the correct binding code |
| | | InitILRuntime(domain); |
| | | ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(domain, path); |
| | | } |
| | | } |
| | | |
| | | // [MenuItem("ILRuntime/æ ¹æ®é
ç½®å表çæCLRç»å®")] |
| | | static void GenerateCLRBindingByTypes() |
| | | { |
| | | var path = genPath + "/Types"; |
| | | //ç¨èªå®ä¹çå表æ¥çæç»å®ä»£ç |
| | | ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(types, path, GetExcludeMethod()); |
| | | } |
| | | |
| | | //åå¹¶çæç代ç |
| | | static void MergeGenerated() |
| | | { |
| | | var exist = new HashSet<string>(); |
| | | var added = new List<string>(); |
| | | var path1 = System.Environment.CurrentDirectory + "/" + genPath + "/Types"; |
| | | var dic1 = new DirectoryInfo(path1); |
| | | //è·åtypesçæçå表 |
| | | foreach (var file in dic1.GetFiles()) |
| | | { |
| | | exist.Add(file.Name); |
| | | } |
| | | var path2 = System.Environment.CurrentDirectory + "/" + genPath + "/Analysis"; |
| | | var dic2 = new DirectoryInfo(path2); |
| | | //dllåå¨åtypes䏿 ·ç代ç ï¼å°±å é¤ï¼å
¶ä½çè§ä¸ºæ°å¢ |
| | | foreach (var file in dic2.GetFiles()) |
| | | { |
| | | if (exist.Contains(file.Name)) |
| | | file.Delete(); |
| | | else |
| | | { |
| | | var className = GetClassName(file.FullName); |
| | | if (!string.IsNullOrEmpty(className)) |
| | | added.Add(className); |
| | | } |
| | | } |
| | | //å°dllæ°å¢ä»£ç åå
¥å°CLRBindings䏿³¨å |
| | | var lines = File.ReadAllLines(path1 + "/CLRBindings.cs").ToList(); |
| | | int index = 0; |
| | | for (int i = 0; i < lines.Count; i++) |
| | | { |
| | | if (lines[i].Contains("public static void Initialize")) |
| | | { |
| | | index = i; |
| | | break; |
| | | } |
| | | } |
| | | var space = " "; |
| | | lines.Insert(index + 2, space + "//é
ç½®å表çCLRç»å®ç±»"); |
| | | foreach (var name in added) |
| | | { |
| | | lines.Insert(index + 2, space + name + ".Register(app);"); |
| | | } |
| | | lines.Insert(index + 2, space + "//èªå¨åædllæ°å¢çCLRç»å®ç±»"); |
| | | File.WriteAllLines(path1 + "/CLRBindings.cs", lines); |
| | | } |
| | | |
| | | //è·åæä»¶çç±»å |
| | | static string GetClassName(string path) |
| | | { |
| | | var lines = File.ReadAllLines(path).ToList(); |
| | | foreach (var line in lines) |
| | | { |
| | | if (line.Contains("class")) |
| | | { |
| | | var strs = line.Split(' '); |
| | | return strs[strs.Length - 1]; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | //è¿ééè¦æ³¨åææçæ´DLLä¸ç¨å°çè·¨åç»§æ¿Adapterï¼å¦åæ æ³æ£ç¡®æåå¼ç¨ |
| | | static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) |
| | | { |
| | | domain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); |
| | | domain.RegisterCrossBindingAdaptor(new DtcBasicAdapter()); |
| | | domain.RegisterCrossBindingAdaptor(new GameNetPackBasicAdapter()); |
| | | } |
| | | |
| | | } |
| | | #endif |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: b25613ceb76187a4f928518b9ac1dd22 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | #if UNITY_EDITOR |
| | | using UnityEditor; |
| | | using UnityEngine; |
| | | using System; |
| | | [System.Reflection.Obfuscation(Exclude = true)] |
| | | public class ILRuntimeCrossBinding : EditorWindow |
| | | { |
| | | [MenuItem("ILRuntime/çæè·¨åç»§æ¿éé
å¨")] |
| | | public static void ShowWindow() |
| | | { |
| | | EditorWindow.GetWindow<ILRuntimeCrossBinding>("çæè·¨åç»§æ¿éé
å¨").Show(); |
| | | } |
| | | |
| | | Type type = typeof(DtcBasic); |
| | | |
| | | private void OnGUI() |
| | | { |
| | | EditorGUILayout.Space(); |
| | | EditorGUILayout.Space(); |
| | | EditorGUILayout.Space(); |
| | | EditorGUILayout.Space(); |
| | | GUILayout.Label(string.Format("ç±»åï¼{0}", type.Name)); |
| | | EditorGUILayout.Space(); |
| | | |
| | | if (GUILayout.Button("çæ")) |
| | | { |
| | | GenerateCrossbindAdapter(); |
| | | } |
| | | } |
| | | |
| | | void GenerateCrossbindAdapter() |
| | | { |
| | | var path = "Assets/Scripts/ILRuntime/Src/Inheritance/{0}Adapter.cs"; |
| | | using (System.IO.StreamWriter sw = new System.IO.StreamWriter(string.Format(path, type.Name))) |
| | | { |
| | | sw.WriteLine(ILRuntime.Runtime.Enviorment.CrossBindingCodeGenerator.GenerateCrossBindingAdapterCode(type, "ILCrossBinding")); |
| | | } |
| | | AssetDatabase.Refresh(); |
| | | DebugEx.Log("è·¨åç»§æ¿éé
çææå"); |
| | | } |
| | | } |
| | | #endif |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 077d29cbd51762b43bf8163a1b0df776 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 9265fa54816eaa241be3e83a494799a7 |
| | | folderAsset: yes |
| | | DefaultImporter: |
| | | externalObjects: {} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 160d44d5c8f210a4a8f72a7d2167b131 |
| | | folderAsset: yes |
| | | DefaultImporter: |
| | | externalObjects: {} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 63c35164a7435f845b547dd77d13d13a |
| | | folderAsset: yes |
| | | DefaultImporter: |
| | | externalObjects: {} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | using UnityEngine; |
| | | using System.Collections.Generic; |
| | | using ILRuntime.Other; |
| | | using System; |
| | | using System.Reflection; |
| | | using ILRuntime.Runtime.Enviorment; |
| | | using ILRuntime.Runtime.Intepreter; |
| | | using ILRuntime.CLR.Method; |
| | | using ILRuntime.CLR.TypeSystem; |
| | | using ILRuntime.Runtime.Stack; |
| | | |
| | | public unsafe class QuaternionBinder : ValueTypeBinder<Quaternion> |
| | | { |
| | | Vector3Binder vector3Binder; |
| | | bool vector3BinderGot; |
| | | |
| | | Vector3Binder Vector3Binder |
| | | { |
| | | get |
| | | { |
| | | if (!vector3BinderGot) |
| | | { |
| | | vector3BinderGot = true; |
| | | var vector3Type = CLRType.AppDomain.GetType(typeof(Vector3)) as CLRType; |
| | | vector3Binder = vector3Type.ValueTypeBinder as Vector3Binder; |
| | | } |
| | | |
| | | return vector3Binder; |
| | | } |
| | | } |
| | | |
| | | public override unsafe void AssignFromStack(ref Quaternion ins, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | var v = ILIntepreter.Minus(ptr, 1); |
| | | ins.x = *(float*)&v->Value; |
| | | v = ILIntepreter.Minus(ptr, 2); |
| | | ins.y = *(float*)&v->Value; |
| | | v = ILIntepreter.Minus(ptr, 3); |
| | | ins.z = *(float*)&v->Value; |
| | | v = ILIntepreter.Minus(ptr, 4); |
| | | ins.w = *(float*)&v->Value; |
| | | } |
| | | |
| | | public override unsafe void CopyValueTypeToStack(ref Quaternion ins, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | var v = ILIntepreter.Minus(ptr, 1); |
| | | *(float*)&v->Value = ins.x; |
| | | v = ILIntepreter.Minus(ptr, 2); |
| | | *(float*)&v->Value = ins.y; |
| | | v = ILIntepreter.Minus(ptr, 3); |
| | | *(float*)&v->Value = ins.z; |
| | | v = ILIntepreter.Minus(ptr, 4); |
| | | *(float*)&v->Value = ins.w; |
| | | } |
| | | public override void RegisterCLRRedirection(ILRuntime.Runtime.Enviorment.AppDomain appdomain) |
| | | { |
| | | BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; |
| | | MethodBase method; |
| | | Type[] args; |
| | | Type type = typeof(Quaternion); |
| | | args = new Type[] { typeof(float), typeof(float), typeof(float), typeof(float) }; |
| | | method = type.GetConstructor(flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, NewQuaternion); |
| | | |
| | | args = new Type[] { typeof(Quaternion), typeof(Quaternion) }; |
| | | method = type.GetMethod("op_Multiply", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Quaternion_Multiply); |
| | | |
| | | args = new Type[] { typeof(Quaternion), typeof(Vector3) }; |
| | | method = type.GetMethod("op_Multiply", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Quaternion_Multiply2); |
| | | |
| | | args = new Type[] { typeof(Quaternion), typeof(Quaternion) }; |
| | | method = type.GetMethod("op_Equality", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Quaternion_Equality); |
| | | |
| | | args = new Type[] { typeof(Quaternion), typeof(Quaternion) }; |
| | | method = type.GetMethod("op_Inequality", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Quaternion_Inequality); |
| | | |
| | | args = new Type[] { typeof(Quaternion), typeof(Quaternion) }; |
| | | method = type.GetMethod("Dot", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Quaternion_Dot); |
| | | |
| | | args = new Type[] { typeof(Quaternion), typeof(Quaternion) }; |
| | | method = type.GetMethod("Angle", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Quaternion_Angle); |
| | | |
| | | args = new Type[] { typeof(Vector3) }; |
| | | method = type.GetMethod("Euler", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Quaternion_Euler); |
| | | |
| | | args = new Type[] { typeof(float), typeof(float), typeof(float) }; |
| | | method = type.GetMethod("Euler", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Quaternion_Euler2); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_eulerAngles", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_EulerAngle); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_identity", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_Identity); |
| | | } |
| | | |
| | | StackObject* Quaternion_Multiply(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | Quaternion left, right; |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | ParseQuaternion(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseQuaternion(out left, intp, ptr, mStack); |
| | | |
| | | var res = left * right; |
| | | PushQuaternion(ref res, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Quaternion_Multiply2(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | Vector3 vec; |
| | | Quaternion left; |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector3Binder.ParseVector3(out vec, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseQuaternion(out left, intp, ptr, mStack); |
| | | |
| | | vec = left * vec; |
| | | PushVector3(ref vec, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Quaternion_Equality(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Quaternion left, right; |
| | | ParseQuaternion(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseQuaternion(out left, intp, ptr, mStack); |
| | | |
| | | var res = left == right; |
| | | |
| | | ret->ObjectType = ObjectTypes.Integer; |
| | | ret->Value = res ? 1 : 0; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Quaternion_Inequality(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Quaternion left, right; |
| | | ParseQuaternion(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseQuaternion(out left, intp, ptr, mStack); |
| | | |
| | | var res = left != right; |
| | | |
| | | ret->ObjectType = ObjectTypes.Integer; |
| | | ret->Value = res ? 1 : 0; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Quaternion_Dot(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Quaternion left, right; |
| | | ParseQuaternion(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseQuaternion(out left, intp, ptr, mStack); |
| | | |
| | | var res = Quaternion.Dot(left, right); |
| | | |
| | | ret->ObjectType = ObjectTypes.Float; |
| | | *(float*)&ret->Value = res; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Quaternion_Angle(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Quaternion left, right; |
| | | ParseQuaternion(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseQuaternion(out left, intp, ptr, mStack); |
| | | |
| | | var res = Quaternion.Angle(left, right); |
| | | |
| | | ret->ObjectType = ObjectTypes.Float; |
| | | *(float*)&ret->Value = res; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Quaternion_Euler(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector3 vec; |
| | | Vector3Binder.ParseVector3(out vec, intp, ptr, mStack); |
| | | |
| | | var res = Quaternion.Euler(vec); |
| | | |
| | | PushQuaternion(ref res, intp, ptr, mStack); |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Quaternion_Euler2(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 3); |
| | | float x, y, z; |
| | | |
| | | var ptr = ILIntepreter.GetObjectAndResolveReference(ILIntepreter.Minus(esp, 1)); |
| | | z = *(float*)&ptr->Value; |
| | | |
| | | ptr = ILIntepreter.GetObjectAndResolveReference(ILIntepreter.Minus(esp, 2)); |
| | | y = *(float*)&ptr->Value; |
| | | |
| | | ptr = ILIntepreter.GetObjectAndResolveReference(ILIntepreter.Minus(esp, 3)); |
| | | x = *(float*)&ptr->Value; |
| | | |
| | | var res = Quaternion.Euler(x, y, z); |
| | | |
| | | PushQuaternion(ref res, intp, ptr, mStack); |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* NewQuaternion(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | StackObject* ret; |
| | | if (isNewObj) |
| | | { |
| | | ret = ILIntepreter.Minus(esp, 3); |
| | | Quaternion vec; |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | vec.w = *(float*)&ptr->Value; |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | vec.z = *(float*)&ptr->Value; |
| | | ptr = ILIntepreter.Minus(esp, 3); |
| | | vec.y = *(float*)&ptr->Value; |
| | | ptr = ILIntepreter.Minus(esp, 4); |
| | | vec.x = *(float*)&ptr->Value; |
| | | |
| | | PushQuaternion(ref vec, intp, ptr, mStack); |
| | | } |
| | | else |
| | | { |
| | | ret = ILIntepreter.Minus(esp, 5); |
| | | var instance = ILIntepreter.GetObjectAndResolveReference(ret); |
| | | var dst = *(StackObject**)&instance->Value; |
| | | var f = ILIntepreter.Minus(dst, 1); |
| | | var v = ILIntepreter.Minus(esp, 4); |
| | | *f = *v; |
| | | |
| | | f = ILIntepreter.Minus(dst, 2); |
| | | v = ILIntepreter.Minus(esp, 3); |
| | | *f = *v; |
| | | |
| | | f = ILIntepreter.Minus(dst, 3); |
| | | v = ILIntepreter.Minus(esp, 2); |
| | | *f = *v; |
| | | |
| | | f = ILIntepreter.Minus(dst, 4); |
| | | v = ILIntepreter.Minus(esp, 1); |
| | | *f = *v; |
| | | } |
| | | return ret; |
| | | } |
| | | |
| | | StackObject* Get_EulerAngle(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Quaternion vec; |
| | | ParseQuaternion(out vec, intp, ptr, mStack); |
| | | |
| | | var res = vec.eulerAngles; |
| | | |
| | | PushVector3(ref res, intp, ret, mStack); |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Get_Identity(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = esp; |
| | | |
| | | var res = Quaternion.identity; |
| | | PushQuaternion(ref res, intp, ret, mStack); |
| | | return ret + 1; |
| | | } |
| | | |
| | | static void ParseQuaternion(out Quaternion vec, ILIntepreter intp, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | var a = ILIntepreter.GetObjectAndResolveReference(ptr); |
| | | if (a->ObjectType == ObjectTypes.ValueTypeObjectReference) |
| | | { |
| | | var src = *(StackObject**)&a->Value; |
| | | vec.x = *(float*)&ILIntepreter.Minus(src, 1)->Value; |
| | | vec.y = *(float*)&ILIntepreter.Minus(src, 2)->Value; |
| | | vec.z = *(float*)&ILIntepreter.Minus(src, 3)->Value; |
| | | vec.w = *(float*)&ILIntepreter.Minus(src, 4)->Value; |
| | | intp.FreeStackValueType(ptr); |
| | | } |
| | | else |
| | | { |
| | | vec = (Quaternion)StackObject.ToObject(a, intp.AppDomain, mStack); |
| | | intp.Free(ptr); |
| | | } |
| | | } |
| | | |
| | | void PushQuaternion(ref Quaternion vec, ILIntepreter intp, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | intp.AllocValueType(ptr, CLRType); |
| | | var dst = *((StackObject**)&ptr->Value); |
| | | CopyValueTypeToStack(ref vec, dst, mStack); |
| | | } |
| | | |
| | | void PushVector3(ref Vector3 vec, ILIntepreter intp, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | var binder = Vector3Binder; |
| | | if (binder != null) |
| | | binder.PushVector3(ref vec, intp, ptr, mStack); |
| | | else |
| | | ILIntepreter.PushObject(ptr, mStack, vec, true); |
| | | } |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: e5e2a12f16432dd41b19583a42ca0e9d |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | using UnityEngine; |
| | | using System.Collections.Generic; |
| | | using ILRuntime.Other; |
| | | using System; |
| | | using System.Reflection; |
| | | using ILRuntime.Runtime.Enviorment; |
| | | using ILRuntime.Runtime.Intepreter; |
| | | using ILRuntime.CLR.Method; |
| | | using ILRuntime.CLR.TypeSystem; |
| | | using ILRuntime.Runtime.Stack; |
| | | |
| | | public unsafe class Vector2Binder : ValueTypeBinder<Vector2> |
| | | { |
| | | Vector3Binder vector3Binder; |
| | | bool vector3BinderGot; |
| | | |
| | | Vector3Binder Vector3Binder |
| | | { |
| | | get |
| | | { |
| | | if (!vector3BinderGot) |
| | | { |
| | | vector3BinderGot = true; |
| | | var vector3Type = CLRType.AppDomain.GetType(typeof(Vector3)) as CLRType; |
| | | vector3Binder = vector3Type.ValueTypeBinder as Vector3Binder; |
| | | } |
| | | |
| | | return vector3Binder; |
| | | } |
| | | } |
| | | |
| | | public override unsafe void AssignFromStack(ref Vector2 ins, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | var v = ILIntepreter.Minus(ptr, 1); |
| | | ins.x = *(float*)&v->Value; |
| | | v = ILIntepreter.Minus(ptr, 2); |
| | | ins.y = *(float*)&v->Value; |
| | | } |
| | | |
| | | public override unsafe void CopyValueTypeToStack(ref Vector2 ins, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | var v = ILIntepreter.Minus(ptr, 1); |
| | | *(float*)&v->Value = ins.x; |
| | | v = ILIntepreter.Minus(ptr, 2); |
| | | *(float*)&v->Value = ins.y; |
| | | } |
| | | public override void RegisterCLRRedirection(ILRuntime.Runtime.Enviorment.AppDomain appdomain) |
| | | { |
| | | BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; |
| | | MethodBase method; |
| | | Type[] args; |
| | | Type type = typeof(Vector2); |
| | | args = new Type[] { typeof(float), typeof(float) }; |
| | | method = type.GetConstructor(flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, NewVector2); |
| | | |
| | | args = new Type[] { typeof(Vector2), typeof(Vector2) }; |
| | | method = type.GetMethod("op_Addition", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Add); |
| | | |
| | | args = new Type[] { typeof(Vector2), typeof(Vector2) }; |
| | | method = type.GetMethod("op_Subtraction", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Subtraction); |
| | | |
| | | args = new Type[] { typeof(Vector2), typeof(float) }; |
| | | method = type.GetMethod("op_Multiply", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Multiply); |
| | | |
| | | args = new Type[] { typeof(float), typeof(Vector2) }; |
| | | method = type.GetMethod("op_Multiply", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Multiply2); |
| | | |
| | | args = new Type[] { typeof(Vector2), typeof(float) }; |
| | | method = type.GetMethod("op_Division", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Division); |
| | | |
| | | args = new Type[] { typeof(Vector2) }; |
| | | method = type.GetMethod("op_UnaryNegation", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Negate); |
| | | |
| | | args = new Type[] { typeof(Vector2), typeof(Vector2) }; |
| | | method = type.GetMethod("op_Equality", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Equality); |
| | | |
| | | args = new Type[] { typeof(Vector2), typeof(Vector2) }; |
| | | method = type.GetMethod("op_Inequality", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Inequality); |
| | | |
| | | args = new Type[] { typeof(Vector2) }; |
| | | method = type.GetMethod("op_Implicit", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Implicit); |
| | | |
| | | args = new Type[] { typeof(Vector3) }; |
| | | method = type.GetMethod("op_Implicit", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Implicit2); |
| | | |
| | | args = new Type[] { typeof(Vector2), typeof(Vector2) }; |
| | | method = type.GetMethod("Dot", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Dot); |
| | | |
| | | args = new Type[] { typeof(Vector2), typeof(Vector2) }; |
| | | method = type.GetMethod("Distance", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector2_Distance); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_magnitude", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_Magnitude); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_sqrMagnitude", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_SqrMagnitude); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_normalized", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_Normalized); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_one", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_One); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_zero", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_Zero); |
| | | } |
| | | |
| | | StackObject* Vector2_Add(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector2 left, right; |
| | | ParseVector2(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector2(out left, intp, ptr, mStack); |
| | | |
| | | var res = left + right; |
| | | PushVector2(ref res, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector2_Subtraction(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector2 left, right; |
| | | ParseVector2(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector2(out left, intp, ptr, mStack); |
| | | |
| | | var res = left - right; |
| | | PushVector2(ref res, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector2_Multiply(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | var b = ILIntepreter.GetObjectAndResolveReference(ptr); |
| | | |
| | | float val = *(float*)&b->Value; |
| | | |
| | | Vector2 vec; |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector2(out vec, intp, ptr, mStack); |
| | | |
| | | vec = vec * val; |
| | | PushVector2(ref vec, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector2_Multiply2(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | Vector2 vec; |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | ParseVector2(out vec, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | var b = ILIntepreter.GetObjectAndResolveReference(ptr); |
| | | |
| | | float val = *(float*)&b->Value; |
| | | |
| | | vec = val * vec; |
| | | PushVector2(ref vec, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector2_Division(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | var b = ILIntepreter.GetObjectAndResolveReference(ptr); |
| | | |
| | | float val = *(float*)&b->Value; |
| | | |
| | | Vector2 vec; |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector2(out vec, intp, ptr, mStack); |
| | | |
| | | vec = vec / val; |
| | | PushVector2(ref vec, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector2_Negate(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector2 vec; |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 1); |
| | | ParseVector2(out vec, intp, ptr, mStack); |
| | | |
| | | vec = -vec; |
| | | PushVector2(ref vec, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector2_Implicit(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector2 vec; |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 1); |
| | | ParseVector2(out vec, intp, ptr, mStack); |
| | | |
| | | Vector3 res = vec; |
| | | PushVector3(ref res, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector2_Implicit2(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector3 vec; |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector3Binder.ParseVector3(out vec, intp, ptr, mStack); |
| | | |
| | | Vector2 res = vec; |
| | | PushVector2(ref res, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector2_Equality(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector2 left, right; |
| | | ParseVector2(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector2(out left, intp, ptr, mStack); |
| | | |
| | | var res = left == right; |
| | | |
| | | ret->ObjectType = ObjectTypes.Integer; |
| | | ret->Value = res ? 1 : 0; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector2_Inequality(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector2 left, right; |
| | | ParseVector2(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector2(out left, intp, ptr, mStack); |
| | | |
| | | var res = left != right; |
| | | |
| | | ret->ObjectType = ObjectTypes.Integer; |
| | | ret->Value = res ? 1 : 0; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector2_Dot(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector2 left, right; |
| | | ParseVector2(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector2(out left, intp, ptr, mStack); |
| | | |
| | | var res = Vector3.Dot(left, right); |
| | | |
| | | ret->ObjectType = ObjectTypes.Float; |
| | | *(float*)&ret->Value = res; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector2_Distance(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector2 left, right; |
| | | ParseVector2(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector2(out left, intp, ptr, mStack); |
| | | |
| | | var res = Vector3.Distance(left, right); |
| | | |
| | | ret->ObjectType = ObjectTypes.Float; |
| | | *(float*)&ret->Value = res; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* NewVector2(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | StackObject* ret; |
| | | if (isNewObj) |
| | | { |
| | | ret = ILIntepreter.Minus(esp, 1); |
| | | Vector2 vec; |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | vec.y = *(float*)&ptr->Value; |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | vec.x = *(float*)&ptr->Value; |
| | | |
| | | PushVector2(ref vec, intp, ptr, mStack); |
| | | } |
| | | else |
| | | { |
| | | ret = ILIntepreter.Minus(esp, 3); |
| | | var instance = ILIntepreter.GetObjectAndResolveReference(ret); |
| | | var dst = *(StackObject**)&instance->Value; |
| | | var f = ILIntepreter.Minus(dst, 1); |
| | | var v = ILIntepreter.Minus(esp, 2); |
| | | *f = *v; |
| | | |
| | | f = ILIntepreter.Minus(dst, 2); |
| | | v = ILIntepreter.Minus(esp, 1); |
| | | *f = *v; |
| | | } |
| | | return ret; |
| | | } |
| | | |
| | | StackObject* Get_Magnitude(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector2 vec; |
| | | ParseVector2(out vec, intp, ptr, mStack); |
| | | |
| | | float res = vec.magnitude; |
| | | |
| | | ret->ObjectType = ObjectTypes.Float; |
| | | *(float*)&ret->Value = res; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Get_SqrMagnitude(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector2 vec; |
| | | ParseVector2(out vec, intp, ptr, mStack); |
| | | |
| | | float res = vec.sqrMagnitude; |
| | | |
| | | ret->ObjectType = ObjectTypes.Float; |
| | | *(float*)&ret->Value = res; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Get_Normalized(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector2 vec; |
| | | ParseVector2(out vec, intp, ptr, mStack); |
| | | |
| | | var res = vec.normalized; |
| | | |
| | | PushVector2(ref res, intp, ret, mStack); |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Get_One(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = esp; |
| | | var res = Vector2.one; |
| | | PushVector2(ref res, intp, ret, mStack); |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Get_Zero(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = esp; |
| | | var res = Vector2.zero; |
| | | PushVector2(ref res, intp, ret, mStack); |
| | | return ret + 1; |
| | | } |
| | | |
| | | public static void ParseVector2(out Vector2 vec, ILIntepreter intp, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | var a = ILIntepreter.GetObjectAndResolveReference(ptr); |
| | | if (a->ObjectType == ObjectTypes.ValueTypeObjectReference) |
| | | { |
| | | var src = *(StackObject**)&a->Value; |
| | | vec.x = *(float*)&ILIntepreter.Minus(src, 1)->Value; |
| | | vec.y = *(float*)&ILIntepreter.Minus(src, 2)->Value; |
| | | intp.FreeStackValueType(ptr); |
| | | } |
| | | else |
| | | { |
| | | vec = (Vector2)StackObject.ToObject(a, intp.AppDomain, mStack); |
| | | intp.Free(ptr); |
| | | } |
| | | } |
| | | |
| | | public void PushVector2(ref Vector2 vec, ILIntepreter intp, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | intp.AllocValueType(ptr, CLRType); |
| | | var dst = *((StackObject**)&ptr->Value); |
| | | CopyValueTypeToStack(ref vec, dst, mStack); |
| | | } |
| | | |
| | | void PushVector3(ref Vector3 vec, ILIntepreter intp, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | var binder = Vector3Binder; |
| | | if (binder != null) |
| | | binder.PushVector3(ref vec, intp, ptr, mStack); |
| | | else |
| | | ILIntepreter.PushObject(ptr, mStack, vec, true); |
| | | } |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: c67e166fc0959864c95cb8a252f5c0d8 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | using UnityEngine; |
| | | using System.Collections.Generic; |
| | | using ILRuntime.Other; |
| | | using System; |
| | | using System.Reflection; |
| | | using ILRuntime.Runtime.Enviorment; |
| | | using ILRuntime.Runtime.Intepreter; |
| | | using ILRuntime.CLR.Method; |
| | | using ILRuntime.Runtime.Stack; |
| | | |
| | | public unsafe class Vector3Binder : ValueTypeBinder<Vector3> |
| | | { |
| | | public override unsafe void AssignFromStack(ref Vector3 ins, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | var v = ILIntepreter.Minus(ptr, 1); |
| | | ins.x = *(float*)&v->Value; |
| | | v = ILIntepreter.Minus(ptr, 2); |
| | | ins.y = *(float*)&v->Value; |
| | | v = ILIntepreter.Minus(ptr, 3); |
| | | ins.z = *(float*)&v->Value; |
| | | } |
| | | |
| | | public override unsafe void CopyValueTypeToStack(ref Vector3 ins, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | var v = ILIntepreter.Minus(ptr, 1); |
| | | *(float*)&v->Value = ins.x; |
| | | v = ILIntepreter.Minus(ptr, 2); |
| | | *(float*)&v->Value = ins.y; |
| | | v = ILIntepreter.Minus(ptr, 3); |
| | | *(float*)&v->Value = ins.z; |
| | | } |
| | | public override void RegisterCLRRedirection(ILRuntime.Runtime.Enviorment.AppDomain appdomain) |
| | | { |
| | | BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; |
| | | MethodBase method; |
| | | Type[] args; |
| | | Type type = typeof(Vector3); |
| | | args = new Type[] { typeof(float), typeof(float), typeof(float) }; |
| | | method = type.GetConstructor(flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, NewVector3); |
| | | |
| | | args = new Type[] { typeof(float), typeof(float) }; |
| | | method = type.GetConstructor(flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, NewVector3_2); |
| | | |
| | | args = new Type[] { typeof(Vector3), typeof(Vector3) }; |
| | | method = type.GetMethod("op_Addition", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector3_Add); |
| | | |
| | | args = new Type[] { typeof(Vector3), typeof(Vector3) }; |
| | | method = type.GetMethod("op_Subtraction", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector3_Subtraction); |
| | | |
| | | args = new Type[] { typeof(Vector3), typeof(float) }; |
| | | method = type.GetMethod("op_Multiply", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector3_Multiply); |
| | | |
| | | args = new Type[] { typeof(float), typeof(Vector3) }; |
| | | method = type.GetMethod("op_Multiply", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector3_Multiply2); |
| | | |
| | | args = new Type[] { typeof(Vector3), typeof(float) }; |
| | | method = type.GetMethod("op_Division", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector3_Division); |
| | | |
| | | args = new Type[] { typeof(Vector3) }; |
| | | method = type.GetMethod("op_UnaryNegation", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector3_Negate); |
| | | |
| | | args = new Type[] { typeof(Vector3), typeof(Vector3) }; |
| | | method = type.GetMethod("op_Equality", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector3_Equality); |
| | | |
| | | args = new Type[] { typeof(Vector3), typeof(Vector3) }; |
| | | method = type.GetMethod("op_Inequality", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector3_Inequality); |
| | | |
| | | args = new Type[] { typeof(Vector3), typeof(Vector3) }; |
| | | method = type.GetMethod("Dot", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector3_Dot); |
| | | |
| | | args = new Type[] { typeof(Vector3), typeof(Vector3) }; |
| | | method = type.GetMethod("Cross", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector3_Cross); |
| | | |
| | | args = new Type[] { typeof(Vector3), typeof(Vector3) }; |
| | | method = type.GetMethod("Distance", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Vector3_Distance); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_magnitude", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_Magnitude); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_sqrMagnitude", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_SqrMagnitude); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_normalized", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_Normalized); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_one", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_One); |
| | | |
| | | args = new Type[] { }; |
| | | method = type.GetMethod("get_zero", flag, null, args, null); |
| | | appdomain.RegisterCLRMethodRedirection(method, Get_Zero); |
| | | } |
| | | |
| | | StackObject* Vector3_Add(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector3 left, right; |
| | | ParseVector3(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector3(out left, intp, ptr, mStack); |
| | | |
| | | var res = left + right; |
| | | PushVector3(ref res, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector3_Subtraction(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector3 left, right; |
| | | ParseVector3(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector3(out left, intp, ptr, mStack); |
| | | |
| | | var res = left - right; |
| | | PushVector3(ref res, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector3_Multiply(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | var b = ILIntepreter.GetObjectAndResolveReference(ptr); |
| | | |
| | | float val = *(float*)&b->Value; |
| | | |
| | | Vector3 vec; |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector3(out vec, intp, ptr, mStack); |
| | | |
| | | vec = vec * val; |
| | | PushVector3(ref vec, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector3_Multiply2(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | Vector3 vec; |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | ParseVector3(out vec, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | var b = ILIntepreter.GetObjectAndResolveReference(ptr); |
| | | |
| | | float val = *(float*)&b->Value; |
| | | |
| | | vec = val * vec; |
| | | PushVector3(ref vec, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector3_Division(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | var b = ILIntepreter.GetObjectAndResolveReference(ptr); |
| | | |
| | | float val = *(float*)&b->Value; |
| | | |
| | | Vector3 vec; |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector3(out vec, intp, ptr, mStack); |
| | | |
| | | vec = vec / val; |
| | | PushVector3(ref vec, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector3_Negate(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector3 vec; |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 1); |
| | | ParseVector3(out vec, intp, ptr, mStack); |
| | | |
| | | vec = -vec; |
| | | PushVector3(ref vec, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector3_Equality(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector3 left, right; |
| | | ParseVector3(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector3(out left, intp, ptr, mStack); |
| | | |
| | | var res = left == right; |
| | | |
| | | ret->ObjectType = ObjectTypes.Integer; |
| | | ret->Value = res ? 1 : 0; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector3_Inequality(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector3 left, right; |
| | | ParseVector3(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector3(out left, intp, ptr, mStack); |
| | | |
| | | var res = left != right; |
| | | |
| | | ret->ObjectType = ObjectTypes.Integer; |
| | | ret->Value = res ? 1 : 0; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector3_Dot(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector3 left, right; |
| | | ParseVector3(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector3(out left, intp, ptr, mStack); |
| | | |
| | | var res = Vector3.Dot(left, right); |
| | | |
| | | ret->ObjectType = ObjectTypes.Float; |
| | | *(float*)&ret->Value = res; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector3_Distance(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector3 left, right; |
| | | ParseVector3(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector3(out left, intp, ptr, mStack); |
| | | |
| | | var res = Vector3.Distance(left, right); |
| | | |
| | | ret->ObjectType = ObjectTypes.Float; |
| | | *(float*)&ret->Value = res; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Vector3_Cross(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 2); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | |
| | | Vector3 left, right; |
| | | ParseVector3(out right, intp, ptr, mStack); |
| | | |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | ParseVector3(out left, intp, ptr, mStack); |
| | | |
| | | var res = Vector3.Cross(left, right); |
| | | PushVector3(ref res, intp, ret, mStack); |
| | | |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* NewVector3(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | StackObject* ret; |
| | | if (isNewObj) |
| | | { |
| | | ret = ILIntepreter.Minus(esp, 2); |
| | | Vector3 vec; |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | vec.z = *(float*)&ptr->Value; |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | vec.y = *(float*)&ptr->Value; |
| | | ptr = ILIntepreter.Minus(esp, 3); |
| | | vec.x = *(float*)&ptr->Value; |
| | | |
| | | PushVector3(ref vec, intp, ptr, mStack); |
| | | } |
| | | else |
| | | { |
| | | ret = ILIntepreter.Minus(esp, 4); |
| | | var instance = ILIntepreter.GetObjectAndResolveReference(ret); |
| | | var dst = *(StackObject**)&instance->Value; |
| | | var f = ILIntepreter.Minus(dst, 1); |
| | | var v = ILIntepreter.Minus(esp, 3); |
| | | *f = *v; |
| | | |
| | | f = ILIntepreter.Minus(dst, 2); |
| | | v = ILIntepreter.Minus(esp, 2); |
| | | *f = *v; |
| | | |
| | | f = ILIntepreter.Minus(dst, 3); |
| | | v = ILIntepreter.Minus(esp, 1); |
| | | *f = *v; |
| | | } |
| | | return ret; |
| | | } |
| | | StackObject* NewVector3_2(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | StackObject* ret; |
| | | if (isNewObj) |
| | | { |
| | | ret = ILIntepreter.Minus(esp, 1); |
| | | Vector3 vec; |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | vec.y = *(float*)&ptr->Value; |
| | | ptr = ILIntepreter.Minus(esp, 2); |
| | | vec.x = *(float*)&ptr->Value; |
| | | vec.z = 0; |
| | | |
| | | PushVector3(ref vec, intp, ptr, mStack); |
| | | } |
| | | else |
| | | { |
| | | ret = ILIntepreter.Minus(esp, 3); |
| | | var instance = ILIntepreter.GetObjectAndResolveReference(ret); |
| | | var dst = *(StackObject**)&instance->Value; |
| | | var f = ILIntepreter.Minus(dst, 1); |
| | | var v = ILIntepreter.Minus(esp, 2); |
| | | *f = *v; |
| | | |
| | | f = ILIntepreter.Minus(dst, 2); |
| | | v = ILIntepreter.Minus(esp, 1); |
| | | *f = *v; |
| | | |
| | | f = ILIntepreter.Minus(dst, 3); |
| | | *(float*)&f->Value = 0f; |
| | | } |
| | | return ret; |
| | | } |
| | | |
| | | StackObject* Get_Magnitude(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector3 vec; |
| | | ParseVector3(out vec, intp, ptr, mStack); |
| | | |
| | | float res = vec.magnitude; |
| | | |
| | | ret->ObjectType = ObjectTypes.Float; |
| | | *(float*)&ret->Value = res; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Get_SqrMagnitude(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector3 vec; |
| | | ParseVector3(out vec, intp, ptr, mStack); |
| | | |
| | | float res = vec.sqrMagnitude; |
| | | |
| | | ret->ObjectType = ObjectTypes.Float; |
| | | *(float*)&ret->Value = res; |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Get_Normalized(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = ILIntepreter.Minus(esp, 1); |
| | | var ptr = ILIntepreter.Minus(esp, 1); |
| | | Vector3 vec; |
| | | ParseVector3(out vec, intp, ptr, mStack); |
| | | |
| | | var res = vec.normalized; |
| | | |
| | | PushVector3(ref res, intp, ret, mStack); |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Get_One(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = esp; |
| | | var res = Vector3.one; |
| | | PushVector3(ref res, intp, ret, mStack); |
| | | return ret + 1; |
| | | } |
| | | |
| | | StackObject* Get_Zero(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj) |
| | | { |
| | | var ret = esp; |
| | | var res = Vector3.zero; |
| | | PushVector3(ref res, intp, ret, mStack); |
| | | return ret + 1; |
| | | } |
| | | |
| | | public static void ParseVector3(out Vector3 vec, ILIntepreter intp, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | var a = ILIntepreter.GetObjectAndResolveReference(ptr); |
| | | if (a->ObjectType == ObjectTypes.ValueTypeObjectReference) |
| | | { |
| | | var src = *(StackObject**)&a->Value; |
| | | vec.x = *(float*)&ILIntepreter.Minus(src, 1)->Value; |
| | | vec.y = *(float*)&ILIntepreter.Minus(src, 2)->Value; |
| | | vec.z = *(float*)&ILIntepreter.Minus(src, 3)->Value; |
| | | intp.FreeStackValueType(ptr); |
| | | } |
| | | else |
| | | { |
| | | vec = (Vector3)StackObject.ToObject(a, intp.AppDomain, mStack); |
| | | intp.Free(ptr); |
| | | } |
| | | } |
| | | |
| | | public void PushVector3(ref Vector3 vec, ILIntepreter intp, StackObject* ptr, IList<object> mStack) |
| | | { |
| | | intp.AllocValueType(ptr, CLRType); |
| | | var dst = *((StackObject**)&ptr->Value); |
| | | CopyValueTypeToStack(ref vec, dst, mStack); |
| | | } |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 5d1e5f2c3e980eb4ca3a46ab89ee9ff2 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | using System.Collections.Generic; |
| | | using ILRuntime.CLR.Method; |
| | | using ILRuntime.Runtime.Enviorment; |
| | | using ILRuntime.Runtime.Intepreter; |
| | | using UnityEngine; |
| | | |
| | | |
| | | /// <summary> |
| | | /// çæ´å·¥ç¨ä½¿ç¨monovehaviorçåºç¡ä»£çç±» |
| | | /// </summary> |
| | | public class ILBehaviourProxy : WidgetBehavior |
| | | { |
| | | [SerializeField] |
| | | [Tooltip("Logicå·¥ç¨ç代ç ï¼ä¾ï¼å½å空é´.ç±»å")] |
| | | List<string> classNames; |
| | | Dictionary<string, ILBehaviourHolder> ilBehaviourHolders = new Dictionary<string, ILBehaviourHolder>(); |
| | | AppDomain appDomain |
| | | { |
| | | get { return ILLauncherProxy.Instance.appdomain; } |
| | | } |
| | | |
| | | private void Init() |
| | | { |
| | | InitWidgts(); |
| | | ilBehaviourHolders.Clear(); |
| | | var baseType = appDomain.LoadedTypes["ILBehaviour"]; |
| | | foreach (var name in classNames) |
| | | { |
| | | if (ilBehaviourHolders.ContainsKey(name)) |
| | | { |
| | | DebugEx.LogErrorFormat("ILBehaviour èæ¬ä»£ç æéå¤é¡¹ï¼{0}", name); |
| | | continue; |
| | | } |
| | | var obj = appDomain.Instantiate(name); |
| | | if (obj == null) |
| | | { |
| | | DebugEx.LogErrorFormat("ILBehaviour èæ¬ä»£ç ä¸åå¨ï¼{0}", name); |
| | | continue; |
| | | } |
| | | var setProxy = baseType.GetMethod("SetProxy", 1); |
| | | appDomain.Invoke(setProxy, obj, this);//å°å½å代çå¯¹è±¡ä¼ è¿å» |
| | | |
| | | var holder = new ILBehaviourHolder(obj); |
| | | |
| | | //æ¤å¤ç¨typeè·åçæ¹æ³ï¼åç±»ä¸å®ä¹æ¯ä¸ä¼æ§è¡Logicå·¥ç¨ç¶ç±»çæ¹æ³ |
| | | var type = obj.Type; |
| | | |
| | | holder.awake = type.GetMethod("Awake"); |
| | | holder.start = type.GetMethod("Start"); |
| | | holder.onEnable = type.GetMethod("OnEnable"); |
| | | holder.onDisable = type.GetMethod("OnDisable"); |
| | | holder.update = type.GetMethod("Update"); |
| | | holder.fixedUpdate = type.GetMethod("FixedUpdate"); |
| | | holder.lateUpdate = type.GetMethod("LateUpdate"); |
| | | holder.onDestroy = type.GetMethod("OnDestroy", 0); |
| | | |
| | | //baseType è·åçæ¹æ³ï¼æä¼æ§è¡ç¶ç±»Logicå·¥ç¨çç¶ç±»æ¹æ³ï¼ä½åæ¶ä¹ä¸ä¼è°ç¨åç±»éåçæ¹æ³ |
| | | holder.dipose = baseType.GetMethod("Dipose", 0); |
| | | |
| | | ilBehaviourHolders.Add(name, holder); |
| | | } |
| | | } |
| | | |
| | | //è·åILçæ´å·¥ç¨çèæ¬å®ä¾ï¼ä¾çæ´å·¥ç¨è°ç¨ï¼ä¸è¦å¨ä¸»å·¥ç¨ä½¿ç¨ |
| | | public object GetILBehaviour(string name) |
| | | { |
| | | ILBehaviourHolder holder; |
| | | if (ilBehaviourHolders.TryGetValue(name, out holder)) |
| | | return holder.instance; |
| | | else |
| | | return null; |
| | | } |
| | | |
| | | private void Awake() |
| | | { |
| | | Init(); |
| | | foreach (var name in classNames) |
| | | { |
| | | ILBehaviourHolder holder; |
| | | if (ilBehaviourHolders.TryGetValue(name, out holder)) |
| | | { |
| | | if (holder.awake != null) |
| | | appDomain.Invoke(holder.awake, holder.instance); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void Start() |
| | | { |
| | | foreach (var name in classNames) |
| | | { |
| | | ILBehaviourHolder holder; |
| | | if (ilBehaviourHolders.TryGetValue(name, out holder)) |
| | | { |
| | | if (holder.start != null) |
| | | appDomain.Invoke(holder.start, holder.instance); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void OnEnable() |
| | | { |
| | | foreach (var name in classNames) |
| | | { |
| | | ILBehaviourHolder holder; |
| | | if (ilBehaviourHolders.TryGetValue(name, out holder)) |
| | | { |
| | | if (holder.onEnable != null) |
| | | appDomain.Invoke(holder.onEnable, holder.instance); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void OnDisable() |
| | | { |
| | | foreach (var name in classNames) |
| | | { |
| | | ILBehaviourHolder holder; |
| | | if (ilBehaviourHolders.TryGetValue(name, out holder)) |
| | | { |
| | | if (holder.onDisable != null) |
| | | appDomain.Invoke(holder.onDisable, holder.instance); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void Update() |
| | | { |
| | | foreach (var name in classNames) |
| | | { |
| | | ILBehaviourHolder holder; |
| | | if (ilBehaviourHolders.TryGetValue(name, out holder)) |
| | | { |
| | | if (holder.update != null) |
| | | appDomain.Invoke(holder.update, holder.instance); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void FixedUpdate() |
| | | { |
| | | foreach (var name in classNames) |
| | | { |
| | | ILBehaviourHolder holder; |
| | | if (ilBehaviourHolders.TryGetValue(name, out holder)) |
| | | { |
| | | if (holder.fixedUpdate != null) |
| | | appDomain.Invoke(holder.fixedUpdate, holder.instance); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | foreach (var name in classNames) |
| | | { |
| | | ILBehaviourHolder holder; |
| | | if (ilBehaviourHolders.TryGetValue(name, out holder)) |
| | | { |
| | | if (holder.lateUpdate != null) |
| | | appDomain.Invoke(holder.lateUpdate, holder.instance); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void OnDestroy() |
| | | { |
| | | |
| | | foreach (var name in classNames) |
| | | { |
| | | ILBehaviourHolder holder; |
| | | if (ilBehaviourHolders.TryGetValue(name, out holder)) |
| | | { |
| | | if (appDomain != null && holder.onDestroy != null) |
| | | appDomain?.Invoke(holder.onDestroy, holder.instance); |
| | | if (appDomain != null && holder.dipose != null) |
| | | appDomain?.Invoke(holder.dipose, holder.instance); |
| | | } |
| | | } |
| | | ilBehaviourHolders.Clear(); |
| | | } |
| | | |
| | | private class ILBehaviourHolder |
| | | { |
| | | public object instance; |
| | | public IMethod awake, start, onEnable, onDisable, update, fixedUpdate, lateUpdate, onDestroy; |
| | | public IMethod dipose; |
| | | |
| | | public ILBehaviourHolder(object instance) |
| | | { |
| | | this.instance = instance; |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 0972c9814fd923f459dfe2411b6ccb50 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using ILCrossBinding; |
| | | using ILRuntime.CLR.Method; |
| | | using ILRuntime.Mono.Cecil.Pdb; |
| | | using ILRuntime.Runtime.Intepreter; |
| | | using Snxxz.UI; |
| | | using UnityEngine; |
| | | |
| | | public class ILLauncherProxy : SingletonMonobehaviour<ILLauncherProxy> |
| | | { |
| | | FileStream dllFS, pdbFS; |
| | | |
| | | private ILRuntime.Runtime.Enviorment.AppDomain _appdomain; |
| | | |
| | | public ILRuntime.Runtime.Enviorment.AppDomain appdomain |
| | | { |
| | | get |
| | | { |
| | | return _appdomain; |
| | | } |
| | | } |
| | | |
| | | public bool started; |
| | | |
| | | ILTypeInstance launcherInstance; |
| | | |
| | | IMethod update, onDestroy; |
| | | |
| | | public void Init() |
| | | { |
| | | started = false; |
| | | LoadILRuntime(); |
| | | //ç±äºUnityçProfileræ¥å£åªå
许å¨ä¸»çº¿ç¨ä½¿ç¨ï¼ä¸ºäºé¿å
åºå¼å¸¸ï¼éè¦åè¯ILRuntime主线ç¨ç线ç¨IDæè½æ£ç¡®å°å½æ°è¿è¡èæ¶æ¥åç»Profiler |
| | | #if UNITY_EDITOR |
| | | _appdomain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; |
| | | #endif |
| | | //对LitJsonè¿è¡æ³¨å |
| | | LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(_appdomain); |
| | | RegisterCrossBindingAdaptor(); |
| | | RegisterValueTypeBinder(); |
| | | RegisterDelegate(); |
| | | #if UNITY_EDITOR |
| | | // CLRBindings æ¯å¨æçæåºæ¥çï¼editorä¸å¯è½ä¸åå¨ï¼æä»¥ä½¿ç¨åå°æ¹å¼è°ç¨ |
| | | var type = Type.GetType("ILRuntime.Runtime.Generated.CLRBindings"); |
| | | if (type != null) |
| | | { |
| | | var m = type.GetMethod("Initialize"); |
| | | m.Invoke(null, new object[] { appdomain }); |
| | | } |
| | | #else |
| | | ILRuntime.Runtime.Generated.CLRBindings.Initialize(_appdomain); |
| | | #endif |
| | | } |
| | | |
| | | void LoadILRuntime() |
| | | { |
| | | _appdomain = new ILRuntime.Runtime.Enviorment.AppDomain(); |
| | | var dllPath = string.Empty; |
| | | var pdbPath = string.Empty; |
| | | if (AssetSource.logicFromEditor) |
| | | { |
| | | dllPath = ResourcesPath.ResourcesOutAssetPath + "logic/Logic.dll.bytes"; |
| | | pdbPath = ResourcesPath.ResourcesOutAssetPath + "logic/Logic.pdb"; |
| | | } |
| | | else |
| | | { |
| | | dllPath = AssetVersionUtility.GetAssetFilePath("logic/Logic.dll.bytes"); |
| | | pdbPath = AssetVersionUtility.GetAssetFilePath("logic/Logic.pdb"); |
| | | } |
| | | if (!File.Exists(dllPath)) |
| | | { |
| | | DebugEx.LogErrorFormat("æ¾ä¸å°çæ´ä»£ç ï¼{0}", dllPath); |
| | | return; |
| | | } |
| | | |
| | | dllFS = new FileStream(dllPath, FileMode.Open); |
| | | if (VersionConfig.Get().debugVersion && File.Exists(pdbPath)) |
| | | pdbFS = new FileStream(pdbPath, FileMode.Open); |
| | | _appdomain.LoadAssembly(dllFS, pdbFS, new PdbReaderProvider()); |
| | | } |
| | | |
| | | //注åè·¨åç»§æ¿éé
å¨ |
| | | private void RegisterCrossBindingAdaptor() |
| | | { |
| | | appdomain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); |
| | | appdomain.RegisterCrossBindingAdaptor(new DtcBasicAdapter()); |
| | | appdomain.RegisterCrossBindingAdaptor(new GameNetPackBasicAdapter()); |
| | | } |
| | | |
| | | //注åå¼ç±»åç»å® |
| | | private void RegisterValueTypeBinder() |
| | | { |
| | | appdomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); |
| | | appdomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); |
| | | appdomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); |
| | | } |
| | | |
| | | //注åå§æ |
| | | private void RegisterDelegate() |
| | | { |
| | | //æ è¿åå¼ |
| | | appdomain.DelegateManager.RegisterMethodDelegate<int>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<long>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<string>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<float>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<double>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<bool>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<byte[]>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<bool, bool>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<bool, string>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<int, string>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<int, float>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<string, int>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<int, bool, string>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<int, int>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<int, bool>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<bool, int>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<ulong>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<uint>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<Snxxz.UI.Operation>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<float, Vector2>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<int, Transform>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<Vector2>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<Vector3>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<Transform>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<GameObject>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<Component>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<E_AttackMode>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<PlayerDataType>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<PlayerDataType, int>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<List<Vector3>>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<ChatData>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<VoiceHttpRequest.VoiceDecodec>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<Snxxz.UI.ComposeMatCell, NeedMatType>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<ItemCompoundConfig, int>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<Snxxz.UI.ComposeMatCell, int, SelectItemType>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<GroupType, bool>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<PackType, int>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<PackType, string>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<PackType, int, int>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<SystemSwitch, bool>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<ChatBoolType, bool>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<E_NpcType, int, uint>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<TeamInviteType>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<Snxxz.UI.PlayerDetails.DetailType>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<FunctionUnlockType>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<TreasureCategory>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<Window>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<TimeMgr.SyntonyType>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<DateTime>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<System.Object>(); |
| | | appdomain.DelegateManager.RegisterMethodDelegate<global::ScrollerDataType, global::CellView>(); |
| | | |
| | | //æè¿åå¼ |
| | | appdomain.DelegateManager.RegisterFunctionDelegate<int>(); |
| | | appdomain.DelegateManager.RegisterFunctionDelegate<bool>(); |
| | | appdomain.DelegateManager.RegisterFunctionDelegate<long>(); |
| | | appdomain.DelegateManager.RegisterFunctionDelegate<string>(); |
| | | appdomain.DelegateManager.RegisterFunctionDelegate<float>(); |
| | | appdomain.DelegateManager.RegisterFunctionDelegate<double>(); |
| | | appdomain.DelegateManager.RegisterFunctionDelegate<int, bool>(); |
| | | appdomain.DelegateManager.RegisterFunctionDelegate<System.Int32, System.Int32, System.Int32>(); |
| | | appdomain.DelegateManager.RegisterFunctionDelegate<ILRuntime.Runtime.Intepreter.ILTypeInstance, ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int32>(); |
| | | |
| | | //èªå®ä¹å§æè½¬æ¢ |
| | | appdomain.DelegateManager.RegisterDelegateConvertor<UnityEngine.Events.UnityAction>((action) => |
| | | { |
| | | return new UnityEngine.Events.UnityAction(() => |
| | | { |
| | | ((System.Action)action)(); |
| | | }); |
| | | }); |
| | | appdomain.DelegateManager.RegisterDelegateConvertor<System.Threading.WaitCallback>((act) => |
| | | { |
| | | return new System.Threading.WaitCallback((state) => |
| | | { |
| | | ((Action<System.Object>)act)(state); |
| | | }); |
| | | }); |
| | | appdomain.DelegateManager.RegisterDelegateConvertor<System.Comparison<System.Int32>>((act) => |
| | | { |
| | | return new System.Comparison<System.Int32>((x, y) => |
| | | { |
| | | return ((Func<System.Int32, System.Int32, System.Int32>)act)(x, y); |
| | | }); |
| | | }); |
| | | appdomain.DelegateManager.RegisterDelegateConvertor<global::ScrollerController.OnRefreshCellDelegate>((act) => |
| | | { |
| | | return new global::ScrollerController.OnRefreshCellDelegate((type, cell) => |
| | | { |
| | | ((Action<global::ScrollerDataType, global::CellView>)act)(type, cell); |
| | | }); |
| | | }); |
| | | appdomain.DelegateManager.RegisterDelegateConvertor<System.Comparison<ILRuntime.Runtime.Intepreter.ILTypeInstance>>((act) => |
| | | { |
| | | return new System.Comparison<ILRuntime.Runtime.Intepreter.ILTypeInstance>((x, y) => |
| | | { |
| | | return ((Func<ILRuntime.Runtime.Intepreter.ILTypeInstance, ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int32>)act)(x, y); |
| | | }); |
| | | }); |
| | | |
| | | } |
| | | |
| | | public void LaunchStart() |
| | | { |
| | | #if UNITY_EDITOR |
| | | _appdomain.DebugService.StartDebugService(56000); |
| | | #endif |
| | | launcherInstance = appdomain.Instantiate("LogicLauncher"); |
| | | var type = launcherInstance.Type; |
| | | update = type.GetMethod("Update"); |
| | | onDestroy = type.GetMethod("OnDestroy", 0); |
| | | |
| | | _appdomain.Invoke("LogicLauncher", "LaunchStart", launcherInstance, null); |
| | | } |
| | | |
| | | private void Update() |
| | | { |
| | | if (update != null) |
| | | appdomain.Invoke(update, launcherInstance); |
| | | } |
| | | |
| | | protected override void OnDestroy() |
| | | { |
| | | base.OnDestroy(); |
| | | |
| | | if (onDestroy != null) |
| | | appdomain.Invoke(onDestroy, launcherInstance); |
| | | |
| | | #if UNITY_EDITOR |
| | | var type = Type.GetType("ILRuntime.Runtime.Generated.CLRBindings"); |
| | | if (type != null) |
| | | { |
| | | var m = type.GetMethod("Shutdown"); |
| | | m.Invoke(null, new object[] { appdomain }); |
| | | } |
| | | #else |
| | | ILRuntime.Runtime.Generated.CLRBindings.Shutdown(appDomain); |
| | | #endif |
| | | dllFS?.Close(); |
| | | pdbFS?.Close(); |
| | | } |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: c019f0e1c95d1d64b9eee16ffaccb910 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | using ILRuntime.CLR.Method; |
| | | using ILRuntime.Runtime.Enviorment; |
| | | using ILRuntime.Runtime.Intepreter; |
| | | using Snxxz.UI; |
| | | using UnityEngine; |
| | | |
| | | /// <summary> |
| | | /// çæ´å·¥ç¨ä½¿ç¨ä¸çº§çªå£çåºç¡ä»£çç±» |
| | | /// </summary> |
| | | public class ILOneLevelWindowProxy : OneLevelWin |
| | | { |
| | | |
| | | ILTypeInstance obj; |
| | | |
| | | IMethod bindController, addListeners, onPreOpen, onAfterOpen, onPreClose, onAfterClose, onDestroy, lateUpdate, onActived; |
| | | IMethod dipose; |
| | | AppDomain appDomain |
| | | { |
| | | get { return ILLauncherProxy.Instance.appdomain; } |
| | | } |
| | | private void Init() |
| | | { |
| | | InitWidgts(); |
| | | //使ç¨ä¸é¢å¶ååçä»£ç æä»¶ |
| | | var windowName = gameObject.name; |
| | | var baseType = appDomain.LoadedTypes["ILOneLevelWindow"]; |
| | | obj = appDomain.Instantiate(windowName); |
| | | if (obj == null) |
| | | { |
| | | DebugEx.LogErrorFormat("ILWindow çæ´ä»£ç ä¸åå¨ï¼{0}", windowName); |
| | | return; |
| | | } |
| | | var setProxy = baseType.GetMethod("SetProxy", 1); |
| | | appDomain.Invoke(setProxy, obj, this);//å°å½å代çå¯¹è±¡ä¼ è¿å» |
| | | |
| | | //æ¤å¤ç¨typeè·åçæ¹æ³ï¼åç±»ä¸å®ä¹æ¯ä¸ä¼æ§è¡Logicå·¥ç¨ç¶ç±»çæ¹æ³ |
| | | var type = obj.Type; |
| | | |
| | | bindController = type.GetMethod("BindController"); |
| | | addListeners = type.GetMethod("AddListeners"); |
| | | onPreOpen = type.GetMethod("OnPreOpen"); |
| | | onAfterOpen = type.GetMethod("OnAfterOpen"); |
| | | onPreClose = type.GetMethod("OnPreClose"); |
| | | onAfterClose = type.GetMethod("OnAfterClose"); |
| | | onDestroy = type.GetMethod("OnDestroy"); |
| | | |
| | | lateUpdate = type.GetMethod("LateUpdate"); |
| | | onActived = type.GetMethod("OnActived"); |
| | | |
| | | //baseType è·åçæ¹æ³ï¼æä¼æ§è¡ç¶ç±»Logicå·¥ç¨çç¶ç±»æ¹æ³,ä½åæ¶ä¹ä¸ä¼è°ç¨åç±»éåçæ¹æ³ |
| | | dipose = baseType.GetMethod("Dipose", 0); |
| | | } |
| | | |
| | | public void CloseAllChildWindow() |
| | | { |
| | | CloseSubWindows(); |
| | | } |
| | | |
| | | protected override void OnActived() |
| | | { |
| | | base.OnActived(); |
| | | if (onActived != null) |
| | | appDomain.Invoke(onActived, obj); |
| | | } |
| | | |
| | | protected override void LateUpdate() |
| | | { |
| | | base.LateUpdate(); |
| | | if (lateUpdate != null) |
| | | appDomain.Invoke(lateUpdate, obj); |
| | | } |
| | | |
| | | protected override void BindController() |
| | | { |
| | | base.BindController(); |
| | | Init(); |
| | | if (bindController != null) |
| | | appDomain.Invoke(bindController, obj); |
| | | } |
| | | protected override void AddListeners() |
| | | { |
| | | base.AddListeners(); |
| | | if (addListeners != null) |
| | | appDomain.Invoke(addListeners, obj); |
| | | } |
| | | protected override void OnPreOpen() |
| | | { |
| | | base.OnPreOpen(); |
| | | if (onPreOpen != null) |
| | | appDomain.Invoke(onPreOpen, obj); |
| | | } |
| | | protected override void OnAfterOpen() |
| | | { |
| | | base.OnAfterOpen(); |
| | | if (onAfterOpen != null) |
| | | appDomain.Invoke(onAfterOpen, obj); |
| | | } |
| | | protected override void OnPreClose() |
| | | { |
| | | base.OnPreClose(); |
| | | if (onPreClose != null) |
| | | appDomain.Invoke(onPreClose, obj); |
| | | } |
| | | protected override void OnAfterClose() |
| | | { |
| | | base.OnAfterClose(); |
| | | if (onAfterClose != null) |
| | | appDomain.Invoke(onAfterClose, obj); |
| | | } |
| | | |
| | | private void OnDestroy() |
| | | { |
| | | if (onDestroy != null) |
| | | appDomain?.Invoke(onDestroy, obj); |
| | | if (dipose != null) |
| | | appDomain?.Invoke(dipose, obj); |
| | | bindController = null; |
| | | addListeners = null; |
| | | onPreOpen = null; |
| | | onAfterOpen = null; |
| | | onPreClose = null; |
| | | onAfterClose = null; |
| | | onDestroy = null; |
| | | lateUpdate = null; |
| | | onActived = null; |
| | | obj = null; |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: a35321404ae3e28439ce53bec5fd2d55 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | |
| | | class ILRuntimeUtility : Singleton<ILRuntimeUtility> |
| | | { |
| | | |
| | | public ILRuntime.Runtime.Enviorment.AppDomain appdomain { |
| | | get { |
| | | return ILLauncherProxy.Instance.appdomain; |
| | | } |
| | | } |
| | | |
| | | public void AddEvent(string modelName, string eventName, Action action) |
| | | { |
| | | var iType = appdomain.LoadedTypes[modelName]; |
| | | var get_Instance = iType.GetMethod("get_Instance", 0); |
| | | var instance = appdomain.Invoke(get_Instance, null); |
| | | var type = iType.ReflectionType; |
| | | var eventInfo = type.GetEvent(eventName); |
| | | eventInfo.AddEventHandler(instance, action); |
| | | } |
| | | |
| | | public void RemoveEvent(string modelName, string eventName, Action action) |
| | | { |
| | | var iType = appdomain.LoadedTypes[modelName]; |
| | | var get_Instance = iType.GetMethod("get_Instance", 0); |
| | | var instance = appdomain.Invoke(get_Instance, null); |
| | | var type = iType.ReflectionType; |
| | | var eventInfo = type.GetEvent(eventName); |
| | | eventInfo.RemoveEventHandler(instance, action); |
| | | } |
| | | |
| | | public void ModelInvoke(string modelName, string methodName, params object[] p) |
| | | { |
| | | var iType = appdomain.LoadedTypes[modelName]; |
| | | var get_Instance = iType.GetMethod("get_Instance", 0); |
| | | var method = iType.GetMethod(methodName, p.Length); |
| | | var instance = appdomain.Invoke(get_Instance, null); |
| | | appdomain.Invoke(method, instance, p); |
| | | } |
| | | |
| | | public T ModelInvoke<T>(string modelName, string methodName, params object[] p) |
| | | { |
| | | var iType = appdomain.LoadedTypes[modelName]; |
| | | var get_Instance = iType.GetMethod("get_Instance", 0); |
| | | var method = iType.GetMethod(methodName, p.Length); |
| | | var instance = appdomain.Invoke(get_Instance, null); |
| | | return (T)appdomain.Invoke(method, instance, p); |
| | | } |
| | | |
| | | } |
| | | |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 66f444fc692a2574bb3939b2623c2dd7 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | using ILRuntime.CLR.Method; |
| | | using ILRuntime.Runtime.Enviorment; |
| | | using ILRuntime.Runtime.Intepreter; |
| | | using Snxxz.UI; |
| | | using UnityEngine; |
| | | |
| | | /// <summary> |
| | | /// çæ´å·¥ç¨ä½¿ç¨windowçåºç¡ä»£çç±» |
| | | /// </summary> |
| | | public class ILWindowProxy : Window |
| | | { |
| | | ILTypeInstance obj; |
| | | |
| | | IMethod bindController, addListeners, onPreOpen, onAfterOpen, onPreClose, onAfterClose, onDestroy, lateUpdate, onActived; |
| | | IMethod dipose; |
| | | AppDomain appDomain |
| | | { |
| | | get { return ILLauncherProxy.Instance.appdomain; } |
| | | } |
| | | private void Init() |
| | | { |
| | | InitWidgts(); |
| | | //使ç¨ä¸é¢å¶ååçä»£ç æä»¶ |
| | | var windowName =gameObject.name; |
| | | var baseType = appDomain.LoadedTypes["ILWindow"]; |
| | | obj = appDomain.Instantiate(windowName); |
| | | if (obj == null) |
| | | { |
| | | DebugEx.LogErrorFormat("ILWindow çæ´ä»£ç ä¸åå¨ï¼{0}", windowName); |
| | | return; |
| | | } |
| | | var setProxy = baseType.GetMethod("SetProxy", 1); |
| | | appDomain.Invoke(setProxy, obj, this);//å°å½å代çå¯¹è±¡ä¼ è¿å» |
| | | |
| | | //æ¤å¤ç¨typeè·åçæ¹æ³ï¼åç±»ä¸å®ä¹æ¯ä¸ä¼æ§è¡Logicå·¥ç¨ç¶ç±»çæ¹æ³ |
| | | var type = obj.Type; |
| | | |
| | | bindController = type.GetMethod("BindController"); |
| | | addListeners = type.GetMethod("AddListeners"); |
| | | onPreOpen = type.GetMethod("OnPreOpen"); |
| | | onAfterOpen = type.GetMethod("OnAfterOpen"); |
| | | onPreClose = type.GetMethod("OnPreClose"); |
| | | onAfterClose = type.GetMethod("OnAfterClose"); |
| | | onDestroy = type.GetMethod("OnDestroy"); |
| | | |
| | | lateUpdate = type.GetMethod("LateUpdate"); |
| | | onActived = type.GetMethod("OnActived"); |
| | | |
| | | //baseType è·åçæ¹æ³ï¼æä¼æ§è¡ç¶ç±»Logicå·¥ç¨çç¶ç±»æ¹æ³,ä½åæ¶ä¹ä¸ä¼è°ç¨åç±»éåçæ¹æ³ |
| | | dipose = baseType.GetMethod("Dipose", 0); |
| | | } |
| | | |
| | | protected override void OnActived() |
| | | { |
| | | if (onActived != null) |
| | | appDomain.Invoke(onActived, obj); |
| | | } |
| | | |
| | | protected override void LateUpdate() |
| | | { |
| | | if (lateUpdate != null) |
| | | appDomain.Invoke(lateUpdate, obj); |
| | | } |
| | | |
| | | protected override void BindController() |
| | | { |
| | | Init(); |
| | | if (bindController != null) |
| | | appDomain.Invoke(bindController, obj); |
| | | } |
| | | protected override void AddListeners() |
| | | { |
| | | if (addListeners != null) |
| | | appDomain.Invoke(addListeners, obj); |
| | | } |
| | | protected override void OnPreOpen() |
| | | { |
| | | if (onPreOpen != null) |
| | | appDomain.Invoke(onPreOpen, obj); |
| | | } |
| | | protected override void OnAfterOpen() |
| | | { |
| | | if (onAfterOpen != null) |
| | | appDomain.Invoke(onAfterOpen, obj); |
| | | } |
| | | protected override void OnPreClose() |
| | | { |
| | | if (onPreClose != null) |
| | | appDomain.Invoke(onPreClose, obj); |
| | | } |
| | | protected override void OnAfterClose() |
| | | { |
| | | if (onAfterClose != null) |
| | | appDomain.Invoke(onAfterClose, obj); |
| | | } |
| | | |
| | | private void OnDestroy() |
| | | { |
| | | if (onDestroy != null) |
| | | appDomain?.Invoke(onDestroy, obj); |
| | | if (dipose != null) |
| | | appDomain?.Invoke(dipose, obj); |
| | | bindController = null; |
| | | addListeners = null; |
| | | onPreOpen = null; |
| | | onAfterOpen = null; |
| | | onPreClose = null; |
| | | onAfterClose = null; |
| | | onDestroy = null; |
| | | lateUpdate = null; |
| | | onActived = null; |
| | | obj = null; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: dfecc37f6c13b544d83e80e8a1dda3f7 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: a36d462b97cf6824cb7d430aaeb583f7 |
| | | folderAsset: yes |
| | | DefaultImporter: |
| | | externalObjects: {} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | using UnityEngine; |
| | | using System.Collections.Generic; |
| | | using ILRuntime.Other; |
| | | using System; |
| | | using System.Collections; |
| | | using ILRuntime.Runtime.Enviorment; |
| | | using ILRuntime.Runtime.Intepreter; |
| | | using ILRuntime.CLR.Method; |
| | | |
| | | namespace ILCrossBinding |
| | | { |
| | | public class CoroutineAdapter : CrossBindingAdaptor |
| | | { |
| | | public override Type BaseCLRType |
| | | { |
| | | get |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public override Type[] BaseCLRTypes |
| | | { |
| | | get |
| | | { |
| | | //è·¨åç»§æ¿åªè½æ1个Adapterï¼å æ¤åºè¯¥å°½éé¿å
ä¸ä¸ªç±»åæ¶å®ç°å¤ä¸ªå¤é¨æ¥å£ï¼å¯¹äºcoroutineæ¥è¯´æ¯IEnumerator<object>,IEnumeratoråIDisposableï¼ |
| | | //ILRuntimeè½ç¶æ¯æï¼ä½æ¯ä¸å®è¦å°å¿è¿ç§ç¨æ³ï¼ä½¿ç¨ä¸å½å¾å®¹æé æä¸å¯é¢æçé®é¢ |
| | | //æ¥å¸¸å¼å妿éè¦å®ç°å¤ä¸ªDLLå¤é¨æ¥å£ï¼è¯·å¨Unityè¿è¾¹å
åä¸ä¸ªåºç±»å®ç°é£äºä¸ªæ¥å£ï¼ç¶åç»§æ¿é£ä¸ªåºç±» |
| | | return new Type[] { typeof(IEnumerator<object>), typeof(IEnumerator), typeof(IDisposable) }; |
| | | } |
| | | } |
| | | |
| | | public override Type AdaptorType |
| | | { |
| | | get |
| | | { |
| | | return typeof(Adaptor); |
| | | } |
| | | } |
| | | |
| | | public override object CreateCLRInstance(ILRuntime.Runtime.Enviorment.AppDomain appdomain, ILTypeInstance instance) |
| | | { |
| | | return new Adaptor(appdomain, instance); |
| | | } |
| | | //Coroutineçæçç±»å®ç°äºIEnumerator<System.Object>, IEnumerator, IDisposable,æä»¥é½è¦å®ç°ï¼è¿ä¸ªå¯ä»¥éè¿reflectorä¹ç±»çILåç¼è¯è½¯ä»¶å¾ç¥ |
| | | internal class Adaptor : IEnumerator<System.Object>, IEnumerator, IDisposable, CrossBindingAdaptorType |
| | | { |
| | | ILTypeInstance instance; |
| | | ILRuntime.Runtime.Enviorment.AppDomain appdomain; |
| | | |
| | | public Adaptor() |
| | | { |
| | | |
| | | } |
| | | |
| | | public Adaptor(ILRuntime.Runtime.Enviorment.AppDomain appdomain, ILTypeInstance instance) |
| | | { |
| | | this.appdomain = appdomain; |
| | | this.instance = instance; |
| | | } |
| | | |
| | | public ILTypeInstance ILInstance { get { return instance; } } |
| | | |
| | | IMethod mCurrentMethod; |
| | | bool mCurrentMethodGot; |
| | | public object Current |
| | | { |
| | | get |
| | | { |
| | | if (!mCurrentMethodGot) |
| | | { |
| | | mCurrentMethod = instance.Type.GetMethod("get_Current", 0); |
| | | if (mCurrentMethod == null) |
| | | { |
| | | //è¿éåSystem.Collections.IEnumerator.get_Currentè䏿¯ç´æ¥get_Currentæ¯å 为coroutineçæçç±»æ¯æ¾å¼å®ç°è¿ä¸ªæ¥å£çï¼éè¿Reflectorçåç¼è¯è½¯ä»¶å¯å¾ç¥ |
| | | //为äºå
¼å®¹å
¶ä»åªå®ç°äºåä¸Current屿§çï¼æä»¥ä¸é¢å
ç´æ¥åäºget_Current |
| | | mCurrentMethod = instance.Type.GetMethod("System.Collections.IEnumerator.get_Current", 0); |
| | | } |
| | | mCurrentMethodGot = true; |
| | | } |
| | | |
| | | if (mCurrentMethod != null) |
| | | { |
| | | var res = appdomain.Invoke(mCurrentMethod, instance, null); |
| | | return res; |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | | |
| | | IMethod mDisposeMethod; |
| | | bool mDisposeMethodGot; |
| | | public void Dispose() |
| | | { |
| | | if (!mDisposeMethodGot) |
| | | { |
| | | mDisposeMethod = instance.Type.GetMethod("Dispose", 0); |
| | | if (mDisposeMethod == null) |
| | | { |
| | | mDisposeMethod = instance.Type.GetMethod("System.IDisposable.Dispose", 0); |
| | | } |
| | | mDisposeMethodGot = true; |
| | | } |
| | | |
| | | if (mDisposeMethod != null) |
| | | { |
| | | appdomain.Invoke(mDisposeMethod, instance, null); |
| | | } |
| | | } |
| | | |
| | | IMethod mMoveNextMethod; |
| | | bool mMoveNextMethodGot; |
| | | public bool MoveNext() |
| | | { |
| | | if (!mMoveNextMethodGot) |
| | | { |
| | | mMoveNextMethod = instance.Type.GetMethod("MoveNext", 0); |
| | | mMoveNextMethodGot = true; |
| | | } |
| | | |
| | | if (mMoveNextMethod != null) |
| | | { |
| | | return (bool)appdomain.Invoke(mMoveNextMethod, instance, null); |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | IMethod mResetMethod; |
| | | bool mResetMethodGot; |
| | | public void Reset() |
| | | { |
| | | if (!mResetMethodGot) |
| | | { |
| | | mResetMethod = instance.Type.GetMethod("Reset", 0); |
| | | mResetMethodGot = true; |
| | | } |
| | | |
| | | if (mResetMethod != null) |
| | | { |
| | | appdomain.Invoke(mResetMethod, instance, null); |
| | | } |
| | | } |
| | | |
| | | public override string ToString() |
| | | { |
| | | IMethod m = appdomain.ObjectType.GetMethod("ToString", 0); |
| | | m = instance.Type.GetVirtualMethod(m); |
| | | if (m == null || m is ILMethod) |
| | | { |
| | | return instance.ToString(); |
| | | } |
| | | else |
| | | return instance.Type.FullName; |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 2f8dde6199bfcaa46b09411a7a942d47 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | using System; |
| | | using ILRuntime.CLR.Method; |
| | | using ILRuntime.Runtime.Enviorment; |
| | | using ILRuntime.Runtime.Intepreter; |
| | | namespace ILCrossBinding |
| | | { |
| | | public class DtcBasicAdapter : CrossBindingAdaptor |
| | | { |
| | | static CrossBindingMethodInfo<global::GameNetPackBasic> mDone_0 = new CrossBindingMethodInfo<global::GameNetPackBasic>("Done"); |
| | | public override Type BaseCLRType |
| | | { |
| | | get |
| | | { |
| | | return typeof(global::DtcBasic); |
| | | } |
| | | } |
| | | |
| | | public override Type AdaptorType |
| | | { |
| | | get |
| | | { |
| | | return typeof(Adapter); |
| | | } |
| | | } |
| | | |
| | | public override object CreateCLRInstance(ILRuntime.Runtime.Enviorment.AppDomain appdomain, ILTypeInstance instance) |
| | | { |
| | | return new Adapter(appdomain, instance); |
| | | } |
| | | |
| | | public class Adapter : global::DtcBasic, CrossBindingAdaptorType |
| | | { |
| | | ILTypeInstance instance; |
| | | ILRuntime.Runtime.Enviorment.AppDomain appdomain; |
| | | |
| | | public Adapter() |
| | | { |
| | | |
| | | } |
| | | |
| | | public Adapter(ILRuntime.Runtime.Enviorment.AppDomain appdomain, ILTypeInstance instance) |
| | | { |
| | | this.appdomain = appdomain; |
| | | this.instance = instance; |
| | | } |
| | | |
| | | public ILTypeInstance ILInstance { get { return instance; } } |
| | | |
| | | public override void Done(global::GameNetPackBasic vNetPack) |
| | | { |
| | | if (mDone_0.CheckShouldInvokeBase(this.instance)) |
| | | base.Done(vNetPack); |
| | | else |
| | | mDone_0.Invoke(this.instance, vNetPack); |
| | | } |
| | | |
| | | public override string ToString() |
| | | { |
| | | IMethod m = appdomain.ObjectType.GetMethod("ToString", 0); |
| | | m = instance.Type.GetVirtualMethod(m); |
| | | if (m == null || m is ILMethod) |
| | | { |
| | | return instance.ToString(); |
| | | } |
| | | else |
| | | return instance.Type.FullName; |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: b3ca5a52e14ab7a4682553c1fb67893d |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| New file |
| | |
| | | using System; |
| | | using ILRuntime.CLR.Method; |
| | | using ILRuntime.Runtime.Enviorment; |
| | | using ILRuntime.Runtime.Intepreter; |
| | | |
| | | namespace ILCrossBinding |
| | | { |
| | | public class GameNetPackBasicAdapter : CrossBindingAdaptor |
| | | { |
| | | static CrossBindingMethodInfo<System.Byte[]> mReadFromBytes_0 = new CrossBindingMethodInfo<System.Byte[]>("ReadFromBytes"); |
| | | static CrossBindingMethodInfo mWriteToBytes_1 = new CrossBindingMethodInfo("WriteToBytes"); |
| | | public override Type BaseCLRType |
| | | { |
| | | get |
| | | { |
| | | return typeof(global::GameNetPackBasic); |
| | | } |
| | | } |
| | | |
| | | public override Type AdaptorType |
| | | { |
| | | get |
| | | { |
| | | return typeof(Adapter); |
| | | } |
| | | } |
| | | |
| | | public override object CreateCLRInstance(ILRuntime.Runtime.Enviorment.AppDomain appdomain, ILTypeInstance instance) |
| | | { |
| | | return new Adapter(appdomain, instance); |
| | | } |
| | | |
| | | public class Adapter : global::GameNetPackBasic, CrossBindingAdaptorType |
| | | { |
| | | ILTypeInstance instance; |
| | | ILRuntime.Runtime.Enviorment.AppDomain appdomain; |
| | | |
| | | public Adapter() |
| | | { |
| | | |
| | | } |
| | | |
| | | public Adapter(ILRuntime.Runtime.Enviorment.AppDomain appdomain, ILTypeInstance instance) |
| | | { |
| | | this.appdomain = appdomain; |
| | | this.instance = instance; |
| | | } |
| | | |
| | | public ILTypeInstance ILInstance { get { return instance; } } |
| | | |
| | | public override void ReadFromBytes(System.Byte[] vBytes) |
| | | { |
| | | if (mReadFromBytes_0.CheckShouldInvokeBase(this.instance)) |
| | | base.ReadFromBytes(vBytes); |
| | | else |
| | | mReadFromBytes_0.Invoke(this.instance, vBytes); |
| | | } |
| | | |
| | | public override void WriteToBytes() |
| | | { |
| | | if (mWriteToBytes_1.CheckShouldInvokeBase(this.instance)) |
| | | base.WriteToBytes(); |
| | | else |
| | | mWriteToBytes_1.Invoke(this.instance); |
| | | } |
| | | |
| | | public override string ToString() |
| | | { |
| | | IMethod m = appdomain.ObjectType.GetMethod("ToString", 0); |
| | | m = instance.Type.GetVirtualMethod(m); |
| | | if (m == null || m is ILMethod) |
| | | { |
| | | return instance.ToString(); |
| | | } |
| | | else |
| | | return instance.Type.FullName; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: a94c13742be64f647bd0be7f74f5f2a5 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| | |
| | | m_Url: https://packages.unity.com |
| | | m_Scopes: [] |
| | | m_IsDefault: 1 |
| | | - m_Id: scoped:ILRuntime |
| | | m_Name: ILRuntime |
| | | m_Url: https://registry.npmjs.org |
| | | m_Scopes: |
| | | - com.ourpalm |
| | | m_IsDefault: 0 |
| | | m_UserSelectedRegistryName: |
| | | m_UserAddingNewScopedRegistry: 0 |
| | | m_RegistryInfoDraft: |
| | | m_ErrorMessage: |
| | | m_Original: |
| | | m_Id: |
| | | m_Name: |
| | | m_Url: |
| | | m_Scopes: [] |
| | | m_Id: scoped:ILRuntime |
| | | m_Name: ILRuntime |
| | | m_Url: https://registry.npmjs.org |
| | | m_Scopes: |
| | | - com.ourpalm |
| | | m_IsDefault: 0 |
| | | m_Modified: 0 |
| | | m_Name: |
| | | m_Url: |
| | | m_Name: ILRuntime |
| | | m_Url: https://registry.npmjs.org |
| | | m_Scopes: |
| | | - |
| | | - com.ourpalm |
| | | m_SelectedScopeIndex: 0 |
| | |
| | | il2cppCompilerConfiguration: {} |
| | | managedStrippingLevel: {} |
| | | incrementalIl2cppBuild: {} |
| | | allowUnsafeCode: 0 |
| | | allowUnsafeCode: 1 |
| | | additionalIl2CppArgs: |
| | | scriptingRuntimeVersion: 1 |
| | | gcIncremental: 0 |