SSymbolLinkHelper.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. namespace SFramework.Editor
  6. {
  7. public class SSymbolLinkHelper
  8. {
  9. public static string AssetBundlesLinkPath
  10. {
  11. get
  12. {
  13. // StreamingAssetsPath
  14. //return "Assets/StreamingAssets/" +
  15. // KEngine.AppEngine.GetConfig(KEngineDefaultConfigs.StreamingBundlesFolderName);
  16. // hold asset bundles
  17. return "Assets/StreamingAssets/" + "Bundles";
  18. }
  19. }
  20. public static string GetLinkPath()
  21. {
  22. if (!System.IO.Directory.Exists(AssetBundlesLinkPath))
  23. System.IO.Directory.CreateDirectory(AssetBundlesLinkPath);
  24. return AssetBundlesLinkPath + "/" + SPlatformInfo.GetBuildPlatformName() + "/";
  25. }
  26. public static string GetResourceExportPath()
  27. {
  28. var resourcePath = SAssetsBundleHelper.GetExportPath(EditorUserBuildSettings.activeBuildTarget);
  29. return resourcePath;
  30. }
  31. [MenuItem("SFramework/Symbol Link Resources/Link Builded Resource -> StreamingAssets or Resources")]
  32. public static void SymbolLinkResource()
  33. {
  34. SUnityEditorTools.SUnityEditorTools.DeleteAllLinks(SSymbolLinkHelper.AssetBundlesLinkPath);
  35. var exportPath = GetResourceExportPath();
  36. var linkPath = GetLinkPath();
  37. SUnityEditorTools.SUnityEditorTools.SymbolLinkFolder(exportPath, linkPath);
  38. AssetDatabase.Refresh();
  39. }
  40. [MenuItem("SFramework/Symbol Link Resources/Remove StreamingAssets or Resources links")]
  41. public static void RemoveSymbolLinkResource()
  42. {
  43. SUnityEditorTools.SUnityEditorTools.DeleteAllLinks(SSymbolLinkHelper.AssetBundlesLinkPath);
  44. Debug.Log("Remove " + SSymbolLinkHelper.AssetBundlesLinkPath);
  45. AssetDatabase.DeleteAsset(SSymbolLinkHelper.AssetBundlesLinkPath);
  46. AssetDatabase.Refresh();
  47. }
  48. }
  49. }