Browse Source

增加热更新dll

jiangxufeng 3 years ago
parent
commit
36f461477a
51 changed files with 396 additions and 2980 deletions
  1. 0 305
      LuaDemo/Assets/SFramework/Editor/SAssetsBundleHelper.cs
  2. 0 11
      LuaDemo/Assets/SFramework/Editor/SAssetsBundleHelper.cs.meta
  3. 0 39
      LuaDemo/Assets/SFramework/Editor/SDataCleanHelper.cs
  4. 0 11
      LuaDemo/Assets/SFramework/Editor/SDataCleanHelper.cs.meta
  5. 0 59
      LuaDemo/Assets/SFramework/Editor/SSymbolLinkHelper.cs
  6. 0 11
      LuaDemo/Assets/SFramework/Editor/SSymbolLinkHelper.cs.meta
  7. 0 8
      LuaDemo/Assets/SFramework/Editor/Tools.meta
  8. 0 237
      LuaDemo/Assets/SFramework/Editor/Tools/SEditorUtils.cs
  9. 0 11
      LuaDemo/Assets/SFramework/Editor/Tools/SEditorUtils.cs.meta
  10. 0 72
      LuaDemo/Assets/SFramework/Editor/Tools/SSymbolLink.cs
  11. 0 11
      LuaDemo/Assets/SFramework/Editor/Tools/SSymbolLink.cs.meta
  12. 0 280
      LuaDemo/Assets/SFramework/Editor/Tools/SUnityEditorEventCatcher.cs
  13. 0 11
      LuaDemo/Assets/SFramework/Editor/Tools/SUnityEditorEventCatcher.cs.meta
  14. 0 8
      LuaDemo/Assets/SFramework/Module.meta
  15. 0 10
      LuaDemo/Assets/SFramework/Module/SCoroutineRunner.cs
  16. 0 119
      LuaDemo/Assets/SFramework/Module/SEventManager.cs
  17. 0 11
      LuaDemo/Assets/SFramework/Module/SEventManager.cs.meta
  18. 0 534
      LuaDemo/Assets/SFramework/Module/SLuaComponent.cs
  19. 0 315
      LuaDemo/Assets/SFramework/Module/SResourceManager.cs
  20. 0 11
      LuaDemo/Assets/SFramework/Module/SResourceManager.cs.meta
  21. 0 363
      LuaDemo/Assets/SFramework/Module/SUpdateManager.cs
  22. 0 11
      LuaDemo/Assets/SFramework/Module/SUpdateManager.cs.meta
  23. 0 20
      LuaDemo/Assets/SFramework/Module/SVersionInfo.cs
  24. 0 11
      LuaDemo/Assets/SFramework/Module/SVersionInfo.cs.meta
  25. 0 35
      LuaDemo/Assets/SFramework/SFrameworkDef.cs
  26. 0 11
      LuaDemo/Assets/SFramework/SFrameworkDef.cs.meta
  27. BIN
      LuaDemo/Assets/SFramework/SFrameworkE.dll
  28. 86 0
      LuaDemo/Assets/SFramework/SFrameworkE.dll.meta
  29. BIN
      LuaDemo/Assets/SFramework/SFrameworkR.dll
  30. 33 0
      LuaDemo/Assets/SFramework/SFrameworkR.dll.meta
  31. 0 8
      LuaDemo/Assets/SFramework/Tools.meta
  32. 0 109
      LuaDemo/Assets/SFramework/Tools/SPlatformInfo.cs
  33. 0 11
      LuaDemo/Assets/SFramework/Tools/SPlatformInfo.cs.meta
  34. 0 62
      LuaDemo/Assets/SFramework/Tools/SToolFunction.cs
  35. 0 11
      LuaDemo/Assets/SFramework/Tools/SToolFunction.cs.meta
  36. 0 8
      LuaDemo/Assets/SFramework/UI.meta
  37. 0 79
      LuaDemo/Assets/SFramework/UI/SUIObjectBase.cs
  38. 0 11
      LuaDemo/Assets/SFramework/UI/SUIObjectBase.cs.meta
  39. 0 82
      LuaDemo/Assets/SFramework/UI/SUIPanelTips.cs
  40. 0 11
      LuaDemo/Assets/SFramework/UI/SUIPanelTips.cs.meta
  41. 0 46
      LuaDemo/Assets/SFramework/UI/SUIPanelUpdate.cs
  42. 0 11
      LuaDemo/Assets/SFramework/UI/SUIPanelUpdate.cs.meta
  43. 1 1
      LuaDemo/Assets/SFramework/XLua.meta
  44. 33 0
      LuaDemo/Assets/SFramework/XLua/SCoroutineRunner.cs
  45. 1 1
      LuaDemo/Assets/SFramework/XLua/SCoroutineRunner.cs.meta
  46. 0 0
      LuaDemo/Assets/SFramework/XLua/SLuaBehaviour.cs
  47. 1 1
      LuaDemo/Assets/SFramework/XLua/SLuaBehaviour.cs.meta
  48. 225 0
      LuaDemo/Assets/SFramework/XLua/SLuaComponent.cs
  49. 1 1
      LuaDemo/Assets/SFramework/XLua/SLuaComponent.cs.meta
  50. 14 1
      LuaDemo/Assets/SFramework/XLua/SLuaEnv.cs
  51. 1 1
      LuaDemo/Assets/SFramework/XLua/SLuaEnv.cs.meta

+ 0 - 305
LuaDemo/Assets/SFramework/Editor/SAssetsBundleHelper.cs

@@ -1,305 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEditor;
-
-namespace SFramework.Editor
-{
-    public static class SAssetsBundleHelper
-    {
-        static string ResourcesBuildDir
-        {
-            get
-            {
-                var dir = "Assets/" + SFrameworkDef.ResourceDir + "/";
-                return dir;
-            }
-        }
-
-        /// <summary>
-        /// Unity 5新AssetBundle系统,需要为打包的AssetBundle配置名称
-        /// 
-        /// 直接将KEngine配置的BundleResources目录整个自动配置名称,因为这个目录本来就是整个导出
-        /// </summary>
-        [MenuItem("SFramework/AssetBundle/Auto Set Names To [BundleResources]")]
-        public static void AutoSetAssetBundleNames()
-        {
-            var dir = ResourcesBuildDir;
-
-            // Check marked asset bundle whether real
-            foreach (var assetGuid in AssetDatabase.FindAssets(""))
-            {
-                var assetPath = AssetDatabase.GUIDToAssetPath(assetGuid);
-                var assetImporter = AssetImporter.GetAtPath(assetPath);
-                var bundleName = assetImporter.assetBundleName;
-                if (string.IsNullOrEmpty(bundleName))
-                {
-                    continue;
-                }
-                if (!assetPath.StartsWith(dir))
-                {
-                    assetImporter.assetBundleName = null;
-                }
-            }
-
-            // set BundleResources's all bundle name
-            foreach (var filepath in System.IO.Directory.GetFiles(dir, "*.*", System.IO.SearchOption.AllDirectories))
-            {
-                if (filepath.EndsWith(".meta")) continue;
-
-                var importer = AssetImporter.GetAtPath(filepath);
-                if (importer == null)
-                {
-                    Debug.LogError(string.Format("Not found: {0}", filepath));
-                    continue;
-                }
-                var bundleName = filepath.Substring(dir.Length, filepath.Length - dir.Length);
-                importer.assetBundleName = bundleName + SFrameworkDef.AssetsBundleExtName;
-            }
-            Debug.Log("Make all asset name success!");
-        }
-
-        /// <summary>
-        /// 清理冗余,即无此资源,却存在AssetBundle的文件, Unity 5 only
-        /// </summary>
-        [MenuItem("SFramework/AssetBundle/Clean Redundancies")]
-        public static void CleanAssetBundlesRedundancies()
-        {
-            var platformName = SPlatformInfo.GetBuildPlatformName();
-            var outputPath = GetExportPath(EditorUserBuildSettings.activeBuildTarget);
-            var srcList = new List<string>(System.IO.Directory.GetFiles(ResourcesBuildDir, "*.*", System.IO.SearchOption.AllDirectories));
-            for (var i = srcList.Count - 1; i >= 0; i--)
-            {
-                if (srcList[i].EndsWith(".meta"))
-                    srcList.RemoveAt(i);
-                else
-                    srcList[i] = srcList[i].Replace(ResourcesBuildDir, "").ToLower();
-            }
-
-            var toListMap = new Dictionary<string, string>();
-            var toList = new List<string>(System.IO.Directory.GetFiles(outputPath, "*.*", System.IO.SearchOption.AllDirectories));
-            for (var i = toList.Count - 1; i >= 0; i--)
-            {
-                var filePath = toList[i];
-
-                if (toList[i].EndsWith((".meta")) || toList[i].EndsWith(".manifest"))
-                {
-                    toList.RemoveAt(i);
-                }
-                else
-                {
-                    var rName = toList[i].Replace(outputPath, "");
-                    if (rName == platformName || // 排除AB 平台总索引文件,
-                        rName == (platformName + ".manifest") ||
-                        rName == (platformName + ".meta") ||
-                        rName == (platformName + ".manifest.meta"))
-                    {
-                        toList.RemoveAt(i);
-                    }
-                    else
-                    {
-                        // 去掉扩展名,因为AssetBundle额外扩展名
-                        toList[i] = System.IO.Path.ChangeExtension(rName, "");// 会留下最后句点
-                        toList[i] = toList[i].Substring(0, toList[i].Length - 1); // 去掉句点
-
-                        toListMap[toList[i]] = filePath;
-                    }
-                }
-            }
-
-            // 删文件和manifest
-            for (var i = 0; i < toList.Count; i++)
-            {
-                if (!srcList.Contains(toList[i]))
-                {
-                    var filePath = toListMap[toList[i]];
-                    var manifestPath = filePath + ".manifest";
-                    System.IO.File.Delete(filePath);
-                    Debug.LogWarning("Delete... " + filePath);
-                    if (System.IO.File.Exists(manifestPath))
-                    {
-                        System.IO.File.Delete(manifestPath);
-                        Debug.LogWarning("Delete... " + manifestPath);
-                    }
-
-
-                }
-            }
-        }
-
-        [MenuItem("SFramework/AssetBundle/Create Version File")]
-        public static void CreateVersionFile()
-        {
-            AssetBundle.UnloadAllAssetBundles(true);
-
-            var platformName = SPlatformInfo.GetBuildPlatformName();
-            var outputPath = GetExportPath(EditorUserBuildSettings.activeBuildTarget);
-            Debug.Log(string.Format("CreateVersionFile -> platformName:{0} outputPath:{1}", platformName, outputPath));
-
-            // Load manifestAB
-            string manifestABPath = Application.dataPath + "/../Product/Bundles/" + platformName + "/" + platformName;
-            Debug.Log("manifestABPath -> " + manifestABPath);
-
-            byte[] byManifest = System.IO.File.ReadAllBytes(manifestABPath);
-            AssetBundle manifestAB = AssetBundle.LoadFromMemory(byManifest);
-            if (manifestAB == null)
-            {
-                Debug.LogError("CreateVersionFile -> Get ManifestAB Failed. Path:" + manifestABPath);
-                return;
-            }
-            AssetBundleManifest manifest = manifestAB.LoadAsset("AssetBundleManifest") as AssetBundleManifest;
-            if (manifest == null)
-            {
-                Debug.LogError("CreateVersionFile -> Get Manifest From AssetBundle Failed.");
-                return;
-            }
-
-            SVersionInfo curVersionInfo = new SVersionInfo();
-            curVersionInfo.version = 0;
-            curVersionInfo.fileInfo = new List<SFileInfo>();
-            // Add Manifest File
-            string manifestFileName   = platformName;
-            SFileInfo manifestFileInfo = SToolFunction.CreateFileInfo(manifestFileName, outputPath + manifestFileName);
-            curVersionInfo.fileInfo.Add(manifestFileInfo);
-
-            // Add Manifest Ext File(platform.manifest)
-            string manifestExtFileName      = platformName + ".manifest";
-            SFileInfo manifestExtFileInfo = SToolFunction.CreateFileInfo(manifestExtFileName, outputPath + manifestExtFileName);
-            curVersionInfo.fileInfo.Add(manifestExtFileInfo);
-
-            // Add files in manifest.
-            string[] allABName = manifest.GetAllAssetBundles();
-            curVersionInfo.fileCount = allABName.Length;
-            foreach (string abName in allABName)
-            {
-                string oneABFullPathWithName = outputPath + abName;
-                SFileInfo curFileInfo = SToolFunction.CreateFileInfo(abName, oneABFullPathWithName);
-                curFileInfo.hashInfo = manifest.GetAssetBundleHash(abName).ToString();
-
-                curVersionInfo.fileInfo.Add(curFileInfo);
-                // Debug.Log(string.Format("oneAB:{0} Size:{1}", abName, oneABFileInfo.Length));
-
-                Debug.Log(string.Format("abName: {0} FileSize:{1} HashCode: {2}", 
-                    curFileInfo.fileName, curFileInfo.fileSize, curFileInfo.hashInfo));
-            }
-            string jsonString = LitJson.JsonMapper.ToJson(curVersionInfo);
-            Debug.Log("jsonString -> " + jsonString);
-
-            string jsonPath = Application.dataPath + "/../Product/Bundles/" + platformName + "/" + SFrameworkDef.VersionFileName;
-            System.IO.StreamWriter build_info = new System.IO.StreamWriter(jsonPath);
-            build_info.Write(jsonString);
-            build_info.Close();
-            build_info.Dispose();
-
-            manifestAB.Unload(true);
-            Debug.Log("CreateVersionFile Success!");
-        }
-
-        //[MenuItem("SFramework/AssetBundle/Build All to All Platforms")]
-        //public static void BuildAllAssetBundlesToAllPlatforms()
-        //{
-        //    var platforms = new List<BuildTarget>()
-        //    {
-        //        BuildTarget.iOS,
-        //        BuildTarget.Android,
-        //        BuildTarget.StandaloneWindows,
-        //        BuildTarget.StandaloneOSX,
-        //    };
-
-        //    // Build all support platforms asset bundle
-        //    var currentBuildTarget = EditorUserBuildSettings.activeBuildTarget;
-        //    platforms.Remove(currentBuildTarget);
-        //    BuildAllAssetBundles();
-
-        //    foreach (var platform in platforms)
-        //    {
-        //        if (EditorUserBuildSettings.SwitchActiveBuildTarget(platform))
-        //            BuildAllAssetBundles();
-        //    }
-
-        //    // revert platform 
-        //    EditorUserBuildSettings.SwitchActiveBuildTarget(currentBuildTarget);
-        //}
-
-        [MenuItem("SFramework/AssetBundle/ReBuild All")]
-        public static void ReBuildAllAssetBundles()
-        {
-            var outputPath = GetExportPath(EditorUserBuildSettings.activeBuildTarget);
-            System.IO.Directory.Delete(outputPath, true);
-
-            Debug.Log("Delete folder: " + outputPath);
-
-            BuildAllAssetBundles();
-        }
-
-        [MenuItem("SFramework/AssetBundle/Build All %&b")]
-        public static void BuildAllAssetBundles()
-        {
-            if (EditorApplication.isPlaying)
-            {
-                Debug.LogError("Cannot build in playing mode! Please stop!");
-                return;
-            }
-            AutoSetAssetBundleNames();
-            var outputPath = GetExportPath(EditorUserBuildSettings.activeBuildTarget);
-            Debug.Log(string.Format("Asset bundle start build to: {0}", outputPath));
-            BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.DeterministicAssetBundle, EditorUserBuildSettings.activeBuildTarget);
-            //BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.DeterministicAssetBundle | BuildAssetBundleOptions.AppendHashToAssetBundleName, EditorUserBuildSettings.activeBuildTarget);
-            CreateVersionFile();
-        }
-
-        /// <summary>
-        /// Extra Flag ->   ex:  Android/  AndroidSD/  AndroidHD/
-        /// </summary>
-        /// <param name="platfrom"></param>
-        /// <returns></returns>
-        public static string GetExportPath(BuildTarget platfrom)
-        {
-            //string basePath =
-            //    System.IO.Path.GetFullPath(KEngine.AppEngine.GetConfig(KEngineDefaultConfigs.AssetBundleBuildRelPath));
-            string basePath = SFrameworkDef.AssetsBundleProductDir;
-
-            if (System.IO.File.Exists(basePath))
-            {
-                SAssetsBundleHelper.ShowDialog("路径配置错误: " + basePath);
-                throw new System.Exception("路径配置错误");
-            }
-            if (!System.IO.Directory.Exists(basePath))
-            {
-                System.IO.Directory.CreateDirectory(basePath);
-            }
-
-            string path = null;
-            var platformName = SPlatformInfo.GetBuildPlatformName();
-
-            path = basePath + "/" + platformName + "/";
-            if (!System.IO.Directory.Exists(path))
-            {
-                System.IO.Directory.CreateDirectory(path);
-            }
-            return path;
-        }
-
-        public static void ClearConsole()
-        {
-            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly(typeof(SceneView));
-            System.Type type = assembly.GetType("UnityEditorInternal.LogEntries");
-            System.Reflection.MethodInfo method = type.GetMethod("Clear");
-            method.Invoke(null, null);
-        }
-
-        public static bool ShowDialog(string msg, string title = "提示", string button = "确定")
-        {
-            return EditorUtility.DisplayDialog(title, msg, button);
-        }
-
-        public static void ShowDialogSelection(string msg, System.Action yesCallback)
-        {
-            if (EditorUtility.DisplayDialog("确定吗", msg, "是!", "不!"))
-            {
-                yesCallback();
-            }
-        }
-    }
-
-}

+ 0 - 11
LuaDemo/Assets/SFramework/Editor/SAssetsBundleHelper.cs.meta

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

+ 0 - 39
LuaDemo/Assets/SFramework/Editor/SDataCleanHelper.cs

@@ -1,39 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEditor;
-
-namespace SFramework.Editor
-{
-    public class SDataCleanHelper
-    {
-        [MenuItem("SFramework/Data Clean/Open PC PersistentDataPath Folder")]
-        public static void OpenPersistentDataPath()
-        {
-            System.Diagnostics.Process.Start(Application.persistentDataPath);
-        }
-
-        [MenuItem("SFramework/Data Clean/Clear PC PersistentDataPath")]
-        public static void ClearPersistentDataPath()
-        {
-            foreach (string dir in System.IO.Directory.GetDirectories(Application.persistentDataPath))
-            {
-                System.IO.Directory.Delete(dir, true);
-            }
-            foreach (string file in System.IO.Directory.GetFiles(Application.persistentDataPath))
-            {
-                System.IO.File.Delete(file);
-            }
-            //SAssetsBundleHelper.ShowDialog("PersistentDataPath Cleared!");
-            Debug.Log("PersistentDataPath Cleared!");
-        }
-
-        [MenuItem("SFramework/Data Clean/Clear Prefs")]
-        public static void ClearPlayerPrefs()
-        {
-            PlayerPrefs.DeleteAll();
-            PlayerPrefs.Save();
-            SAssetsBundleHelper.ShowDialog("Prefs Cleared!");
-        }
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/Editor/SDataCleanHelper.cs.meta

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

+ 0 - 59
LuaDemo/Assets/SFramework/Editor/SSymbolLinkHelper.cs

@@ -1,59 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEditor;
-
-namespace SFramework.Editor
-{
-    public class SSymbolLinkHelper
-    {
-        public static string AssetBundlesLinkPath
-        {
-            get
-            {
-                // StreamingAssetsPath
-                //return "Assets/StreamingAssets/" +
-                //       KEngine.AppEngine.GetConfig(KEngineDefaultConfigs.StreamingBundlesFolderName);
-                // hold asset bundles
-                return "Assets/StreamingAssets/" + "Bundles";
-            }
-        }
-
-        public static string GetLinkPath()
-        {
-            if (!System.IO.Directory.Exists(AssetBundlesLinkPath))
-                System.IO.Directory.CreateDirectory(AssetBundlesLinkPath);
-            return AssetBundlesLinkPath + "/" + SPlatformInfo.GetBuildPlatformName() + "/";
-        }
-
-        public static string GetResourceExportPath()
-        {
-            var resourcePath = SAssetsBundleHelper.GetExportPath(EditorUserBuildSettings.activeBuildTarget);
-            return resourcePath;
-        }
-
-        [MenuItem("SFramework/Symbol Link Resources/Link Builded Resource -> StreamingAssets or Resources")]
-        public static void SymbolLinkResource()
-        {
-            SUnityEditorTools.SUnityEditorTools.DeleteAllLinks(SSymbolLinkHelper.AssetBundlesLinkPath);
-
-            var exportPath = GetResourceExportPath();
-            var linkPath = GetLinkPath();
-
-            SUnityEditorTools.SUnityEditorTools.SymbolLinkFolder(exportPath, linkPath);
-
-            AssetDatabase.Refresh();
-        }
-
-        [MenuItem("SFramework/Symbol Link Resources/Remove StreamingAssets or Resources links")]
-        public static void RemoveSymbolLinkResource()
-        {
-            SUnityEditorTools.SUnityEditorTools.DeleteAllLinks(SSymbolLinkHelper.AssetBundlesLinkPath);
-            Debug.Log("Remove " + SSymbolLinkHelper.AssetBundlesLinkPath);
-
-            AssetDatabase.DeleteAsset(SSymbolLinkHelper.AssetBundlesLinkPath);
-
-            AssetDatabase.Refresh();
-        }
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/Editor/SSymbolLinkHelper.cs.meta

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

+ 0 - 8
LuaDemo/Assets/SFramework/Editor/Tools.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 0c5f227db78fcfb45b7957c273e9e4aa
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 237
LuaDemo/Assets/SFramework/Editor/Tools/SEditorUtils.cs

@@ -1,237 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
-using System.Text;
-using System.Text.RegularExpressions;
-using UnityEditor;
-using Debug = UnityEngine.Debug;
-
-namespace SUnityEditorTools
-{
-    /// <summary>
-    /// Shell / cmd / 等等常用Editor需要用到的工具集
-    /// </summary>
-    public class SEditorUtils
-    {
-        /// <summary>
-        /// 用于非主线程里执行主线程的函数
-        /// </summary>
-        internal static Queue<Action> _mainThreadActions = new Queue<Action>();
-
-        static SEditorUtils()
-        {
-            KUnityEditorEventCatcher.OnEditorUpdateEvent -= OnEditorUpdate;
-            KUnityEditorEventCatcher.OnEditorUpdateEvent += OnEditorUpdate;
-        }
-
-        /// <summary>
-        /// 捕获Unity Editor update事件
-        /// </summary>
-        private static void OnEditorUpdate()
-        {
-            // 主线程委托
-            while (_mainThreadActions.Count > 0)
-            {
-                var action = _mainThreadActions.Dequeue();
-                if (action != null) action();
-            }
-        }
-
-        /// <summary>
-        /// 异步线程回到主线程进行回调
-        /// </summary>
-        /// <param name="action"></param>
-        public static void CallMainThread(Action action)
-        {
-            _mainThreadActions.Enqueue(action);
-        }
-
-        /// <summary>
-        /// 清除Console log
-        /// </summary>
-        public static void ClearConsoleLog()
-        {
-            Assembly assembly = Assembly.GetAssembly(typeof (ActiveEditorTracker));
-            Type type = assembly.GetType("UnityEditorInternal.LogEntries");
-            MethodInfo method = type.GetMethod("Clear");
-            method.Invoke(new object(), null);
-        }
-
-        /// <summary>
-        /// 执行批处理命令
-        /// </summary>
-        /// <param name="command"></param>
-        /// <param name="workingDirectory"></param>
-        public static void ExecuteCommand(string command, string workingDirectory = null)
-        {
-            var fProgress = .1f;
-            EditorUtility.DisplayProgressBar("KEditorUtils.ExecuteCommand", command, fProgress);
-
-            try
-            {
-                string cmd;
-                string preArg;
-                var os = Environment.OSVersion;
-
-                Debug.Log(String.Format("[ExecuteCommand]Command on OS: {0}", os.ToString()));
-                if (os.ToString().Contains("Windows"))
-                {
-                    cmd = "cmd.exe";
-                    preArg = "/C ";
-                }
-                else
-                {
-                    cmd = "sh";
-                    preArg = "-c ";
-                }
-                Debug.Log("[ExecuteCommand]" + command);
-                var allOutput = new StringBuilder();
-                using (var process = new Process())
-                {
-                    if (workingDirectory != null)
-                        process.StartInfo.WorkingDirectory = workingDirectory;
-                    process.StartInfo.FileName = cmd;
-                    process.StartInfo.Arguments = preArg + "\"" + command + "\"";
-                    process.StartInfo.UseShellExecute = false;
-                    process.StartInfo.CreateNoWindow = true;
-                    process.StartInfo.RedirectStandardOutput = true;
-                    process.StartInfo.RedirectStandardError = true;
-                    process.Start();
-
-                    while (true)
-                    {
-                        var line = process.StandardOutput.ReadLine();
-                        if (line == null)
-                            break;
-                        allOutput.AppendLine(line);
-                        EditorUtility.DisplayProgressBar("[ExecuteCommand] " + command, line, fProgress);
-                        fProgress += .001f;
-                    }
-
-                    var err = process.StandardError.ReadToEnd();
-                    if (!String.IsNullOrEmpty(err))
-                    {
-                        Debug.LogError(String.Format("[ExecuteCommand] {0}", err));
-                    }
-                    process.WaitForExit();
-                }
-                Debug.Log("[ExecuteResult]" + allOutput);
-            }
-            finally
-            {
-                EditorUtility.ClearProgressBar();
-            }
-        }
-
-        public delegate void EachDirectoryDelegate(string fileFullPath, string fileRelativePath);
-
-        /// <summary>
-        /// 递归一个目录所有文件,callback
-        /// </summary>
-        /// <param name="dirPath"></param>
-        /// <param name="eachCallback"></param>
-        public static void EachDirectoryFiles(string dirPath, EachDirectoryDelegate eachCallback)
-        {
-            foreach (var filePath in Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories))
-            {
-                var fileRelativePath = filePath.Replace(dirPath, "");
-                if (fileRelativePath.StartsWith("/") || fileRelativePath.StartsWith("\\"))
-                    fileRelativePath = fileRelativePath.Substring(1, fileRelativePath.Length - 1);
-
-                var cleanFilePath = filePath.Replace("\\", "/");
-                fileRelativePath = fileRelativePath.Replace("\\", "/");
-                eachCallback(cleanFilePath, fileRelativePath);
-            }
-        }
-
-        /// <summary>
-        /// 将丑陋的windows路径,替换掉\字符
-        /// </summary>
-        /// <param name="path"></param>
-        /// <returns></returns>
-        public static string GetCleanPath(string path)
-        {
-            return path.Replace("\\", "/");
-        }
-
-        /// <summary>
-        /// 在指定目录中搜寻字符串并返回匹配}
-        /// </summary>
-        /// <param name="sourceFolder"></param>
-        /// <param name="searchWord"></param>
-        /// <param name="fileFilter"></param>
-        /// <returns></returns>
-        public static Dictionary<string, List<Match>> FindStrMatchesInFolderTexts(string sourceFolder, Regex searchWord,
-            Func<string, bool> fileFilter = null)
-        {
-            var retMatches = new Dictionary<string, List<Match>>();
-            var allFiles = new List<string>();
-            AddFileNamesToList(sourceFolder, allFiles);
-            foreach (string fileName in allFiles)
-            {
-                if (fileFilter != null && !fileFilter(fileName))
-                    continue;
-
-                retMatches[fileName] = new List<Match>();
-                string contents = File.ReadAllText(fileName);
-                var matches = searchWord.Matches(contents);
-                if (matches.Count > 0)
-                {
-                    for (int i = 0; i < matches.Count; i++)
-                    {
-                        retMatches[fileName].Add(matches[i]);
-                    }
-
-                }
-            }
-            return retMatches;
-        }
-
-        private static void AddFileNamesToList(string sourceDir, List<string> allFiles)
-        {
-
-            string[] fileEntries = Directory.GetFiles(sourceDir);
-            foreach (string fileName in fileEntries)
-            {
-                allFiles.Add(fileName);
-            }
-
-            //Recursion    
-            string[] subdirectoryEntries = Directory.GetDirectories(sourceDir);
-            foreach (string item in subdirectoryEntries)
-            {
-                // Avoid "reparse points"
-                if ((File.GetAttributes(item) & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint)
-                {
-                    AddFileNamesToList(item, allFiles);
-                }
-            }
-
-        }
-
-        /// <summary>
-        /// 从所有的程序集收集指定类型,public, 包括继承的
-        /// </summary>
-        /// <returns></returns>
-        public static IList<Type> FindAllPublicTypes(Type findType)
-        {
-            var list = new List<Type>();
-            Assembly[] Assemblies = AppDomain.CurrentDomain.GetAssemblies();
-            for (int n = 0; n < Assemblies.Length; n++)
-            {
-                Assembly asm = Assemblies[n];
-                foreach (var type in asm.GetExportedTypes())
-                {
-                    if (findType.IsAssignableFrom(type) || findType == type)
-                    {
-                        list.Add(type);
-                    }
-                }
-            }
-            return list;
-        }
-
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/Editor/Tools/SEditorUtils.cs.meta

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

+ 0 - 72
LuaDemo/Assets/SFramework/Editor/Tools/SSymbolLink.cs

@@ -1,72 +0,0 @@
-using System;
-using System.IO;
-using UnityEngine;
-
-namespace SUnityEditorTools
-{
-    /// <summary>
-    /// 硬链接目录工具。。。支持win+mac, 需要win 7以上才有mklink命令
-    /// </summary>
-    public class SUnityEditorTools
-    {
-        /// <summary>
-        /// 删除硬链接目录
-        /// </summary>
-        /// <param name="linkPath"></param>
-        public static void DeleteLink(string linkPath)
-        {
-            var os = Environment.OSVersion;
-            if (os.ToString().Contains("Windows"))
-            {
-                SEditorUtils.ExecuteCommand(String.Format("rmdir \"{0}\"", linkPath));
-            }
-            else if (os.ToString().Contains("Unix"))
-            {
-                SEditorUtils.ExecuteCommand(String.Format("rm -Rf \"{0}\"", linkPath));
-            }
-            else
-            {
-                Debug.LogError(String.Format("[SymbolLinkFolder]Error on OS: {0}", os.ToString()));
-            }
-        }
-
-        public static void SymbolLinkFolder(string srcFolderPath, string targetPath)
-        {
-            var os = Environment.OSVersion;
-            if (os.ToString().Contains("Windows"))
-            {
-                SEditorUtils.ExecuteCommand(String.Format("mklink /J \"{0}\" \"{1}\"", targetPath, srcFolderPath));
-            }
-            else if (os.ToString().Contains("Unix"))
-            {
-                var fullPath = Path.GetFullPath(targetPath);
-                if (fullPath.EndsWith("/"))
-                {
-                    fullPath = fullPath.Substring(0, fullPath.Length - 1);
-                    fullPath = Path.GetDirectoryName(fullPath);
-                }
-                SEditorUtils.ExecuteCommand(String.Format("ln -s {0} {1}", Path.GetFullPath(srcFolderPath), fullPath));
-            }
-            else
-            {
-                Debug.LogError(String.Format("[SymbolLinkFolder]Error on OS: {0}", os.ToString()));
-            }
-        }
-
-        /// <summary>
-        /// 删除指定目录所有硬链接
-        /// </summary>
-        /// <param name="assetBundlesLinkPath"></param>
-        public static void DeleteAllLinks(string assetBundlesLinkPath)
-        {
-            if (Directory.Exists(assetBundlesLinkPath))
-            {
-                foreach (var dirPath in Directory.GetDirectories(assetBundlesLinkPath))
-                {
-                    DeleteLink(dirPath);
-                }
-            }
-
-        }
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/Editor/Tools/SSymbolLink.cs.meta

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

+ 0 - 280
LuaDemo/Assets/SFramework/Editor/Tools/SUnityEditorEventCatcher.cs

@@ -1,280 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using UnityEditor;
-using UnityEditor.Callbacks;
-
-namespace SUnityEditorTools
-{
-    /// <summary>
-    /// 用于捕捉编辑器变更事件,不做具体逻辑处理,只暴露各种封装事件
-    /// 
-    /// 注意不要加具体逻辑在这里,namespace KAdminTools 没有具体逻辑依赖具体逻辑塞到KGameAdminEditor里
-    /// 
-    /// 具体逻辑使用时,注意加上[InitializeOnLoad]
-    /// </summary>
-    [InitializeOnLoad]
-    public class KUnityEditorEventCatcher
-    {
-        /// <summary>
-        /// Editor update事件
-        /// </summary>
-        private static System.Action _OnEditorUpdateEvent;
-        public static System.Action OnEditorUpdateEvent
-        {
-            get
-            {
-                return _OnEditorUpdateEvent;
-            }
-            set
-            {
-                _OnEditorUpdateEvent = value;
-                if (IsInited && _OnEditorUpdateEvent != null)
-                    _OnEditorUpdateEvent();
-            }
-        }
-        /// <summary>
-        /// 将要播放游戏事件
-        /// </summary>
-        private static System.Action _OnWillPlayEvent;
-
-        public static System.Action OnWillPlayEvent
-        {
-            get { return _OnWillPlayEvent; }
-            set
-            {
-                _OnWillPlayEvent = value;
-                //if (IsInited && _OnWillPlayEvent != null)
-                //    _OnWillPlayEvent();
-            }
-        }
-
-        /// <summary>
-        /// 进入播放时刻事件
-        /// </summary>
-        private static System.Action _OnBeginPlayEvent;
-
-        public static System.Action OnBeginPlayEvent
-        {
-            get { return _OnBeginPlayEvent; }
-            set
-            {
-                _OnBeginPlayEvent = value;
-                //if (IsInited && _OnBeginPlayEvent != null)
-                //    _OnBeginPlayEvent();
-            }
-        }
-
-        /// <summary>
-        /// 将要停止游戏 (不包括暂停哦)
-        /// </summary>
-        private static System.Action _OnWillStopEvent;
-        public static System.Action OnWillStopEvent
-        {
-            get { return _OnWillStopEvent; }
-            set
-            {
-                _OnWillStopEvent = value;
-                //if (IsInited && _OnWillStopEvent != null)
-                //    _OnWillStopEvent();
-            }
-        }
-
-        /// <summary>
-        /// 程序集锁定事件,事件中可以进行DLL的注入修改
-        /// </summary>
-        private static System.Action _OnLockingAssembly;
-        public static System.Action OnLockingAssembly
-        {
-            get { return _OnLockingAssembly; }
-            set
-            {
-                _OnLockingAssembly = value;
-                if (IsInited && _OnLockingAssembly != null)
-                    _OnLockingAssembly();
-            }
-        }
-
-
-        /// <summary>
-        /// 编译前事件,比较特殊的处理,配合了PostBuildProcess和PostBuildScene
-        /// </summary>
-        public static Action OnBeforeBuildPlayerEvent;
-
-
-        /// <summary>
-        /// 编译完成后事件
-        /// </summary>
-        private static System.Action<BuildTarget, string> _OnPostBuildPlayerEvent;
-        public static System.Action<BuildTarget, string> OnPostBuildPlayerEvent
-        {
-            get { return _OnPostBuildPlayerEvent;}
-            set
-            {
-                _OnPostBuildPlayerEvent = value;
-            }
-        }
-        /// <summary>
-        /// Save Scene事件
-        /// </summary>
-        internal static System.Action _onSaveSceneEvent;
-        public static System.Action OnSaveSceneEvent
-        {
-            get
-            {
-                return _onSaveSceneEvent;
-            }
-            set
-            {
-                _onSaveSceneEvent= value;
-            }
-        }
-
-        /// <summary>
-        /// 是否静态构造完成
-        /// </summary>
-        public static bool IsInited { get; private set; }
-        static KUnityEditorEventCatcher()
-        {
-            EditorApplication.update -= OnEditorUpdate;
-            EditorApplication.update += OnEditorUpdate;
-
-            // change by sunxun on 20211011 for warnning;
-            //SceneView.onSceneGUIDelegate -= OnSceneViewGUI;
-            SceneView.duringSceneGui -= OnSceneViewGUI;
-            //SceneView.onSceneGUIDelegate += OnSceneViewGUI;
-            SceneView.duringSceneGui += OnSceneViewGUI;
-
-            // change by sunxun on 20181019 for warnning;
-            //EditorApplication.playmodeStateChanged -= OnPlayModeStateChanged;
-            EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
-            //EditorApplication.playmodeStateChanged += OnPlayModeStateChanged;
-            EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
-
-            if (OnLockingAssembly != null)
-            {
-                EditorApplication.LockReloadAssemblies();
-                OnLockingAssembly();
-                EditorApplication.UnlockReloadAssemblies();
-            }
-
-
-            IsInited = true;
-        }
-
-        /// <summary>
-        /// For BeforeBuildEvent, Because in Unity:   PostProcessScene -> PostProcessScene ->.... PostProcessScene -> PostProcessBuild
-        /// When true, waiting PostProcessBuild to revert to false
-        /// </summary>
-        private static bool _beforeBuildFlag = false;
-
-        [PostProcessScene]
-        private static void OnProcessScene()
-        {
-            if (!_beforeBuildFlag && !EditorApplication.isPlayingOrWillChangePlaymode)
-            {
-                _beforeBuildFlag = true;
-
-                if (OnBeforeBuildPlayerEvent != null)
-                    OnBeforeBuildPlayerEvent();
-            }
-        }
-        /// <summary>
-        /// Unity标准Build后处理函数
-        /// </summary>
-        [PostProcessBuild()]
-        private static void OnPostBuildPlayer(BuildTarget target, string pathToBuiltProject)
-        {
-            if (OnPostBuildPlayerEvent != null)
-            {
-                OnPostBuildPlayerEvent(target, pathToBuiltProject);
-            }
-
-            UnityEngine.Debug.Log(string.Format("Success build ({0}) : {1}", target, pathToBuiltProject));
-        }
-
-        /// <summary>
-        /// 播放状态改变,进行一些编译性的东西, 比如点击播放,编译文件、编译脚本、编译配置等
-        /// </summary>
-        private static void OnPlayModeStateChanged(PlayModeStateChange state)
-        {
-            if (EditorApplication.isPlayingOrWillChangePlaymode)
-            {
-                if (!EditorApplication.isPlaying) // means Will Change to Playmode
-                {
-                    if (OnWillPlayEvent != null)
-                    {
-                        OnWillPlayEvent();
-                    }
-                }
-                else
-                {
-                    if (OnBeginPlayEvent != null)
-                    {
-                        OnBeginPlayEvent();
-                    }
-                }
-            }
-            else
-            {
-                if (EditorApplication.isPlaying)
-                {
-                    if (OnWillStopEvent != null)
-                    {
-                        OnWillStopEvent();
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// 捕捉编译过程中、同时播放游戏的状态,强制暂停,避免运行出错
-        /// </summary>
-        /// <param name="view"></param>
-        //static void OnSceneViewGUI(SceneView view)
-        static void OnEditorUpdate()
-        {
-            CheckComplie();
-            if (OnEditorUpdateEvent != null)
-            {
-                OnEditorUpdateEvent();
-            }
-        }
-
-        private static void OnSceneViewGUI(SceneView sceneview)
-        {
-            CheckComplie();
-        }
-
-        static void CheckComplie()
-        {
-            // 检查编译中,立刻暂停游戏!
-            if (EditorApplication.isCompiling)
-            {
-                if (EditorApplication.isPlaying)
-                {
-                    UnityEngine.Debug.Log("Force Stop Play, because of Compiling.");
-                    EditorApplication.isPlaying = false;
-                }
-            }
-        }
-    }
-
-    internal class SaveSceneAssetModificationProcessor : UnityEditor.AssetModificationProcessor
-    {
-        public static string[] OnWillSaveAssets(string[] paths)
-        {
-            foreach (string path in paths)
-            {
-                if (path.Contains(".unity"))
-                {
-                    //scenePath = Path.GetDirectoryName(path);
-                    //sceneName = Path.GetFileNameWithoutExtension(path);
-                    // KUnityEditorEventCatcher._onSaveSceneEvent();
-                }
-            }
-
-            return paths;
-        }
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/Editor/Tools/SUnityEditorEventCatcher.cs.meta

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

+ 0 - 8
LuaDemo/Assets/SFramework/Module.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 633de8b60b62e1c4a87b5f8f11f02774
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 10
LuaDemo/Assets/SFramework/Module/SCoroutineRunner.cs

@@ -1,10 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace SFramework
-{
-    public class SCoroutineRunner : MonoBehaviour
-    {
-    }
-}

+ 0 - 119
LuaDemo/Assets/SFramework/Module/SEventManager.cs

@@ -1,119 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace SFramework{
-
-    public static class SEventManager {
-        public enum EVENT {
-            BEGIN = 0,
-
-            //UI_ACTIVE_WELCOME,
-            //UI_ACTIVE_SETTING,
-            //UI_ACTIVE_BUY,
-
-            //IAP_DATA_READY,
-            //IAP_PAY_SUCCESS,
-            //IAP_PAY_FAILED,
-            //ADS_PLAY_FINISH,
-            //ADS_PLAY_SKIPPED,
-            //ADS_PLAY_FAILED,
-            //ADS_PLAY_CONTINUE,
-
-            //HTTP_QUERY_RECORD_RESPOND,
-            //HTTP_COMMIT_RECORD_SUCCESS,
-
-            END,
-        }
-
-        public delegate void EventCallbackDelegate(EVENT ev, Object[] args);
-
-        private static Dictionary<EVENT, EventCallbackDelegate> _dictEvents;
-        private static List<EventCallbackDelegate> _lstGlobalEventCallback;
-        private static List<Action> _lstActions;
-        static SEventManager() {
-            _lstGlobalEventCallback = new List<EventCallbackDelegate>() {DefaultEventCallback};
-            _lstActions = new List<Action>();
-            _dictEvents = new Dictionary<EVENT, EventCallbackDelegate>();
-            for (EVENT ev = EVENT.BEGIN + 1; ev < EVENT.END; ++ev) {
-                _dictEvents[ev] = new EventCallbackDelegate(DefaultEventCallback);
-            }
-        }
-
-        public static void DestroyAllSceneEvent() {
-            for (EVENT ev = EVENT.BEGIN + 1; ev < EVENT.END; ++ev) {
-                foreach (Delegate i in _dictEvents[ev].GetInvocationList()) {
-                    if (!_lstGlobalEventCallback.Contains(i as EventCallbackDelegate)) {
-                        _dictEvents[ev] -= (i as EventCallbackDelegate);
-                    }
-                }
-            }
-        }
-
-        private static void DefaultEventCallback(EVENT ev, Object[] args) {
-        }
-
-        public static void RegisterGlobalEvent(EVENT ev, EventCallbackDelegate cb) {
-            _lstActions.Add(() => {
-                _lstGlobalEventCallback.Add(cb);
-                _dictEvents[ev] += cb;
-            });
-
-            TryProcessActions();
-        }
-
-        public static void RegisterEvent(EVENT ev, EventCallbackDelegate cb) {
-            _lstActions.Add(() => {
-                _dictEvents[ev] += cb;
-            });
-
-            TryProcessActions();
-        }
-
-        public static void UnregisterEvent(EVENT ev, EventCallbackDelegate cb) {
-            _lstActions.Add(() => {
-                _dictEvents[ev] -= cb;
-                _lstGlobalEventCallback.Remove(cb);
-            });
-            TryProcessActions();
-        }
-
-        private static void TryProcessActions() {
-            if (_lstActions.Count > 1) {
-                return;
-            }
-
-            while (_lstActions.Count > 0) {
-                Action action = _lstActions[0];
-                try {
-                    action();
-                } catch (Exception e) {
-                    UnityEngine.Debug.LogError(String.Format("ProcessAction Error:" + e.StackTrace));
-                } finally {
-                    UnityEngine.Debug.Assert(_lstActions[0] == action, "Action List Changed during Processing");
-                    _lstActions.RemoveAt(0);
-                }
-            }
-        }
-
-        private static void FireEventInternal(EVENT ev, Object[] args) {
-            //UnityEngine.Debug.Log("FireEvent:" + ev.ToString());
-            foreach (EventCallbackDelegate cb in _dictEvents[ev].GetInvocationList()) {
-                try {
-                    cb(ev, args);
-                } catch (Exception e) {
-                    UnityEngine.Debug.LogError(String.Format("ProcessEvent {0} Message:{1} Error:{2}", ev.ToString(), e.Message, e.StackTrace));
-                }
-            }
-        }
-    
-        public static void FireEvent(EVENT ev, params object[] args) {
-            //UnityEngine.Debug.Log("EventManager FireEvent -> Event.Name: " + ev.ToString() + " Length: " + args.Length.ToString());
-            
-            _lstActions.Add(()=> {
-                FireEventInternal(ev, args);
-            });
-
-            TryProcessActions();
-        }
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/Module/SEventManager.cs.meta

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

+ 0 - 534
LuaDemo/Assets/SFramework/Module/SLuaComponent.cs

@@ -1,534 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEngine.EventSystems;
-
-namespace SFramework
-{
-    [XLua.LuaCallCSharp]
-    public class SLuaComponent : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
-    {
-        public TextAsset luaScript;
-        private XLua.LuaTable _luaTable;
-
-        private XLua.LuaFunction _luaAwake;
-        private XLua.LuaFunction _luaStart;
-        private XLua.LuaFunction _luaUpdate;
-        private XLua.LuaFunction _luaFixedUpdate;
-        private XLua.LuaFunction _luaLateUpdate;
-        private XLua.LuaFunction _luaOnDestroy;
-        private XLua.LuaFunction _luaOnEnable;
-        private XLua.LuaFunction _luaOnDisable;
-        private XLua.LuaFunction _luaOnApplicationFocus;
-        private XLua.LuaFunction _luaOnApplicationPause;
-        private XLua.LuaFunction _luaOnApplicationQuit;
-        private XLua.LuaFunction _luaOnCollisionEnter;
-        private XLua.LuaFunction _luaOnCollisionEnter2D;
-        private XLua.LuaFunction _luaOnCollisionExit;
-        private XLua.LuaFunction _luaOnCollisionExit2D;
-        private XLua.LuaFunction _luaOnCollisionStay;
-        private XLua.LuaFunction _luaOnCollisionStay2D;
-        private XLua.LuaFunction _luaOnMouseDown;
-        private XLua.LuaFunction _luaOnMouseDrag;
-        private XLua.LuaFunction _luaOnMouseEnter;
-        private XLua.LuaFunction _luaOnMouseExit;
-        private XLua.LuaFunction _luaOnMouseOver;
-        private XLua.LuaFunction _luaOnMouseUp;
-        private XLua.LuaFunction _luaOnMouseUpAsButton;
-        private XLua.LuaFunction _luaOnTriggerEnter;
-        private XLua.LuaFunction _luaOnTriggerEnter2D;
-        private XLua.LuaFunction _luaOnTriggerExit;
-        private XLua.LuaFunction _luaOnTriggerExit2D;
-        private XLua.LuaFunction _luaOnTriggerStay;
-        private XLua.LuaFunction _luaOnTriggerStay2D;
-        private XLua.LuaFunction _luaOnBeginDrag;
-        private XLua.LuaFunction _luaOnEndDrag;
-        private XLua.LuaFunction _luaOnDrag;
-
-        internal static XLua.LuaEnv luaEnv = SLuaEnv.Instance;
-        internal static float lastGCTime = 0;
-        internal const float GCInterval = 1;
-
-        public static void Add(GameObject targetGameObject, XLua.LuaTable luaTable, string luaFileName)
-        {
-            SLuaComponent luaComponent = targetGameObject.AddComponent<SLuaComponent>();
-            luaComponent.luaScript = new UnityEngine.TextAsset("print('The lua script add dynamic.')");
-            luaComponent.luaScript.name = luaFileName;
-            if (null == luaFileName) { Debug.LogWarning("SLuaComponent Add Script Dynamic But Do Not Set Script Name!"); }
-            luaComponent.SetLuaTable(luaTable);
-        }
-
-        public void SetLuaTable(XLua.LuaTable luaTable)
-        {
-            Debug.Assert(null != luaTable, "SLuaComponent SetLuaTable Failed luaTable == null");
-            Debug.Assert(null == _luaTable, "SLuaComponent SetLuaTable Failed _luaTable != null");
-
-            _luaTable = luaTable;
-            InitLuaFunction();
-
-            // Try Call Awake Function();
-            if (null != _luaAwake)
-                _luaAwake.Call(gameObject);
-        }
-
-        private void InitLuaFunction()
-        {
-            if (null == _luaTable)
-            {
-                Debug.LogError("SLuaComponent InitLuaFunction Failed Because _luaTable == null");
-                return;
-            }
-
-            _luaAwake = _luaTable.Get<XLua.LuaFunction>("Awake");
-            _luaStart = _luaTable.Get<XLua.LuaFunction>("Start");
-            _luaUpdate = _luaTable.Get<XLua.LuaFunction>("Update");
-            _luaFixedUpdate = _luaTable.Get<XLua.LuaFunction>("FixedUpdate");
-            _luaLateUpdate = _luaTable.Get<XLua.LuaFunction>("LateUpdate");
-            _luaOnDestroy = _luaTable.Get<XLua.LuaFunction>("OnDestroy");
-            _luaOnEnable = _luaTable.Get<XLua.LuaFunction>("OnEnable");
-            _luaOnDisable = _luaTable.Get<XLua.LuaFunction>("OnDisable");
-            _luaOnApplicationFocus = _luaTable.Get<XLua.LuaFunction>("OnApplicationFocus");
-            _luaOnApplicationPause = _luaTable.Get<XLua.LuaFunction>("OnApplicationPause");
-            _luaOnApplicationQuit = _luaTable.Get<XLua.LuaFunction>("OnApplicationQuit");
-            _luaOnCollisionEnter = _luaTable.Get<XLua.LuaFunction>("OnCollisionEnter");
-            _luaOnCollisionEnter2D = _luaTable.Get<XLua.LuaFunction>("OnCollisionEnter2D");
-            _luaOnCollisionExit = _luaTable.Get<XLua.LuaFunction>("OnCollisionExit");
-            _luaOnCollisionExit2D = _luaTable.Get<XLua.LuaFunction>("OnCollisionExit2D");
-            _luaOnCollisionStay = _luaTable.Get<XLua.LuaFunction>("OnCollisionStay");
-            _luaOnCollisionStay2D = _luaTable.Get<XLua.LuaFunction>("OnCollisionStay2D");
-            _luaOnMouseDown = _luaTable.Get<XLua.LuaFunction>("OnMouseDown");
-            _luaOnMouseDrag = _luaTable.Get<XLua.LuaFunction>("OnMouseDrag");
-            _luaOnMouseEnter = _luaTable.Get<XLua.LuaFunction>("OnMouseEnter");
-            _luaOnMouseExit = _luaTable.Get<XLua.LuaFunction>("OnMouseExit");
-            _luaOnMouseOver = _luaTable.Get<XLua.LuaFunction>("OnMouseOver");
-            _luaOnMouseUp = _luaTable.Get<XLua.LuaFunction>("OnMouseUp");
-            _luaOnMouseUpAsButton = _luaTable.Get<XLua.LuaFunction>("OnMouseUpAsButton");
-            _luaOnTriggerEnter = _luaTable.Get<XLua.LuaFunction>("OnTriggerEnter");
-            _luaOnTriggerEnter2D = _luaTable.Get<XLua.LuaFunction>("OnTriggerEnter2D");
-            _luaOnTriggerExit = _luaTable.Get<XLua.LuaFunction>("OnTriggerExit");
-            _luaOnTriggerExit2D = _luaTable.Get<XLua.LuaFunction>("OnTriggerExit2D");
-            _luaOnTriggerStay = _luaTable.Get<XLua.LuaFunction>("OnTriggerStay");
-            _luaOnTriggerStay2D = _luaTable.Get<XLua.LuaFunction>("OnTriggerStay2D");
-            _luaOnBeginDrag = _luaTable.Get<XLua.LuaFunction>("OnBeginDrag");
-            _luaOnEndDrag = _luaTable.Get<XLua.LuaFunction>("OnEndDrag");
-            _luaOnDrag = _luaTable.Get<XLua.LuaFunction>("OnDrag");
-        }
-
-        private void Awake()
-        {
-            if (null == luaScript)
-                return;
-
-            System.Object[] retValues = luaEnv.DoString(luaScript.text, "LuaComponent");
-            if (null == retValues || retValues.Length != 1)
-            {
-                Debug.LogWarning("SLuaCompnent Need A Lua That Return A LuaTable.");
-                Debug.LogError("SLuaComponent Load LuaScript Failed When Awake, ScriptName: " + luaScript.name);
-                return;
-            }
-
-            _luaTable = retValues[0] as XLua.LuaTable;
-
-            InitLuaFunction();
-
-            if (null != _luaAwake)
-                _luaAwake.Call(gameObject);
-        }
-
-        private void Start()
-        {
-            if (null != _luaStart)
-                _luaStart.Call(gameObject);
-        }
-
-        private void Update()
-        {
-            if (Time.time - SLuaComponent.lastGCTime > GCInterval)
-            {
-                luaEnv.Tick();
-                SLuaComponent.lastGCTime = Time.time;
-            }
-
-            if (null != _luaUpdate)
-                _luaUpdate.Call();
-        }
-
-        private void FixedUpdate()
-        {
-            if (null != _luaFixedUpdate)
-                _luaFixedUpdate.Call();
-        }
-
-        private void LateUpdate()
-        {
-            if (null != _luaLateUpdate)
-                _luaLateUpdate.Call();
-        }
-
-        private void OnDestroy()
-        {
-            if (null != _luaOnDestroy)
-                _luaOnDestroy.Call();
-
-            if (null != _luaAwake)
-            {
-                _luaAwake.Dispose();
-                _luaAwake = null;
-            }
-            
-            if (null != _luaStart)
-            {
-                _luaStart.Dispose();
-                _luaStart = null;
-            }
-
-            if (null != _luaUpdate)
-            {
-                _luaUpdate.Dispose();
-                _luaUpdate = null;
-            }
-
-            if (null != _luaFixedUpdate)
-            {
-                _luaFixedUpdate.Dispose();
-                _luaFixedUpdate = null;
-            }
-
-            if (null != _luaLateUpdate)
-            {
-                _luaLateUpdate.Dispose();
-                _luaLateUpdate = null;
-            }
-
-            if (null != _luaOnDestroy)
-            {
-                _luaOnDestroy.Dispose();
-                _luaOnDestroy = null;  
-            }
-
-            if (null != _luaOnEnable)
-            {
-                _luaOnEnable.Dispose();
-                _luaOnEnable = null;
-            }
-
-            if (null != _luaOnDisable)
-            {
-                _luaOnDisable.Dispose();
-                _luaOnDisable = null;
-            }
-
-            if (null != _luaOnApplicationFocus)
-            {
-                _luaOnApplicationFocus.Dispose();
-                _luaOnApplicationFocus = null;
-            }
-
-            if (null != _luaOnApplicationPause)
-            {
-                _luaOnApplicationPause.Dispose();
-                _luaOnApplicationPause = null;
-            }
-
-            if (null != _luaOnApplicationQuit)
-            {
-                _luaOnApplicationQuit.Dispose();
-                _luaOnApplicationQuit = null;  
-            }
-
-            if (null != _luaOnCollisionEnter)
-            {
-                _luaOnCollisionEnter.Dispose();
-                _luaOnCollisionEnter = null;
-            }
-
-            if (null != _luaOnCollisionEnter2D)
-            {
-                _luaOnCollisionEnter2D.Dispose();
-                _luaOnCollisionEnter2D = null;
-            }
-
-            if (null != _luaOnCollisionExit)
-            {
-                _luaOnCollisionExit.Dispose();
-                _luaOnCollisionExit = null;
-            }
-
-            if (null != _luaOnCollisionExit2D)
-            {
-                _luaOnCollisionExit2D.Dispose();
-                _luaOnCollisionExit2D = null;
-            }
-
-            if (null != _luaOnCollisionStay)
-            {
-                _luaOnCollisionStay.Dispose();
-                _luaOnCollisionStay = null;
-            }
-
-            if (null != _luaOnCollisionStay2D)
-            {
-                _luaOnCollisionStay2D.Dispose();
-                _luaOnCollisionStay2D = null;
-            }
-
-            if (null != _luaOnMouseDown)
-            {
-                _luaOnMouseDown.Dispose();
-                _luaOnMouseDown = null;
-            }
-
-            if (null != _luaOnMouseDrag)
-            {
-                _luaOnMouseDrag.Dispose();
-                _luaOnMouseDrag = null;
-            }
-
-            if (null != _luaOnMouseEnter)
-            {
-                _luaOnMouseEnter.Dispose();
-                _luaOnMouseEnter = null;
-            }
-
-            if (null != _luaOnMouseExit)
-            {
-                _luaOnMouseExit.Dispose();
-                _luaOnMouseExit = null;
-            }
-
-            if (null != _luaOnMouseOver)
-            {
-                _luaOnMouseOver.Dispose();
-                _luaOnMouseOver = null;
-            }
-
-            if (null != _luaOnMouseUp)
-            {
-                _luaOnMouseUp.Dispose();
-                _luaOnMouseUp = null;
-            }
-
-            if (null != _luaOnMouseUpAsButton)
-            {
-                _luaOnMouseUpAsButton.Dispose();
-                _luaOnMouseUpAsButton = null;
-            }
-
-            if (null != _luaOnTriggerEnter)
-            {
-                _luaOnTriggerEnter.Dispose();
-                _luaOnTriggerEnter = null;  
-            }
-
-            if (null != _luaOnTriggerEnter2D)
-            {
-                _luaOnTriggerEnter2D.Dispose();
-                _luaOnTriggerEnter2D = null;
-            }
-
-            if (null != _luaOnTriggerExit)
-            {
-                _luaOnTriggerExit.Dispose();
-                _luaOnTriggerExit = null;
-            }
-
-            if (null != _luaOnTriggerExit2D)
-            {
-                _luaOnTriggerExit2D.Dispose();
-                _luaOnTriggerExit2D = null;
-            }
-
-            if (null != _luaOnTriggerStay)
-            {
-                _luaOnTriggerStay.Dispose();
-                _luaOnTriggerStay = null;
-            }
-
-            if (null != _luaOnTriggerStay2D)
-            {
-                _luaOnTriggerStay2D.Dispose();
-                _luaOnTriggerStay2D = null;
-            }
-
-            if (null != _luaOnBeginDrag)
-            {
-                _luaOnBeginDrag.Dispose();
-                _luaOnBeginDrag = null;
-            }
-
-            if (null != _luaOnEndDrag)
-            {
-                _luaOnEndDrag.Dispose();
-                _luaOnEndDrag = null;
-            }
-
-            if (null != _luaOnDrag)
-            {
-                _luaOnDrag.Dispose();
-                _luaOnDrag = null;
-            }
-        }
-
-        private void OnEnable()
-        {
-            if (null != _luaOnEnable)
-                _luaOnEnable.Call();
-        }
-
-        private void OnDisable()
-        {
-            if (null != _luaOnDisable)
-                _luaOnDisable.Call();
-        }
-
-        private void OnApplicationFocus(bool focus)
-        {
-            if (null != _luaOnApplicationFocus)
-                _luaOnApplicationFocus.Call(focus);
-        }
-
-        private void OnApplicationPause(bool pause)
-        {
-            if (null != _luaOnApplicationPause)
-                _luaOnApplicationPause.Call(pause);
-        }
-
-        private void OnApplicationQuit()
-        {
-            if (null != _luaOnApplicationQuit)
-                _luaOnApplicationQuit.Call();
-        }
-
-        private void OnCollisionEnter(Collision collision)
-        {
-            if (null != _luaOnCollisionEnter)
-                _luaOnCollisionEnter.Call(collision);
-        }
-
-        private void OnCollisionEnter2D(Collision2D collision)
-        {
-            if (null != _luaOnCollisionEnter2D)
-                _luaOnCollisionEnter2D.Call(collision);
-        }
-
-        private void OnCollisionExit(Collision collision)
-        {
-            if (null != _luaOnCollisionExit)
-                _luaOnCollisionExit.Call(collision);
-        }
-
-        private void OnCollisionExit2D(Collision2D collision)
-        {
-            if (null != _luaOnCollisionExit2D)
-                _luaOnCollisionExit2D.Call(collision);
-        }
-
-        private void OnCollisionStay(Collision collision)
-        {
-            if (null != _luaOnCollisionStay)
-                _luaOnCollisionStay.Call(collision);
-        }
-        
-        private void OnCollisionStay2D(Collision2D collision)
-        {
-            if (null != _luaOnCollisionStay2D)
-                _luaOnCollisionStay2D.Call(collision);
-        }
-        
-        private void OnMouseDown()
-        {
-            if (null != _luaOnMouseDown)
-                _luaOnMouseDown.Call();
-        }
-
-        private void OnMouseDrag()
-        {
-            if (null != _luaOnMouseDrag)
-                _luaOnMouseDrag.Call();
-        }
-
-        private void OnMouseEnter()
-        {
-            if (null != _luaOnMouseEnter)
-                _luaOnMouseEnter.Call();
-        }
-
-        private void OnMouseExit()
-        {
-            if (null != _luaOnMouseExit)
-                _luaOnMouseExit.Call();
-        }
-
-        private void OnMouseOver()
-        {
-            if (null != _luaOnMouseOver)
-                _luaOnMouseOver.Call();
-        }
-
-        private void OnMouseUp()
-        {
-            if (null != _luaOnMouseUp)
-                _luaOnMouseUp.Call();
-        }
-
-        private void OnMouseUpAsButton()
-        {
-            if (null != _luaOnMouseUpAsButton)
-                _luaOnMouseUpAsButton.Call();
-        }
-
-        private void OnTriggerEnter(Collider other)
-        {
-            if (null != _luaOnTriggerEnter)
-                _luaOnTriggerEnter.Call(other);
-        }
-
-        private void OnTriggerEnter2D(Collider2D other)
-        {
-            if (null != _luaOnTriggerEnter2D)
-                _luaOnTriggerEnter2D.Call(other);
-        }
-
-        private void OnTriggerExit(Collider other)
-        {
-            if (null != _luaOnTriggerExit)
-                _luaOnTriggerExit.Call(other);
-        }
-
-        private void OnTriggerExit2D(Collider2D other)
-        {
-            if (null != _luaOnTriggerExit2D)   
-                _luaOnTriggerExit2D.Call(other);
-        }
-
-        private void OnTriggerStay(Collider other)
-        {
-            if (null != _luaOnTriggerStay)
-                _luaOnTriggerStay.Call(other);
-        }
-
-        private void OnTriggerStay2D(Collider2D other)
-        {
-            if (null != _luaOnTriggerStay2D)
-                _luaOnTriggerStay2D.Call(other);
-        }
-
-        public void OnBeginDrag(PointerEventData eventData)
-        {
-            if (null != _luaOnBeginDrag)
-                _luaOnBeginDrag.Call(eventData);
-        }
-
-        public void OnEndDrag(PointerEventData eventData)
-        {
-            if (null != _luaOnEndDrag)
-                _luaOnEndDrag.Call(eventData);
-        }
-
-        public void OnDrag(PointerEventData eventData)
-        {
-            if (null != _luaOnDrag)
-                _luaOnDrag.Call(eventData);
-        }
-    }
-}

+ 0 - 315
LuaDemo/Assets/SFramework/Module/SResourceManager.cs

@@ -1,315 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace SFramework
-{
-    public class SResourceManager
-    {
-        private static AssetBundleManifest _mainAssetBundleManifest = null;
-        private static Dictionary<string, AssetBundle> _loadedAssetBundle = new Dictionary<string, AssetBundle>();
-
-        public static string TestCall(string value)
-        {
-            Debug.Log("SFramework.SResourceManager.TestCall -> " + value);
-
-            return "TestCall Return Value.";
-        }
-
-        public static UnityEngine.Object LoadResource(string resourcePath)
-        {
-            UnityEngine.Object targetObject = null;
-            resourcePath = resourcePath.ToLower();
-#pragma warning disable 0162
-            // Editor Direct Read Res
-            if (Application.isEditor && !SFrameworkDef.isLoadAssetsBundleOnEditor)
-            {
-                string resFinalPath = "";
-#if UNITY_EDITOR
-                resFinalPath = "Assets/" + SFrameworkDef.ResourceDir + "/" + resourcePath;
-                targetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(resFinalPath, typeof(UnityEngine.Object));
-                Debug.Assert(targetObject != null);
-#endif
-                return targetObject;
-            }
-#pragma warning restore 0162
-            // Editor or non-Editor Read AssetsBundle
-            else
-            {
-                // Check Main AssetBundleManifest.
-                if (_mainAssetBundleManifest == null)
-                {
-                    LoadMainAssetBundleManifest();
-                }
-
-                string abExtName = SFrameworkDef.AssetsBundleExtName;
-                targetObject = LoadOneAssetBundle(resourcePath + abExtName);
-                // Disable it on 20181023 by SunXun. Because targeetObject == null. If the assetbundle.isStreamedSceneAssetBundle == true.
-                // Debug.Assert(targetObject != null);
-
-                return targetObject;
-            }
-        }
-
-        private static void LoadMainAssetBundleManifest()
-        {
-            string mainManifestPath = "";
-            string platformName = SPlatformInfo.GetBuildPlatformName();
-            string persistentPath = Application.persistentDataPath + "/Bundles/" + platformName + "/" + platformName;
-            string streamingPath = Application.streamingAssetsPath + "/Bundles/" + platformName + "/" + platformName;
-
-            // Process Special Android Path.
-            if (platformName == "Android" && !Application.isEditor)
-            {
-                streamingPath = Application.dataPath + "!assets/Bundles/" + platformName + "/" + platformName;
-                mainManifestPath = streamingPath;
-            }
-
-            if (System.IO.File.Exists(streamingPath))
-                mainManifestPath = streamingPath;
-
-            if (System.IO.File.Exists(persistentPath))
-                mainManifestPath = persistentPath;
-
-            if (string.IsNullOrEmpty(mainManifestPath))
-            {
-                Debug.LogError(string.Format("LoadMainAssetBundleManifest Failed ! File:{0} Is Not Existed!", mainManifestPath));
-                return;
-            }
-            Debug.Log("LoadMainAssetBundleManifest -> mainManifestPath -> " + mainManifestPath);
-
-            AssetBundle manifestAB = AssetBundle.LoadFromFile(mainManifestPath);
-            Debug.Assert(mainManifestPath != null);
-            _mainAssetBundleManifest = manifestAB.LoadAsset("AssetBundleManifest") as AssetBundleManifest;
-            Debug.Assert(_mainAssetBundleManifest != null);
-            Debug.Log("LoadMainAssetBundleManifest Success!");
-        }
-
-        private static UnityEngine.Object LoadOneAssetBundle(string assetBundleFullName)
-        {
-            Debug.Assert(_mainAssetBundleManifest != null);
-
-            UnityEngine.Object targetObject;
-            string resourcePath = "";
-            string platformName = SPlatformInfo.GetBuildPlatformName();
-            string persistentPath = Application.persistentDataPath + "/Bundles/" + platformName + "/" + assetBundleFullName;
-            string streamingPath = Application.streamingAssetsPath + "/Bundles/" + platformName + "/" + assetBundleFullName;
-            string assetName = GetAssetNameByAssetBundleFullName(assetBundleFullName);
-
-            // Process Loaded Asset Bundle.
-            if (_loadedAssetBundle.ContainsKey(assetBundleFullName))
-            {
-                AssetBundle loadedAB = _loadedAssetBundle[assetBundleFullName];
-                Debug.Assert(loadedAB != null);
-                targetObject = loadedAB.LoadAsset(assetName);
-                Debug.Assert(targetObject != null);
-                Debug.Log(string.Format("LoadOneAssetBundle -> Load By Cache AsetName:{0} From:{1}", assetName, assetBundleFullName));
-                return targetObject;
-            }
-
-            // Process Special Android Path.
-            if (platformName == "Android" && !Application.isEditor)
-            {
-                streamingPath = Application.dataPath + "!assets/Bundles/" + platformName + "/" + assetBundleFullName;
-                resourcePath = streamingPath;
-            }
-
-            // For Editor Link.
-            if (System.IO.File.Exists(streamingPath))
-                resourcePath = streamingPath;
-
-            if (System.IO.File.Exists(persistentPath))
-                resourcePath = persistentPath;
-
-            if (string.IsNullOrEmpty(resourcePath))
-            {
-                Debug.LogError(string.Format("LoadOneAssetBundle Failed ! File:{0} Is Not Existed!", assetBundleFullName));
-                return null;
-            }
-            //Debug.Log("LoadOneAssetBundle -> resourcePath -> " + resourcePath);
-
-            // Load All Dependencies
-            string[] dependenciesArray = _mainAssetBundleManifest.GetAllDependencies(assetBundleFullName);
-            for (var depIndex = 0; depIndex < dependenciesArray.Length; depIndex++)
-                LoadOneAssetBundle(dependenciesArray[depIndex]);
-
-            // Load AssetBundle
-            AssetBundle resourceAB = AssetBundle.LoadFromFile(resourcePath);
-            Debug.Assert(resourceAB != null);
-            if (resourceAB.isStreamedSceneAssetBundle)
-            {
-                // isStreamedSceneAssetBundle Can't Be LoadAsset.
-                // just can load like below.
-                // string[] scenePath = resourceAB.GetAllScenePaths();
-                // string sceneName = System.IO.Path.GetFileNameWithoutExtension(scenePath[0]);
-                // UnityEngine.SceneManagement.Scene targetScene = UnityEngine.SceneManagement.SceneManager.GetSceneByName(sceneName);
-                // UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName);
-                // targetObject = targetScene as UnityEngine.Object;
-                targetObject = null;
-            }
-            else 
-            {
-                targetObject = resourceAB.LoadAsset(assetName);
-                Debug.Assert(targetObject != null);
-            }
-
-            _loadedAssetBundle.Add(assetBundleFullName, resourceAB);
-            Debug.Log(string.Format("LoadOneAssetBundle -> Load By File AssetName:{0} From:{1}", assetName, assetBundleFullName));
-
-            return targetObject;
-        }
-
-        private static string GetAssetNameByAssetBundleFullName(string assetBundleFullName)
-        {
-            string[] splitArray = assetBundleFullName.Split('/');
-            string splitString = splitArray[splitArray.Length - 1];
-
-            int extNameLengh = SFrameworkDef.AssetsBundleExtName.Length;
-            string finalString = splitString.Substring(0, splitString.Length - extNameLengh);
-
-            return finalString;
-        }
-
-        private static string GetAssetNameByAssetBundleFullNameWithExt(string assetBundleFullName)
-        {
-            string[] splitArray = assetBundleFullName.Split('/');
-            string splitString = splitArray[splitArray.Length - 1];
-            string finalString = splitString;
-
-            return finalString;
-        }
-
-        public static SFramework.SVersionInfo GetLocalVersionInfo()
-        {
-            var platformName = SPlatformInfo.GetBuildPlatformName();
-            string persistentPath = Application.persistentDataPath + "/Bundles/" + platformName + "/" + SFrameworkDef.VersionFileName;
-            string streamingPath = Application.streamingAssetsPath + "/Bundles/" + platformName + "/" + SFrameworkDef.VersionFileName;
-            string versionFilePath = "";
-            bool canLoadFromFileDirectly = false;
-
-            // Process Special Android Real Machine Path.
-            if (platformName == "Android" && !Application.isEditor)
-            {
-                streamingPath = "jar:file://" + Application.dataPath + "!assets/Bundles/" + platformName + "/" + SFrameworkDef.VersionFileName;
-                versionFilePath = streamingPath;
-                canLoadFromFileDirectly = false;
-            }
-
-            // For Editor Link.
-            if (System.IO.File.Exists(streamingPath))
-            {
-                versionFilePath = streamingPath;
-                canLoadFromFileDirectly = true;
-            }
-
-            Debug.Log("persistentPath -> " + persistentPath);
-            if (System.IO.File.Exists(persistentPath))
-            {
-                versionFilePath = persistentPath;
-                canLoadFromFileDirectly = true;
-            }
-
-            if (string.IsNullOrEmpty(versionFilePath))
-            {
-                Debug.LogError(string.Format("GetLocalVersionInfo Failed ! File:{0} Is Not Existed!", versionFilePath));
-                return null;
-            }
-            Debug.Log("GetLocalVersionInfo -> File Path -> " + versionFilePath);
-
-            string versionInfo = "";
-            if (canLoadFromFileDirectly)
-            {
-                versionInfo = System.IO.File.ReadAllText(versionFilePath);
-            }
-            else
-            {
-                UnityEngine.Networking.UnityWebRequest versionFileLoader =
-                    UnityEngine.Networking.UnityWebRequest.Get(versionFilePath);
-                versionFileLoader.timeout = 3;
-                versionFileLoader.SendWebRequest();
-                while (!versionFileLoader.isDone)
-                {
-                    // just wait.
-                }
-                //if (versionFileLoader.isNetworkError || versionFileLoader.isHttpError)
-                if (versionFileLoader.result == UnityEngine.Networking.UnityWebRequest.Result.ConnectionError || versionFileLoader.result == UnityEngine.Networking.UnityWebRequest.Result.ProtocolError)
-                {
-                    Debug.LogError("GetLocalVersionInfo -> versionFileLoader error ->" + versionFileLoader.error);
-                    return null;
-                }
-                versionInfo = versionFileLoader.downloadHandler.text;
-            }
-
-
-            SVersionInfo localVersionInfo =  LitJson.JsonMapper.ToObject<SVersionInfo>(versionInfo);
-            Debug.Assert(localVersionInfo != null);
-
-            return localVersionInfo;
-        }
-
-        public static void TryDeleteAssetBundle(string assetBundleName)
-        {
-            // Here the assetBundleName include ext name , Like -> "prefabs/xxxx.prefab.s"
-            string platformName = SPlatformInfo.GetBuildPlatformName();
-            string filePath = Application.persistentDataPath + "/Bundles/" + platformName + "/" + assetBundleName;
-            string fileManifesetPath = filePath + ".manifest";
-
-            // Delete AssetBundle File.
-            if (System.IO.File.Exists(filePath))
-            {
-                System.IO.File.Delete(filePath);
-                Debug.Log(string.Format("TryDeleteAssetBundle -> Delete File:{0} Path:{1}", assetBundleName, filePath));
-            }
-
-            // Delete AssetBundle.manifest File.
-            if (System.IO.File.Exists(fileManifesetPath))
-            {
-                System.IO.File.Delete(fileManifesetPath);
-                Debug.Log(string.Format("TryDeleteAssetBundle -> Delete File:{0} Path:{1}", assetBundleName + ".manifest", filePath));
-            }
-        }
-
-        public static void SaveAssetBundle(string assetBundleName, byte[] assetBundleData)
-        {
-            string platformName = SPlatformInfo.GetBuildPlatformName();
-            string abFullPathWithName = Application.persistentDataPath + "/Bundles/" + platformName + "/" + assetBundleName;
-            string abFullPath = SToolFunction.GetAssetBundleFullPath(abFullPathWithName);
-
-            // Debug.Log("abFullPathWithName -> " + abFullPathWithName);
-            // Debug.Log("abFullPath -> " + abFullPath);
-            SToolFunction.MakeSurePathExisted(abFullPath);
-
-            System.IO.File.WriteAllBytes(abFullPathWithName, assetBundleData);
-
-            // Below is wrong. file size error.
-            // System.IO.StreamWriter abWriter = new System.IO.StreamWriter(abFullPathWithName);
-            // abWriter.Write(assetBundleData);
-            // abWriter.Close();
-            // abWriter.Dispose();
-            Debug.Log(string.Format(
-                "SResourceManager -> SaveAssetBundle abName:{0} abPath:{1}", assetBundleName, abFullPathWithName
-            ));
-        }
-
-        public static void SaveRemoteVersion(SVersionInfo remoteVersion)
-        {
-            string platformName = SPlatformInfo.GetBuildPlatformName();
-            string versionPath = Application.persistentDataPath + "/Bundles/" + platformName + "/";
-            string jsonInfo = LitJson.JsonMapper.ToJson(remoteVersion);
-
-            SToolFunction.MakeSurePathExisted(versionPath);
-            versionPath += SFrameworkDef.VersionFileName;
-
-            System.IO.StreamWriter versionWriter = new System.IO.StreamWriter(versionPath);
-            versionWriter.Write(jsonInfo);
-            versionWriter.Close();
-            versionWriter.Dispose();
-
-            Debug.Log(string.Format(
-                "SResourceManager -> SaveRemoteVersion -> SavePath:{0} VersionInfo:{1}", versionPath, jsonInfo
-            ));
-        }
-
-    }
-}
-

+ 0 - 11
LuaDemo/Assets/SFramework/Module/SResourceManager.cs.meta

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

+ 0 - 363
LuaDemo/Assets/SFramework/Module/SUpdateManager.cs

@@ -1,363 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace SFramework
-{
-    enum Update_State {
-        usInvaild,
-
-        usStart,
-        usShowUI,
-        usHotfixLua,
-        usGetResVersion,
-        usCalcUpdateResInfo,
-        usDownloadResource,
-        usFinish,
-    }
-    public class SUpdateManager : MonoBehaviour
-    {
-        private Update_State _currentState;
-        private GameObject _logicInstance;
-        private SUIPanelUpdate _uiPanelUpdate;
-        private SUIPanelTips _uiPanelTips;
-        private SVersionInfo _localResVersion, _remoteResVersion;
-        private int _willDownloadBytes;
-        private List<SFileInfo> _willDownloadFileInfoList = new List<SFileInfo>();
-
-        void Awake()
-        {
-            _currentState = Update_State.usStart;
-
-            Debug.Log("Application.dataPath            -> " + Application.dataPath);
-            Debug.Log("Application.streamingAssetsPath -> " + Application.streamingAssetsPath);
-            Debug.Log("Application.persistentDataPath  -> " + Application.persistentDataPath);
-            _logicInstance = GameObject.Find("LogicInstance");
-            Debug.Assert(_logicInstance != null);
-        }
-
-        void Start()
-        {
-            _currentState = Update_State.usShowUI;
-            ShowUpdateUI();
-            AddUIController();
-#pragma warning disable 0162
-            _currentState = Update_State.usHotfixLua;
-            if (!SFrameworkDef.isEnableHotfix) _currentState = Update_State.usFinish;
-#pragma warning restore
-            TryUpdate();
-        }
-
-        private void ShowUpdateUI()
-        {
-            // Add CanvasUI
-            GameObject canvasUpdate = SResourceManager.LoadResource("prefabs/canvas_update.prefab") as GameObject;
-            GameObject.Instantiate(canvasUpdate);
-        }
-
-        private void AddUIController()
-        {
-            // Add UIController
-            _uiPanelUpdate = _logicInstance.AddComponent<SUIPanelUpdate>();
-            _uiPanelTips = _logicInstance.AddComponent<SUIPanelTips>();
-        }
-
-        public void TryUpdate()
-        {
-            StartCoroutine(UpdateLogic());
-        }
-
-        public void UpdateStateInfo(string stateInfo)
-        {
-            Debug.Log("SUpdateManager -> " + stateInfo);
-
-            _uiPanelUpdate.SetUpdateInfo(stateInfo);
-        }
-
-        IEnumerator UpdateLogic()
-        {
-            yield return null;
-
-            switch (_currentState)
-            {
-                case Update_State.usHotfixLua:
-                    StartCoroutine(TryHotfixLuaLogic());
-                    break;
-                case Update_State.usGetResVersion:
-                    StartCoroutine(TryGetResVersionLogic());
-                    break;
-                case Update_State.usCalcUpdateResInfo:
-                    StartCoroutine(TryCalcUpdateResInfoLogic());
-                    break;
-                case Update_State.usDownloadResource:
-                    StartCoroutine(TryDownloadResource());
-                    break;
-                case Update_State.usFinish:
-                    StartCoroutine(TryFinishLogic());
-                    break;
-                default:
-                    Debug.Assert(false, "Update_State Error -> " + _currentState.ToString());
-                    break;
-            }
-
-            yield return new WaitForSeconds(1.0f);
-            // string resourceVersionURL = SFrameworkDef.resourceVersionUrl;
-            // Step 3 : Switch To Start Scene.
-        }
-
-        IEnumerator TryHotfixLuaLogic()
-        {
-            // Step 1 : Try Hotfix.
-            yield return null;
-
-            UpdateStateInfo("Communication With Server ...");
-            yield return new WaitForSeconds(1.0f);
-
-            string hotfixLuaUrl = SFrameworkDef.hotfixLuaUrl;
-            UnityEngine.Networking.UnityWebRequest luaRequest = 
-                UnityEngine.Networking.UnityWebRequest.Get(hotfixLuaUrl);
-            luaRequest.timeout = SFrameworkDef.httpRequestTimeoutTime;
-            yield return luaRequest.SendWebRequest();
-            //if (luaRequest.isNetworkError || luaRequest.isHttpError)
-            if (luaRequest.result == UnityEngine.Networking.UnityWebRequest.Result.ConnectionError || luaRequest.result == UnityEngine.Networking.UnityWebRequest.Result.ProtocolError)
-            {
-                Debug.LogError("SUpdateManager -> UpdateLogic luaRequest Error -> " + luaRequest.error);
-                UpdateStateInfo("Communication With Server ... Error: " + luaRequest.error);
-
-                // show tips and notice try again.
-                _uiPanelTips.ShowTips(
-                    "Connect Failed", 
-                    "Connection To Server Failed!\nPlease Check Your Network State.\nClick Yes Try Again. Click No Exit Game.", 
-                    delegate(){
-                        Debug.Log("SUpdateManager -> Click Tips Yes -> TryUpdate Again!");
-                        TryUpdate();
-                    }, 
-                    delegate(){
-                        Debug.Log("SUpdateManager -> Click Tips No  -> Exit Game!");
-                        Application.Quit();
-                    }
-                );
-                yield break;
-            }
-            string luaCode = luaRequest.downloadHandler.text;
-            SLuaEnv.Instance.DoString(luaCode);
-            
-            UpdateStateInfo("Communication With Server ... Success");
-            _currentState = Update_State.usGetResVersion;
-            TryUpdate();
-        }
-
-        IEnumerator TryGetResVersionLogic()
-        {
-            // Step 2 : Try Get Res Version Info And Check IsNeed Update Resource.
-            yield return null;
-
-            UpdateStateInfo("Commuication With Resource Server ...");
-            yield return new WaitForSeconds(1.0f);
-
-            string platformName = SPlatformInfo.GetBuildPlatformName();
-            string resVersionUrl = SFrameworkDef.resourceVersionUrlBase + platformName + "/" + SFrameworkDef.resourceVersionName;
-            UnityEngine.Networking.UnityWebRequest resVersionRequest = 
-                UnityEngine.Networking.UnityWebRequest.Get(resVersionUrl);
-            resVersionRequest.timeout = SFrameworkDef.httpRequestTimeoutTime;
-            yield return resVersionRequest.SendWebRequest();
-            if (resVersionRequest.result == UnityEngine.Networking.UnityWebRequest.Result.ConnectionError || resVersionRequest.result == UnityEngine.Networking.UnityWebRequest.Result.ProtocolError)
-            {
-                Debug.LogError("SUpdateManager -> UpdateLogic resVersionRequest Error -> " + resVersionRequest.error);
-                UpdateStateInfo("Communication With Resource Server ... Error: " + resVersionRequest.error);
-                
-                // show tips and notice try again.
-                _uiPanelTips.ShowTips(
-                    "Connect Failed",
-                    "Connection To Resrouce Server Failed!\nPlease Check Your Network State.\nClick Yes Try Again. Click No Exit Game.",
-                    delegate() {
-                        Debug.Log("SUpdateManager -> Click Tips Yes -> Try Again!");
-                        TryUpdate();
-                    },
-                    delegate() {
-                        Debug.Log("SUpdateManager -> Click Tips No  -> Exit Game!");
-                        Application.Quit();
-                    }
-                );
-                yield break;
-            }
-            // get version.json success start to calc download files info.
-            string versionJson = resVersionRequest.downloadHandler.text;
-            Debug.Log("remoteVersionJson -> " + versionJson);
-
-            yield return new WaitForSeconds(1.0f);
-            SVersionInfo remoteVersion = LitJson.JsonMapper.ToObject<SVersionInfo>(versionJson);
-            // Debug.Log("Remote Version -> " + remoteVersionInfo.version);
-            SVersionInfo localVersion = SResourceManager.GetLocalVersionInfo();
-            // Debug.Log("Local  Version -> " + localVersionInfo.version);
-            UpdateStateInfo(string.Format("Remote Version: {0} Local Version: {1}", remoteVersion.version, localVersion.version));
-            yield return new WaitForSeconds(1.0f);
-
-            _localResVersion = localVersion;
-            _remoteResVersion = remoteVersion;
-            yield return new WaitForSeconds(1.0f);
-            UpdateStateInfo("Commuication With Resource Server ... Success");
-
-            _currentState = Update_State.usCalcUpdateResInfo;
-            if (localVersion.version == remoteVersion.version)
-            {
-                // No need to update resource.
-                _currentState = Update_State.usFinish;
-            }
-            // Debug.Log("currentState -> " + currentState.ToString());
-            TryUpdate();
-        }
-
-        IEnumerator TryCalcUpdateResInfoLogic()
-        {
-            // Step 3: Try Update Resource By LocalVersionInfo And RemoteVersionInfo.
-            yield return null;
-
-            UpdateStateInfo("Prepare Calc Update Resource ...");
-            // Get Update File Count And File Total Size And Update FileInfoList.
-            Debug.Assert(_localResVersion != null, "TryUpdateResourceLogic -> localResVersion = null");
-            Debug.Assert(_remoteResVersion != null, "TryUpdateResourceLogic -> remoteResVersion = null");
-            Debug.Assert(_localResVersion.version != _remoteResVersion.version, "TryUpdateResourceLogic -> LVersion == RVersion");
-
-            foreach (SFileInfo oneFileInfo in _remoteResVersion.fileInfo)
-            {
-                SFileInfo localFileInfo = _localResVersion.fileInfo.Find(target => 
-                    {
-                        if (target.fileName == oneFileInfo.fileName)
-                            return true;
-                        else
-                            return false;
-                    }
-                );
-
-                // File Existed And Don't Need Update.
-                if (localFileInfo != null && localFileInfo.hashInfo == oneFileInfo.hashInfo)
-                    continue;
-
-                // File Is Not Existed Or Need Update.
-                _willDownloadBytes += oneFileInfo.fileSize;
-                _willDownloadFileInfoList.Add(oneFileInfo);
-            }
-
-            UpdateStateInfo("Prepare Calc Update Resource ... Success");
-            // Show Tips For Player.
-            // If Choose No Exit Game.
-            // If Choose Yes Start Update Resource.
-            _uiPanelTips.ShowTips(
-                "UpdateInfo",
-                string.Format(
-                    "Found new version:{0} ...\nFile Count:{1} FileSize:{2}", 
-                    _remoteResVersion.version, _willDownloadFileInfoList.Count, 
-                    System.Math.Round(_willDownloadBytes / 1024f / 1024f, 2) + "MB"
-                ),
-                delegate () {
-                    Debug.Log("SUpdateManager -> Click Tips Yes -> Start Download Logic");
-                    _currentState = Update_State.usDownloadResource;
-                    TryUpdate();
-                },
-                delegate () {
-                    Debug.Log("SUpdateManager -> Click Tips No  -> Exit Game");
-                    Application.Quit();
-                }
-            );
-        }
-
-        IEnumerator TryDownloadResource()
-        {
-            // UnityWebRequest.GetAssetBundle(string url, int version, uint crc)
-            // If crc is not zero, engine will compare crc.
-            // UnityEngine.Networking.UnityWebRequest.GetAssetBundle("", 0, 0);
-
-            yield return null;
-
-            UpdateStateInfo("Prepare To Clean Local Resources ...");
-            yield return new WaitForSeconds(1.0f);
-
-            // Download Resource Logic Start:
-            // Step 1: Try To Delete All Local File(PersistentPath) That Need Update. 
-            int cleanedCount = 1;
-            int fileTotalCount = _willDownloadFileInfoList.Count;
-            foreach (SFileInfo oneFileInfo in _willDownloadFileInfoList)
-            {
-                SResourceManager.TryDeleteAssetBundle(oneFileInfo.fileName);
-                UpdateStateInfo(string.Format(
-                    "Clean Local Files({0}/{1}) -> {2}", cleanedCount, fileTotalCount, oneFileInfo.fileName
-                ));
-                _uiPanelUpdate.SetProgressPercent(cleanedCount * 1.0f / fileTotalCount);
-                cleanedCount++;
-                yield return new WaitForSeconds(1.0f);
-            }
-            UpdateStateInfo("Clean All Local Resources ... Success");
-            yield return new WaitForSeconds(1.0f);
-
-            // Step 2: Download Each File One By One And Write It On Right Path.
-            UpdateStateInfo("Prepare To Download Remote Resources ...");
-            float downloadStartTime = UnityEngine.Time.realtimeSinceStartup;
-            float downloadedBytes   = 0.0f;
-            string downloadSpeed    = "";
-            foreach (SFileInfo oneFileInfo in _willDownloadFileInfoList)
-            {
-                float baseDownloadedBytes = downloadedBytes;
-                string platformName = SPlatformInfo.GetBuildPlatformName();
-                string downloadLink = SFrameworkDef.resourceVersionUrlBase + platformName + "/" + oneFileInfo.fileName;
-                UnityEngine.Networking.UnityWebRequest resDownloadRequest = 
-                    // UnityEngine.Networking.UnityWebRequest.GetAssetBundle(downloadLink, (uint)remoteResVersion.version, 0);
-                    UnityEngine.Networking.UnityWebRequest.Get(downloadLink);
-
-                float downloadPercent = 0.0f;
-                _uiPanelUpdate.SetProgressPercent(downloadPercent);
-                resDownloadRequest.SendWebRequest();
-                while (!resDownloadRequest.isDone)
-                {
-                    downloadPercent = resDownloadRequest.downloadProgress * 100.0f;
-                    if (downloadPercent < 0) downloadPercent = 0;
-                    System.Math.Round(downloadPercent, 2);
-                    float fileDownloadBytes = baseDownloadedBytes + resDownloadRequest.downloadedBytes;
-                    downloadSpeed = SToolFunction.GetDownloadSpeed(fileDownloadBytes, UnityEngine.Time.realtimeSinceStartup - downloadStartTime);
-
-                    UpdateStateInfo(string.Format("Downloading: {0} From {1} \nPercent: {2} Speed:{3}", 
-                        oneFileInfo.fileName, downloadLink, downloadPercent, downloadSpeed
-                    ));
-                    _uiPanelUpdate.SetProgressPercent(downloadPercent);
-                    yield return null;
-                }
-                _uiPanelUpdate.SetProgressPercent(1.0f);
-
-                downloadedBytes += resDownloadRequest.downloadedBytes;
-                downloadSpeed = SToolFunction.GetDownloadSpeed(downloadedBytes, UnityEngine.Time.realtimeSinceStartup - downloadStartTime);
-                UpdateStateInfo(string.Format("Downloading: {0} \nPercent: {1} Speed:{2} Success", oneFileInfo.fileName, downloadPercent, downloadSpeed));
-                yield return new WaitForSeconds(1.0f);
-
-                SResourceManager.SaveAssetBundle(oneFileInfo.fileName, resDownloadRequest.downloadHandler.data);
-                UpdateStateInfo(string.Format("Download And Save {0} Success", oneFileInfo.fileName));
-                yield return new WaitForSeconds(1.0f);
-            }
-            downloadSpeed = SToolFunction.GetDownloadSpeed(downloadedBytes, UnityEngine.Time.realtimeSinceStartup - downloadStartTime);
-            UpdateStateInfo("All Remote Resource Download Compelete ... Speed:" + downloadSpeed);
-
-            // Step 3: Try Write version.json(Remote Version) To PersistentPath.
-            SResourceManager.SaveRemoteVersion(_remoteResVersion);
-
-            // Step 4: Change currentState And Call TryUpdate().
-            UpdateStateInfo("All Files Download Finish ...");
-            yield return new WaitForSeconds(1.0f);
-            _currentState = Update_State.usFinish;
-            TryUpdate();
-        }
-
-        IEnumerator TryFinishLogic()
-        {
-            // Step 4: Try To Switch Scene To Start.unity.
-            yield return null;
-
-            UpdateStateInfo("All Data Updated ... Success");
-            yield return new WaitForSeconds(1.0f);
-
-            yield return new WaitForSeconds(1.0f);
-
-            SResourceManager.LoadResource("scenes/start.unity");
-            UnityEngine.SceneManagement.SceneManager.LoadScene("Start");
-        }
-
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/Module/SUpdateManager.cs.meta

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

+ 0 - 20
LuaDemo/Assets/SFramework/Module/SVersionInfo.cs

@@ -1,20 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace SFramework
-{
-    public class SFileInfo
-    {
-        public string fileName { get; set; }
-        public string hashInfo { get; set; }
-        public int fileSize { get;set; }
-    }
-
-    public class SVersionInfo
-    {
-        public int version { get; set; }
-        public int fileCount { get; set; }
-        public List<SFileInfo> fileInfo { get; set; }
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/Module/SVersionInfo.cs.meta

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

+ 0 - 35
LuaDemo/Assets/SFramework/SFrameworkDef.cs

@@ -1,35 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-
-
-namespace SFramework
-{
-    public class SFrameworkDef
-    {
-        // Editor
-        public const string ResourceDir = "BundleResource";
-        public const string AssetsBundleExtName = ".s";
-        public const string AssetsBundleProductDir = "Product/Bundles";
-        public const string VersionFileName = "version.json";
-
-        // ResourceManager
-        // This is the Update Manager Flag.
-        public const bool isEnableHotfix = true;
-        //public const bool isEnableHotfix = true;
-        public const bool isLoadAssetsBundleOnEditor = false;
-        //public const bool isLoadAssetsBundleOnEditor = true;
-
-        // UpdateManager
-        public const int httpRequestTimeoutTime = 3;
-        // Client Request Hotfix Lua Before GameUpdate Every Times.
-        // So We Should Put The Hotfix Lua On GameServer.
-        //public const string hotfixLuaUrl = "http://192.168.2.125:21000/files/hotfix.lua";
-        //public const string hotfixLuaUrl = "http://127.0.0.1:21000/files/hotfix.lua";
-        public const string hotfixLuaUrl = "http://192.168.1.135:80/hotfix.lua";
-        // We should put download server on non-game server like CDN in production mode.
-        //public const string resourceVersionUrlBase = "http://192.168.2.125:21000/files/Bundles/";
-        //public const string resourceVersionUrlBase = "http://127.0.0.1:21000/files/Bundles/";
-        public const string resourceVersionUrlBase = "http://192.168.1.135:80/Bundles/";
-        public const string resourceVersionName = "version.json";
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/SFrameworkDef.cs.meta

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

BIN
LuaDemo/Assets/SFramework/SFrameworkE.dll


+ 86 - 0
LuaDemo/Assets/SFramework/SFrameworkE.dll.meta

@@ -0,0 +1,86 @@
+fileFormatVersion: 2
+guid: 8e1c8ec7c441bb34fbfd5efa069d6245
+PluginImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  iconMap: {}
+  executionOrder: {}
+  defineConstraints: []
+  isPreloaded: 0
+  isOverridable: 0
+  isExplicitlyReferenced: 0
+  validateReferences: 1
+  platformData:
+  - first:
+      : Any
+    second:
+      enabled: 0
+      settings:
+        Exclude Android: 1
+        Exclude Editor: 0
+        Exclude Linux64: 1
+        Exclude OSXUniversal: 1
+        Exclude Win: 1
+        Exclude Win64: 1
+        Exclude iOS: 1
+  - first:
+      Android: Android
+    second:
+      enabled: 0
+      settings:
+        CPU: ARMv7
+  - first:
+      Any: 
+    second:
+      enabled: 0
+      settings: {}
+  - first:
+      Editor: Editor
+    second:
+      enabled: 1
+      settings:
+        CPU: AnyCPU
+        DefaultValueInitialized: true
+        OS: AnyOS
+  - first:
+      Standalone: Linux64
+    second:
+      enabled: 0
+      settings:
+        CPU: None
+  - first:
+      Standalone: OSXUniversal
+    second:
+      enabled: 0
+      settings:
+        CPU: None
+  - first:
+      Standalone: Win
+    second:
+      enabled: 0
+      settings:
+        CPU: None
+  - first:
+      Standalone: Win64
+    second:
+      enabled: 0
+      settings:
+        CPU: None
+  - first:
+      Windows Store Apps: WindowsStoreApps
+    second:
+      enabled: 0
+      settings:
+        CPU: AnyCPU
+  - first:
+      iPhone: iOS
+    second:
+      enabled: 0
+      settings:
+        AddToEmbeddedBinaries: false
+        CPU: AnyCPU
+        CompileFlags: 
+        FrameworkDependencies: 
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
LuaDemo/Assets/SFramework/SFrameworkR.dll


+ 33 - 0
LuaDemo/Assets/SFramework/SFrameworkR.dll.meta

@@ -0,0 +1,33 @@
+fileFormatVersion: 2
+guid: 2b2c20f7016d83342b145a2bc100bf40
+PluginImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  iconMap: {}
+  executionOrder: {}
+  defineConstraints: []
+  isPreloaded: 0
+  isOverridable: 0
+  isExplicitlyReferenced: 0
+  validateReferences: 1
+  platformData:
+  - first:
+      Any: 
+    second:
+      enabled: 1
+      settings: {}
+  - first:
+      Editor: Editor
+    second:
+      enabled: 0
+      settings:
+        DefaultValueInitialized: true
+  - first:
+      Windows Store Apps: WindowsStoreApps
+    second:
+      enabled: 0
+      settings:
+        CPU: AnyCPU
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 0 - 8
LuaDemo/Assets/SFramework/Tools.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: df39a1bfe919c49468c2894593225b64
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 109
LuaDemo/Assets/SFramework/Tools/SPlatformInfo.cs

@@ -1,109 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace SFramework
-{
-    public class SPlatformInfo
-    {
-        private static string _unityEditorEditorUserBuildSettingsActiveBuildTarget;
-        /// <summary>
-        /// UnityEditor.EditorUserBuildSettings.activeBuildTarget, Can Run in any platform~
-        /// </summary>
-        public static string UnityEditor_EditorUserBuildSettings_activeBuildTarget
-        {
-            get
-            {
-                if (Application.isPlaying && !string.IsNullOrEmpty(_unityEditorEditorUserBuildSettingsActiveBuildTarget))
-                {
-                    return _unityEditorEditorUserBuildSettingsActiveBuildTarget;
-                }
-                var assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
-                foreach (var a in assemblies)
-                {
-                    if (a.GetName().Name == "UnityEditor")
-                    {
-                        System.Type lockType = a.GetType("UnityEditor.EditorUserBuildSettings");
-                        //var retObj = lockType.GetMethod(staticMethodName,
-                        //    System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public)
-                        //    .Invoke(null, args);
-                        //return retObj;
-                        var p = lockType.GetProperty("activeBuildTarget");
-
-                        var em = p.GetGetMethod().Invoke(null, new object[] { }).ToString();
-                        _unityEditorEditorUserBuildSettingsActiveBuildTarget = em;
-                        return em;
-                    }
-                }
-                return null;
-            }
-        }
-
-        /// <summary>
-        /// Different platform's assetBundles is incompatible.
-        /// CosmosEngine put different platform's assetBundles in different folder.
-        /// Here, get Platform name that represent the AssetBundles Folder.
-        /// </summary>
-        /// <returns>Platform folder Name</returns>
-        public static string GetBuildPlatformName()
-        {
-            string buildPlatformName = "Windows"; // default
-
-            if (Application.isEditor)
-            {
-                var buildTarget = UnityEditor_EditorUserBuildSettings_activeBuildTarget;
-                //UnityEditor.EditorUserBuildSettings.activeBuildTarget;
-                switch (buildTarget)
-                {
-                    case "StandaloneOSX":
-                    case "StandaloneOSXIntel":
-                    case "StandaloneOSXIntel64":
-                    case "StandaloneOSXUniversal":
-                        buildPlatformName = "MacOS";
-                        break;
-                    case "StandaloneWindows": // UnityEditor.BuildTarget.StandaloneWindows:
-                    case "StandaloneWindows64": // UnityEditor.BuildTarget.StandaloneWindows64:
-                        buildPlatformName = "Windows";
-                        break;
-                    case "Android": // UnityEditor.BuildTarget.Android:
-                        buildPlatformName = "Android";
-                        break;
-                    case "iPhone": // UnityEditor.BuildTarget.iPhone:
-                    case "iOS":
-                        buildPlatformName = "iOS";
-                        break;
-                    default:
-                        Debug.Assert(false);
-                        break;
-                }
-            }
-            else
-            {
-                switch (Application.platform)
-                {
-                    case RuntimePlatform.OSXPlayer:
-                        buildPlatformName = "MacOS";
-                        break;
-                    case RuntimePlatform.Android:
-                        buildPlatformName = "Android";
-                        break;
-                    case RuntimePlatform.IPhonePlayer:
-                        buildPlatformName = "iOS";
-                        break;
-                    case RuntimePlatform.WindowsPlayer:
-#if !UNITY_5_4_OR_NEWER
-                    case RuntimePlatform.WindowsWebPlayer:
-#endif
-                        buildPlatformName = "Windows";
-                        break;
-                    default:
-                        Debug.Assert(false);
-                        break;
-                }
-            }
-
-            return buildPlatformName;
-        }
-        
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/Tools/SPlatformInfo.cs.meta

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

+ 0 - 62
LuaDemo/Assets/SFramework/Tools/SToolFunction.cs

@@ -1,62 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace SFramework
-{
-    public class SToolFunction
-    {
-        public static int GetFileSize(string fileFullPath)
-        {
-            System.IO.FileInfo oneFileInfo = new System.IO.FileInfo(fileFullPath);
-            return (int)oneFileInfo.Length;
-        }
-
-        public static string GetAssetBundleFullPath(string abFullNameWithPath)
-        {
-            string[] nameInfo = abFullNameWithPath.Split('/');
-            string realABName = nameInfo[nameInfo.Length - 1];
-            string fullPath = abFullNameWithPath.Substring(0, abFullNameWithPath.Length - realABName.Length);
-            return fullPath;
-        }
-
-        public static string GetDownloadSpeed(float alreadyDownloadBytes, float downloadTime)
-        {
-            float downloadSpeed = alreadyDownloadBytes / downloadTime; // Bytes Per Second.
-            string extName = "B/s";
-
-            if (System.Math.Floor(downloadSpeed / 1024) > 0)
-            {
-                downloadSpeed = downloadSpeed / 1024; // KB/s
-                extName = "KB/s";
-            }
-
-            if (System.Math.Floor(downloadSpeed / 1024) > 0)
-            {
-                downloadSpeed = downloadSpeed / 1024; //MB/s
-                extName = "MB/s";
-            }
-
-            downloadSpeed = (float)System.Math.Round(downloadSpeed, 2);
-            string finalSpeed = downloadSpeed.ToString() + " " + extName;
-            return finalSpeed;
-        }
-
-        public static void MakeSurePathExisted(string path)
-        {
-            if (System.IO.Directory.Exists(path))
-                return;
-
-            System.IO.Directory.CreateDirectory(path);
-        }
-
-        public static SFileInfo CreateFileInfo(string fileName, string fileFullPathWithName)
-        {
-            SFileInfo fileInfo = new SFileInfo();
-            fileInfo.fileName = fileName;
-            fileInfo.hashInfo = fileName.GetHashCode().ToString();
-            fileInfo.fileSize = SToolFunction.GetFileSize(fileFullPathWithName);
-            return fileInfo;
-        }
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/Tools/SToolFunction.cs.meta

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

+ 0 - 8
LuaDemo/Assets/SFramework/UI.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 95d634dbb2e2f2446abf0f2731a12a95
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 79
LuaDemo/Assets/SFramework/UI/SUIObjectBase.cs

@@ -1,79 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace SFramework
-{
-    public class SUIObjectBase : MonoBehaviour
-    {
-        public GameObject _rootPanel;
-        public delegate void ClickDelegate(GameObject buttonObject);
-
-        void Awake()
-        {
-            UI_Awake();
-        }
-
-        void Start()
-        {
-            UI_Start();
-
-            UI_RegisterEvent();
-            UI_RefreshInfo();
-            UI_BindTouchEvent();
-        }
-
-        void Update()
-        {
-            UI_Update();
-        }
-
-        void OnDestroy()
-        {
-            UI_UnregisterEvent();
-
-            UI_OnDestroy();
-        }
-
-        public GameObject GetSubUI(string subUIName)
-        {
-            Debug.Assert(_rootPanel != null);
-
-            Transform subUITransform = _rootPanel.transform.Find(subUIName);
-            Debug.Assert(subUITransform != null, string.Format("GetSubUI Failed For Name : {0}", subUIName));
-            return subUITransform.gameObject;
-        }
-
-        public void BindButtonClick(string gameObjectPathName, ClickDelegate clickFunc)
-        {
-            Debug.Assert(_rootPanel != null);
-
-            GameObject buttonObject = _rootPanel.transform.Find(gameObjectPathName).gameObject as GameObject;
-            UnityEngine.UI.Button buttonControl = buttonObject.GetComponent<UnityEngine.UI.Button>();
-            buttonControl.onClick.AddListener(delegate ()
-            {
-                clickFunc(buttonObject);
-            });
-        }
-
-        public void BindButtonClick(GameObject buttonObject, ClickDelegate clickFunc)
-        {
-            Debug.Assert(_rootPanel != null);
-
-            UnityEngine.UI.Button buttonControl = buttonObject.GetComponent<UnityEngine.UI.Button>();
-            buttonControl.onClick.AddListener(delegate ()
-            {
-                clickFunc(buttonObject);
-            });
-        }
-
-        public virtual void UI_Awake() { }
-        public virtual void UI_Start() { }
-        public virtual void UI_Update() { }
-        public virtual void UI_OnDestroy() { }
-        public virtual void UI_RegisterEvent() { }
-        public virtual void UI_UnregisterEvent() { }
-        public virtual void UI_RefreshInfo() { }
-        public virtual void UI_BindTouchEvent() { }
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/UI/SUIObjectBase.cs.meta

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

+ 0 - 82
LuaDemo/Assets/SFramework/UI/SUIPanelTips.cs

@@ -1,82 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace SFramework
-{
-    public class SUIPanelTips : SUIObjectBase
-    {
-        private GameObject _textTitle;
-        private GameObject _textInfo;
-        System.Action _clickYesCallBack;
-        System.Action _clickNoCallBack;
-
-        public override void UI_Awake()
-        {
-            Debug.Log("SUIPanelTips -> Awake()");
-
-            GameObject rootCanvas = GameObject.Find("Canvas_Update(Clone)");
-            Debug.Assert(rootCanvas != null);
-
-            _rootPanel = rootCanvas.transform.Find("Panel_Tips").gameObject;
-            Debug.Assert(_rootPanel != null);
-
-            _textTitle = GetSubUI("Text_Title");
-            _textInfo = GetSubUI("Text_Info");
-
-            _rootPanel.SetActive(false);
-        }
-
-        public override void UI_Start()
-        {
-        }
-
-        public override void UI_RefreshInfo()
-        {
-            _textTitle.GetComponent<UnityEngine.UI.Text>().text = "UpdateTips";
-            _textInfo.GetComponent<UnityEngine.UI.Text>().text = "Prepare For Update.";
-        }
-
-        public override void UI_BindTouchEvent()
-        {
-            BindButtonClick("Button_Yes", onClickButtonYes);
-            BindButtonClick("Button_No", onClickButtonNo);
-        }
-
-        private void onClickButtonYes(GameObject buttonObject)
-        {
-            Debug.Log("SUIPanelTips -> onClickButtonYes");
-
-            _rootPanel.SetActive(false);
-
-            if (_clickYesCallBack != null)
-            {
-                _clickYesCallBack();
-                _clickYesCallBack = null;
-            }
-        }
-
-        private void onClickButtonNo(GameObject buttonObject)
-        {
-            Debug.Log("SUIPanelTips -> onClickButtonNo");
-
-            _rootPanel.SetActive(false);
-
-            if (_clickNoCallBack != null)
-            {
-                _clickNoCallBack();
-                _clickNoCallBack = null;
-            }
-        }
-
-        public void ShowTips(string tipsTitle, string tipsInfo, System.Action yesAction, System.Action noAction)
-        {
-            _rootPanel.SetActive(true);
-            _textTitle.GetComponent<UnityEngine.UI.Text>().text = tipsTitle;
-            _textInfo.GetComponent<UnityEngine.UI.Text>().text = tipsInfo;
-            _clickYesCallBack = yesAction;
-            _clickNoCallBack = noAction;
-        }
-    }
-}
-

+ 0 - 11
LuaDemo/Assets/SFramework/UI/SUIPanelTips.cs.meta

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

+ 0 - 46
LuaDemo/Assets/SFramework/UI/SUIPanelUpdate.cs

@@ -1,46 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace SFramework
-{
-    public class SUIPanelUpdate : SUIObjectBase 
-    {
-        private GameObject _textInfo;
-        private GameObject _imageProgress;
-        public override void UI_Awake()
-        {
-            Debug.Log("SUIPanelUpdate -> Awake()");
-
-            GameObject rootCanvas = GameObject.Find("Canvas_Update(Clone)");
-            Debug.Assert(rootCanvas != null);
-
-            _rootPanel = rootCanvas.transform.Find("Panel_Update").gameObject;
-            Debug.Assert(_rootPanel != null);
-
-            _textInfo = _rootPanel.transform.Find("Text_Info").gameObject;
-            Debug.Assert(_textInfo != null);
-
-            _imageProgress = _rootPanel.transform.Find("Image_Progress").gameObject;
-            Debug.Assert(_imageProgress != null);
-        }
-
-        public override void UI_Start()
-        {
-            Debug.Log("SUIPanelUpdate -> Start()");
-        }
-
-        public void SetProgressPercent(float percent)
-        {
-            if (percent <= 0.0f) percent = 0.0f;
-            if (percent >= 1.0f) percent = 1.0f;
-
-            _imageProgress.GetComponent<UnityEngine.UI.Image>().fillAmount = percent;
-        }
-
-        public void SetUpdateInfo(string information)
-        {
-            _textInfo.GetComponent<UnityEngine.UI.Text>().text = information;
-        }
-    }
-}

+ 0 - 11
LuaDemo/Assets/SFramework/UI/SUIPanelUpdate.cs.meta

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

+ 1 - 1
LuaDemo/Assets/SFramework/Editor.meta → LuaDemo/Assets/SFramework/XLua.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 28c75bed8e2e802448b615d46a17eedd
+guid: 0de4aa53ddbb9af418c20a9bfe02d638
 folderAsset: yes
 DefaultImporter:
   externalObjects: {}

+ 33 - 0
LuaDemo/Assets/SFramework/XLua/SCoroutineRunner.cs

@@ -0,0 +1,33 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace SFramework
+{
+    public class SCoroutineRunner : MonoBehaviour
+    {
+    }
+
+// now don't need config the waitforseconds and other functions.
+// Modify by sunxun 20200725
+/*
+    public static class CoroutineConfig
+    {
+        [LuaCallCSharp]
+        public static List<Type> LuaCallCSharp
+        {
+            get
+            {
+                return new List<Type>()
+            {
+                //typeof(WaitForSeconds),
+                // Modify On 20200707 For Warning.
+#pragma warning disable 0618
+                    typeof(WWW)
+#pragma warning restore 0618
+            };
+            }
+        }
+    }
+*/
+}

+ 1 - 1
LuaDemo/Assets/SFramework/Module/SCoroutineRunner.cs.meta → LuaDemo/Assets/SFramework/XLua/SCoroutineRunner.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 94f45a7fd7781cb4fbd64fb3de7ccb05
+guid: d23f725c8a1201a4a9da4eae1b804b0a
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 0 - 0
LuaDemo/Assets/SFramework/Module/SLuaBehaviour.cs → LuaDemo/Assets/SFramework/XLua/SLuaBehaviour.cs


+ 1 - 1
LuaDemo/Assets/SFramework/Module/SLuaBehaviour.cs.meta → LuaDemo/Assets/SFramework/XLua/SLuaBehaviour.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 691c88b09913a424db3097d434234ba1
+guid: f4de7cbffe175ab498b32a52e80cef35
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 225 - 0
LuaDemo/Assets/SFramework/XLua/SLuaComponent.cs

@@ -0,0 +1,225 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace SFramework
+{
+    [XLua.LuaCallCSharp]
+    public class SLuaComponent : MonoBehaviour
+    {
+        public TextAsset luaScript;
+        private XLua.LuaTable _luaTable;
+
+        private XLua.LuaFunction _luaAwake;
+        private XLua.LuaFunction _luaStart;
+        private XLua.LuaFunction _luaUpdate;
+        private XLua.LuaFunction _luaFixedUpdate;
+        private XLua.LuaFunction _luaLateUpdate;
+        private XLua.LuaFunction _luaOnDestroy;
+        private XLua.LuaFunction _luaOnEnable;
+        private XLua.LuaFunction _luaOnDisable;
+        private XLua.LuaFunction _luaOnApplicationFocus;
+        private XLua.LuaFunction _luaOnApplicationPause;
+        private XLua.LuaFunction _luaOnApplicationQuit;
+
+        internal static XLua.LuaEnv luaEnv = SLuaEnv.Instance;
+        internal static float lastGCTime = 0;
+        internal const float GCInterval = 1;
+
+        public static void Add(GameObject targetGameObject, XLua.LuaTable luaTable, string luaFileName)
+        {
+            SLuaComponent luaComponent = targetGameObject.AddComponent<SLuaComponent>();
+            luaComponent.luaScript = new UnityEngine.TextAsset("print('The lua script add dynamic.')");
+            luaComponent.luaScript.name = luaFileName;
+            if (null == luaFileName) { Debug.LogWarning("SLuaComponent Add Script Dynamic But Do Not Set Script Name!"); }
+            luaComponent.SetLuaTable(luaTable);
+        }
+
+        public void SetLuaTable(XLua.LuaTable luaTable)
+        {
+            Debug.Assert(null != luaTable, "SLuaComponent SetLuaTable Failed luaTable == null");
+            Debug.Assert(null == _luaTable, "SLuaComponent SetLuaTable Failed _luaTable != null");
+
+            _luaTable = luaTable;
+            InitLuaFunction();
+
+            // Try Call Awake Function();
+            if (null != _luaAwake)
+                _luaAwake.Call(gameObject);
+        }
+
+        private void InitLuaFunction()
+        {
+            if (null == _luaTable)
+            {
+                Debug.LogError("SLuaComponent InitLuaFunction Failed Because _luaTable == null");
+                return;
+            }
+
+            _luaAwake = _luaTable.Get<XLua.LuaFunction>("Awake");
+            _luaStart = _luaTable.Get<XLua.LuaFunction>("Start");
+            _luaUpdate = _luaTable.Get<XLua.LuaFunction>("Update");
+            _luaFixedUpdate = _luaTable.Get<XLua.LuaFunction>("FixedUpdate");
+            _luaLateUpdate = _luaTable.Get<XLua.LuaFunction>("LateUpdate");
+            _luaOnDestroy = _luaTable.Get<XLua.LuaFunction>("OnDestroy");
+            _luaOnEnable = _luaTable.Get<XLua.LuaFunction>("OnEnable");
+            _luaOnDisable = _luaTable.Get<XLua.LuaFunction>("OnDisable");
+            _luaOnApplicationFocus = _luaTable.Get<XLua.LuaFunction>("OnApplicationFocus");
+            _luaOnApplicationPause = _luaTable.Get<XLua.LuaFunction>("OnApplicationPause");
+            _luaOnApplicationQuit = _luaTable.Get<XLua.LuaFunction>("OnApplicationQuit");
+        }
+
+        private void Awake()
+        {
+            if (null == luaScript)
+                return;
+
+            System.Object[] retValues = luaEnv.DoString(luaScript.text, "LuaComponent");
+            if (null == retValues || retValues.Length != 1)
+            {
+                Debug.LogWarning("SLuaCompnent Need A Lua That Return A LuaTable.");
+                Debug.LogError("SLuaComponent Load LuaScript Failed When Awake, ScriptName: " + luaScript.name);
+                return;
+            }
+
+            _luaTable = retValues[0] as XLua.LuaTable;
+
+            InitLuaFunction();
+
+            if (null != _luaAwake)
+                _luaAwake.Call(gameObject);
+        }
+
+        private void Start()
+        {
+            if (null != _luaStart)
+                _luaStart.Call(gameObject);
+        }
+
+        private void Update()
+        {
+            if (Time.time - SLuaComponent.lastGCTime > GCInterval)
+            {
+                luaEnv.Tick();
+                SLuaComponent.lastGCTime = Time.time;
+            }
+
+            if (null != _luaUpdate)
+                _luaUpdate.Call();
+        }
+
+        private void FixedUpdate()
+        {
+            if (null != _luaFixedUpdate)
+                _luaFixedUpdate.Call();
+        }
+
+        private void LateUpdate()
+        {
+            if (null != _luaLateUpdate)
+                _luaLateUpdate.Call();
+        }
+
+        private void OnDestroy()
+        {
+            if (null != _luaOnDestroy)
+                _luaOnDestroy.Call();
+
+            if (null != _luaAwake)
+            {
+                _luaAwake.Dispose();
+                _luaAwake = null;
+            }
+            
+            if (null != _luaStart)
+            {
+                _luaStart.Dispose();
+                _luaStart = null;
+            }
+
+            if (null != _luaUpdate)
+            {
+                _luaUpdate.Dispose();
+                _luaUpdate = null;
+            }
+
+            if (null != _luaFixedUpdate)
+            {
+                _luaFixedUpdate.Dispose();
+                _luaFixedUpdate = null;
+            }
+
+            if (null != _luaLateUpdate)
+            {
+                _luaLateUpdate.Dispose();
+                _luaLateUpdate = null;
+            }
+
+            if (null != _luaOnDestroy)
+            {
+                _luaOnDestroy.Dispose();
+                _luaOnDestroy = null;  
+            }
+
+            if (null != _luaOnEnable)
+            {
+                _luaOnEnable.Dispose();
+                _luaOnEnable = null;
+            }
+
+            if (null != _luaOnDisable)
+            {
+                _luaOnDisable.Dispose();
+                _luaOnDisable = null;
+            }
+
+            if (null != _luaOnApplicationFocus)
+            {
+                _luaOnApplicationFocus.Dispose();
+                _luaOnApplicationFocus = null;
+            }
+
+            if (null != _luaOnApplicationPause)
+            {
+                _luaOnApplicationPause.Dispose();
+                _luaOnApplicationPause = null;
+            }
+
+            if (null != _luaOnApplicationQuit)
+            {
+                _luaOnApplicationQuit.Dispose();
+                _luaOnApplicationQuit = null;  
+            }
+        }
+
+        private void OnEnable()
+        {
+            if (null != _luaOnEnable)
+                _luaOnEnable.Call();
+        }
+
+        private void OnDisable()
+        {
+            if (null != _luaOnDisable)
+                _luaOnDisable.Call();
+        }
+
+        private void OnApplicationFocus(bool focus)
+        {
+            if (null != _luaOnApplicationFocus)
+                _luaOnApplicationFocus.Call(focus);
+        }
+
+        private void OnApplicationPause(bool pause)
+        {
+            if (null != _luaOnApplicationPause)
+                _luaOnApplicationPause.Call(pause);
+        }
+
+        private void OnApplicationQuit()
+        {
+            if (null != _luaOnApplicationQuit)
+                _luaOnApplicationQuit.Call();
+        }
+    }
+}

+ 1 - 1
LuaDemo/Assets/SFramework/Module/SLuaComponent.cs.meta → LuaDemo/Assets/SFramework/XLua/SLuaComponent.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 97bfc2f13c0d97d45926a0c19e592a55
+guid: 98b2aa5f518408d43a00bae5ad9a12de
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 14 - 1
LuaDemo/Assets/SFramework/Module/SLuaEnv.cs → LuaDemo/Assets/SFramework/XLua/SLuaEnv.cs

@@ -27,13 +27,26 @@ namespace SFramework
             }
         }
 
+        private static TextAsset GetTextAsset(string fullLuaScriptPath)
+        {
+#if UNITY_EDITOR
+            string resFinalPath = "Assets/" + SFrameworkDefR.ResourceDir + "/" + fullLuaScriptPath;
+            TextAsset luaTextAssets = UnityEditor.AssetDatabase.LoadAssetAtPath(resFinalPath, typeof(UnityEngine.Object)) as TextAsset;
+#else
+            TextAsset luaTextAssets = SFramework.SResourceManagerR.LoadResource(fullLuaScriptPath) as TextAsset;
+#endif
+
+            return luaTextAssets;
+        }
+
         private static byte[] CustomLoader(ref string luaScriptName)
         {
             //Debug.Log("CustomLoader Work Once. ---> " + luaScriptName);
             string fullLuaScriptPath = "LuaScripts/" + luaScriptName + ".txt";
             //Debug.Log("FullLuaScriptPath -> " + fullLuaScriptPath);
 
-            TextAsset luaTextAssets = SFramework.SResourceManager.LoadResource(fullLuaScriptPath) as TextAsset;
+            //TextAsset luaTextAssets = SFramework.SResourceManagerR.LoadResource(fullLuaScriptPath) as TextAsset;
+            TextAsset luaTextAssets = GetTextAsset(fullLuaScriptPath);
             //Debug.Log("luaTextAssets -> " + luaTextAssets.text);
             Debug.Log(string.Format(
                 "SFramework.SLuaEnv.CustomLoader -> luaScriptName: {0} \nluaTextAssets: {2}",

+ 1 - 1
LuaDemo/Assets/SFramework/Module/SLuaEnv.cs.meta → LuaDemo/Assets/SFramework/XLua/SLuaEnv.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 0fe0c4c369a9c7b4e92f38db0b176418
+guid: d06b3a07e2c08cd498f269669512538f
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2