fix :1、先删除H5代码

This commit is contained in:
2026-07-07 20:03:00 +08:00
parent 03b3ad4364
commit 3fd1e034c9
36 changed files with 33895 additions and 34364 deletions
+1
View File
@@ -16,6 +16,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AStringExtensions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F79472e60dafb4701a62b3edca7f7c89928a00_003Fbc_003F2e2380bf_003FStringExtensions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASystem_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F3ea01e77be99618395f448b16bd7cc2bd4248bd9e5d8474964b2d97f39c5d74_003FSystem_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F1071a2cb0cb3433aae80a793c277a04846ac00_003Fb8_003Fdebf208b_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AType_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F1071a2cb0cb3433aae80a793c277a04846ac00_003F62_003Fb6a73001_003FType_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AUni2SDKAutoRefresh_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F79472e60dafb4701a62b3edca7f7c89928a00_003F5c_003Fd7ca2e25_003FUni2SDKAutoRefresh_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AUni2SDKManager_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F79472e60dafb4701a62b3edca7f7c89928a00_003F13_003Fbb0c88a6_003FUni2SDKManager_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AUni2SDKManager_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F8d4b727702d44da88ac054d09f951a8528a00_003F44_003F2fc63fee_003FUni2SDKManager_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
-14
View File
@@ -1,14 +0,0 @@
<linker>
<assembly fullname="Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
<type fullname="UnityEngine.AddressableAssets.Addressables" preserve="all" />
</assembly>
<assembly fullname="Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider" preserve="all" />
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider" preserve="all" />
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider" preserve="all" />
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.SceneProvider" preserve="all" />
</assembly>
<assembly fullname="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="UnityEngine.TextAsset" preserve="all" />
</assembly>
</linker>
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 1c722df2a1f8db54faa3792051d6b555
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -17,5 +17,13 @@ namespace IgnoreOPS
public string des_key;
public string Mode_0;
public string Mode_1;
public string Mode_FR;
public string Mode_DE;
public string Mode_ES;
public string Mode_PT;
public string Mode_JA;
public string Mode_KO;
public string Mode_RU;
public string Mode_ID;
}
}
+43 -8
View File
@@ -396,8 +396,8 @@ namespace ChillConnect
string countryCode = "US";
try
{
countryCode = RegionInfo.CurrentRegion.TwoLetterISORegionName;
Debug.Log("国家代码: " + countryCode); // 例如:US, CN, JP, DE 等
countryCode = Language.getCurrentLanguage();
// Debug.Log("国家代码: " + countryCode); // 例如:US, CN, JP, DE 等
}
catch (System.Exception e)
{
@@ -1670,20 +1670,55 @@ namespace ChillConnect
}
public static string getDesByKey(string key)
{
Debug.Log(JsonConvert.SerializeObject(ConfigSystem.GetConfig<ExchangeDesModel>().DataList));
if (isRDExchangeMode())
var config = ConfigSystem.GetConfig<ExchangeDesModel>();
var data = config.DataList.FirstOrDefault(d => d.des_key == key);
if (data == null)
return "";
// 根据语言动态获取对应的字段值
string property = GetModelByLanguage(data);
if (property == null)
{
string str = ConfigSystem.GetConfig<ExchangeDesModel>().DataList.FirstOrDefault(data => data.des_key == key)?.Mode_1 ?? "";
if (str != "")
// 如果找不到对应语言字段,返回默认的 Mode_1
return data.Mode_1 ?? "";
}
string str = property ?? "";
if (str != "" && isRDExchangeMode())
{
str = str.Replace("<img1>", "<img src='ui://o9974uc5qbo98'/>")
.Replace("<img2>", "<img src='ui://o9974uc5t9w7c3'/>");
}
return str;
}
else
private static string GetModelByLanguage(ExchangeDes vo)
{
return ConfigSystem.GetConfig<ExchangeDesModel>().DataList.FirstOrDefault(data => data.des_key == key)?.Mode_0 ?? "";
var language = Language.getCurrentLanguage();
switch (language)
{
case "fr"://法语
return vo.Mode_FR;
case "de"://德语
return vo.Mode_DE;
case "es"://西班牙语
return vo.Mode_ES;
case "pt"://葡萄牙语
return vo.Mode_PT;
case "ja"://日语
return vo.Mode_JA;
case "ko"://韩语
return vo.Mode_KO;
case "ru"://俄语
return vo.Mode_RU;
case "id"://印尼语
return vo.Mode_ID;
default:
return vo.Mode_1;
}
}
public static bool isRDExchangeMode()
@@ -1,7 +1,6 @@
using DG.Tweening;
using IgnoreOPS;
using SGModule.Net;
using UNSDK;
namespace ChillConnect
{
@@ -129,7 +128,6 @@ namespace ChillConnect
Debug.Log($"open wb normal==={openConfig.normal} url==={openConfig.url}");
SdkConfigMgr.Instance.Open(openConfig.normal, openConfig.url);
SetCameraVisible(false);
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.H5UI_Open);
File diff suppressed because it is too large Load Diff
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8"?><resources><string name="com.crashlytics.android.build_id" translatable="false">7c39fb54-51ba-420b-95e5-23431554d237</string></resources>
<?xml version="1.0" encoding="utf-8"?><resources><string name="com.crashlytics.android.build_id" translatable="false">602f3837-09d2-4b5d-9661-02f63bfad863</string></resources>
Binary file not shown.
@@ -1,32 +0,0 @@
fileFormatVersion: 2
guid: 1486d6522f70f02429e1e7de6ce68bfd
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -22,7 +22,8 @@
"claimed": "Claimed",
"get_card": "GET GIFT CARD",
"saveingpot_get": "You will get the {0} for 90 days",
"saveingpot_claimed": "{0} directly to your gift card"
"saveingpot_claimed": "{0} directly to your gift card",
"use_item": "Use Item"
},
"ja": {
"copy_succeed": "コピー完了",
@@ -47,7 +48,9 @@
"claimed": "受け取り済み",
"get_card": "ギフトカードを取得",
"saveingpot_get": "{0}を90日間獲得できます",
"saveingpot_claimed": "{0}がギフトカードに直接届きます"
"saveingpot_claimed": "{0}がギフトカードに直接届きます",
"use_item": "アイテムを使用する"
},
"ko": {
"copy_succeed": "복사 완료",
@@ -72,7 +75,8 @@
"claimed": "수령 완료",
"get_card": "기프트 카드 받기",
"saveingpot_get": "{0}을 90일간 획득합니다",
"saveingpot_claimed": "{0}이 기프트 카드로 직접 지급됩니다"
"saveingpot_claimed": "{0}이 기프트 카드로 직접 지급됩니다",
"use_item": "아이템 사용하기"
},
"ru": {
"copy_succeed": "Копирование выполнено",
@@ -97,7 +101,8 @@
"claimed": "Забрано",
"get_card": "Получить подарочную карту",
"saveingpot_get": "Вы получите {0} на 90 дней",
"saveingpot_claimed": "{0} сразу поступит на подарочную карту"
"saveingpot_claimed": "{0} сразу поступит на подарочную карту",
"use_item": "Использовать предмет"
},
"id": {
"copy_succeed": "कॉपी सफल",
@@ -122,7 +127,8 @@
"claimed": "दावा किया गया",
"get_card": "उपहार कार्ड प्राप्त करें",
"saveingpot_get": "आपको {0} 90 दिनों के लिए मिलेगा",
"saveingpot_claimed": "{0} सीधे आपके उपहार कार्ड पर मिल जाएगा"
"saveingpot_claimed": "{0} सीधे आपके उपहार कार्ड पर मिल जाएगा",
"use_item": "वस्तु उपयोग करेंं"
},
"pt": {
"copy_succeed": "Cópia realizada com sucesso",
@@ -147,7 +153,8 @@
"claimed": "Resgatado",
"get_card": "OBTER CARTÃO DE PRESENTE",
"saveingpot_get": "Você receberá {0} por 90 dias",
"saveingpot_claimed": "{0} será enviado diretamente para seu cartão de presente"
"saveingpot_claimed": "{0} será enviado diretamente para seu cartão de presente",
"use_item": "Usar item"
},
"de": {
"copy_succeed": "Kopieren erfolgreich",
@@ -172,7 +179,8 @@
"claimed": "Eingelöst",
"get_card": "GESCHENKKARTE ERHALTEN",
"saveingpot_get": "Du erhältst {0} für 90 Tage",
"saveingpot_claimed": "{0} wird direkt auf deine Geschenkkarte gutgeschrieben"
"saveingpot_claimed": "{0} wird direkt auf deine Geschenkkarte gutgeschrieben",
"use_item": "Nutzung des Items"
},
"fr": {
"copy_succeed": "Copie réussie",
@@ -197,7 +205,8 @@
"claimed": "Réclamé",
"get_card": "OBTENIR LA CARTE CADEAU",
"saveingpot_get": "Vous obtiendrez {0} pendant 90 jours",
"saveingpot_claimed": "{0} sera directement versé sur votre carte cadeau"
"saveingpot_claimed": "{0} sera directement versé sur votre carte cadeau",
"use_item": "Utiliser l'objet"
},
"es": {
"copy_succeed": "Copia realizada con éxito",
@@ -222,6 +231,7 @@
"claimed": "Reclamado",
"get_card": "OBTENER TARJETA DE REGALO",
"saveingpot_get": "Recibirás {0} durante 90 días",
"saveingpot_claimed": "{0} se enviará directamente a tu tarjeta de regalo"
"saveingpot_claimed": "{0} se enviará directamente a tu tarjeta de regalo",
"use_item": "Usar objeto"
}
}
+1 -2
View File
@@ -6,14 +6,13 @@ using SGModule.MarkdownKit;
using SGModule.Net;
using SGModule.NetKit;
using UnityEngine;
using UNSDK;
public class ChillConnectRoot : MonoBehaviour
{
public void Awake()
{
#if UNITY_EDITOR || GAME_RELEASE || GAME_RELEASE1
#if UNITY_EDITOR || GAME_RELEASE
GameObject ingameDebugConsole = GameObject.Find("IngameDebugConsole");
if (ingameDebugConsole != null) ingameDebugConsole.SetActive(false);
#endif
@@ -120,7 +120,7 @@ namespace ChillConnect
{
ui.btn_watch.enabled = true;
btnWatch.can.selectedIndex = 0;
btnWatch.text.text = "Use Item";
btnWatch.text.text = Language.GetContent("use_item");
}
}
}
-2
View File
@@ -6,7 +6,6 @@ using FGUI.ZM_H5_15;
using IgnoreOPS;
using SGModule.NetKit;
using UnityEngine;
using UNSDK;
namespace ChillConnect
{
@@ -40,7 +39,6 @@ namespace ChillConnect
protected override void OnClose()
{
SdkConfigMgr.Instance.Close();
GameDispatcher.Instance.Dispatch(GameMsg.StopArrowTouch, true);
GameDispatcher.Instance.Dispatch(GameMsg.showBroadCast);
@@ -158,7 +158,7 @@ namespace ChillConnect
private void InitView()
{
Makeup_2 makeupVo = ConfigSystem.GetConfig<MakeupModel_2>().GetData(makeupTaskData.tableId);
ui.text_ad.text = string.Format(GameHelper.getDesByKey("saving_pot_5"), makeupVo.ADIncrease);
ui.text_ad.text = string.Format(GameHelper.getDesByKey("saving_pot_5"), makeupVo.ADIncrease * GameHelper.GetExchangeRateVo().Multi);
string str = string.Format(GameHelper.getDesByKey("saving_pot_2"), makeupVo.PayIncrease);
ui.text_pay.text = str;
initTop();
+2
View File
@@ -172,6 +172,8 @@ public class SaveingPotHelper
}
public static string getChNumber(float cash)
{
var exchangeRateVo = GameHelper.GetExchangeRateVo();
cash = exchangeRateVo.Multi * cash;
return $"{cash:N}";
}
+1 -1
View File
@@ -57,7 +57,7 @@ public static class Language
lang = "ru";
}
// }
// lang = "pt";
lang = "de";
setCurrentLanguage(lang);
}
+1 -1
View File
@@ -134,7 +134,7 @@ namespace ChillConnect
{
onVideoAdCompleted = onCompleted;
_placement = placement;
#if UNITY_EDITOR
#if UNITY_EDITOR || GAME_RELEASE1
onVideoAdCompleted?.Invoke(true);
#else
TrackKit.SendEvent(Property.adEvent,Property.watch_ad_people);
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 4ebe9c47f185b4746a79a6a509c59f5e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 1a405f67bd764ee4ba3cbb08847007d5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
-30
View File
@@ -1,30 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using Uni2SDK;
namespace UNSDK
{
public class Uni2SdkDemo : MonoBehaviour
{
private void Awake()
{
//初始化sdk时,如果不确定unity中是否填入了包名,你这里最好填写你的包名
SdkConfigMgr.Init("com.your.package.name");
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
}
-11
View File
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 19f42161b9e34bc4fa15dcabf69fe812
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: bd1a17c754b6b374f800265176706eb3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
-65
View File
@@ -1,65 +0,0 @@
using UnityEditor;
using UnityEngine;
namespace UNSDK
{
public class ConfigEditor : EditorWindow
{
private static ConfigEditor _view;
[MenuItem("Tools/CreateConfig")]
public static void ShowWindow()
{
if (_view != null)
{
CloseView();
return;
}
_view = GetWindow<ConfigEditor>();
_view.titleContent = new GUIContent("ConfigEditor");
}
static void CloseView()
{
_view.Close();
_view = null;
}
private void OnGUI()
{
DrawWindow();
EditorUtility.SetDirty(SdkConfigMgr.Instance);
}
private void DrawWindow()
{
TextLabel("Sdk 配置",Color.white);
EditorGUILayout.BeginVertical("frameBox");
SdkConfigMgr.Instance.secret = EditorGUILayout.TextField("Secret", SdkConfigMgr.Instance.secret);
SdkConfigMgr.Instance.host = EditorGUILayout.TextField("Host", SdkConfigMgr.Instance.host);
EditorGUILayout.EndVertical();
TextLabel("Debug Log",Color.white);
EditorGUILayout.BeginVertical("frameBox");
SdkConfigMgr.Instance.isLog = EditorGUILayout.Toggle("IsLog", SdkConfigMgr.Instance.isLog);
EditorGUILayout.EndVertical();
}
private void TextLabel(string content, Color color = new Color())
{
if (color.Equals(Color.clear))
{
color = Color.gray;
}
GUIStyle style = new GUIStyle();
style.contentOffset = new Vector2(8, 0);
style.normal.textColor = color;
style.fontSize = 14;
style.padding = new RectOffset(0, 0, 3, 0);
GUILayout.Label(content, style);
}
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 68fcbeb7d5bbfbb4db4304eb591872db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0729286c16e0bb94f9ec7cbade888be0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
-79
View File
@@ -1,79 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using Newtonsoft.Json;
using Uni2SDK;
using UnityEngine;
using UnityEngine.Serialization;
namespace UNSDK
{
public class SdkConfigMgr : ScriptableObject
{
[FormerlySerializedAs("Secret")] public string secret;
[FormerlySerializedAs("Host")] public string host;
[FormerlySerializedAs("IsLog")] public bool isLog;
public static bool IsInitSuccess = false;
private static SdkConfigMgr _instance;
public static SdkConfigMgr Instance
{
get
{
if (_instance) return _instance;
_instance = AssetTools.GetScriptableObject<SdkConfigMgr>(typeof(SdkConfigMgr).Name, "Assets/Resources", false, false);
return _instance;
}
set => _instance = value;
}
public static void Init(string packageName = "")
{
var package = StringExtensions.IsNullOrWhiteSpace(packageName) ? Application.identifier: packageName;
Uni2SDKManager.Instance.SetPackage("com.wackyllamagame.chaos",package);
Uni2SDKManager.Instance.SetLog(Instance.isLog);
Uni2SDKManager.Instance.Init(Instance.host,Instance.secret, (b, msg) =>
{
IsInitSuccess = b;
Debug.Log($"init SDK bool===={b} WvManager.Instance.Init s==={msg}");
});
}
/// <summary>
/// 关闭有感
/// 必须调用,且在退出有感界界面时调用
/// 调用此方法后,可以将其他游戏界面等显示了
/// </summary>
public void Close()
{
#if !UNITY_EDITOR
Uni2SDKManager.Instance.Close();
#endif
}
/// <summary>
/// 开启有感
/// 开启时:需要将其他游戏界面等隐藏,注意,是隐藏,不是在其界面上再添加一个界面
/// </summary>
public void Open(bool normal = true, string url = "")
{
#if !UNITY_EDITOR
Uni2SDKManager.Instance.Open(0,0,0,156,normal,url);
#endif
}
}
public class SDKOpenConfig
{
[JsonProperty("normal")]
public bool normal;
[JsonProperty("url")]
public string url;
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: fb2c9d85afdd3d34c88a57c51b02fa84
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 1fe3549a90795f54e822612affc22b6d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
-152
View File
@@ -1,152 +0,0 @@

using System;
using System.IO;
using UnityEngine;
#if UNITY_EDITOR
using System.Collections.Generic;
using UnityEditor;
#endif
namespace UNSDK
{
public static class AssetTools
{
/// <summary>
/// Returns a reference to a scriptable object of type T with the given fileName at the relative resourcesPath.
/// <para/> If the asset is not found, one will get created automatically (in the Editor only)
/// </summary>
/// <param name="fileName"></param>
/// <param name="resourcesPath"></param>
/// <param name="saveAssetDatabase"></param>
/// <param name="refreshAssetDatabase"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static T GetScriptableObject<T>(string fileName,
string resourcesPath,
bool saveAssetDatabase,
bool refreshAssetDatabase)
where T : ScriptableObject
{
if (string.IsNullOrEmpty(resourcesPath)) return null;
if (string.IsNullOrEmpty(fileName)) return null;
// ReSharper disable once SuspiciousTypeConversion.Global
// if (!resourcesPath[resourcesPath.Length - 1].Equals(@"\")) resourcesPath += @"\";
// resourcesPath = resourcesPath.Replace(@"\", "/");
resourcesPath = CleanPath(resourcesPath);
var obj = (T)Resources.Load(fileName, typeof(T));
if (obj == null)
{
string simpleResourcesPath = resourcesPath.Replace(resourcesPath.Substring(0, resourcesPath.LastIndexOf("Resources", StringComparison.Ordinal)), "");
simpleResourcesPath = simpleResourcesPath.Replace("Resources", "").Remove(0, 1);
obj = (T)Resources.Load(Path.Combine(simpleResourcesPath, fileName), typeof(T));
}
#if UNITY_EDITOR
if (obj != null) return obj;
if (!Directory.Exists("Assets/Resources"))
{
Directory.CreateDirectory("Assets/Resources");
}
obj = CreateAsset<T>(resourcesPath, fileName, ".asset", saveAssetDatabase, refreshAssetDatabase);
#endif
return obj;
}
public static T GetResource<T>(string resourcesPath, string fileName) where T : ScriptableObject
{
if (string.IsNullOrEmpty(resourcesPath)) return null;
if (string.IsNullOrEmpty(fileName)) return null;
resourcesPath = CleanPath(resourcesPath);
// ReSharper disable once SuspiciousTypeConversion.Global
// if (!resourcesPath[resourcesPath.Length - 1].Equals(@"\")) resourcesPath += @"\";
// resourcesPath = resourcesPath.Replace(@"\", "/");
return (T)Resources.Load(resourcesPath + fileName, typeof(T));
}
public static string CleanPath(string path)
{
// ReSharper disable once SuspiciousTypeConversion.Global
if (!path[path.Length - 1].Equals(@"\")) path += @"\";
path = path.Replace(@"\\", @"\");
path = path.Replace(@"\", "/");
return path;
}
#if UNITY_EDITOR
public static T CreateAsset<T>(string relativePath,
string fileName,
string extension = ".asset",
bool saveAssetDatabase = true,
bool refreshAssetDatabase = true)
where T : ScriptableObject
{
if (string.IsNullOrEmpty(relativePath)) return null;
if (string.IsNullOrEmpty(fileName)) return null;
relativePath = CleanPath(relativePath);
// ReSharper disable once SuspiciousTypeConversion.Global
// if (!relativePath[relativePath.Length - 1].Equals(@"\")) relativePath += @"\";
// relativePath = relativePath.Replace(@"\\", @"\");
var asset = ScriptableObject.CreateInstance<T>();
AssetDatabase.CreateAsset(asset, relativePath + fileName + extension);
EditorUtility.SetDirty(asset);
if (saveAssetDatabase) AssetDatabase.SaveAssets();
if (refreshAssetDatabase) AssetDatabase.Refresh();
return asset;
}
public static List<T> GetAssets<T>() where T : ScriptableObject
{
var list = new List<T>();
string[] guids = AssetDatabase.FindAssets("t:" + typeof(T).Name);
foreach (string guid in guids)
{
var asset = AssetDatabase.LoadAssetAtPath<T>(AssetDatabase.GUIDToAssetPath(guid));
if (asset == null) continue;
list.Add(asset);
}
return list;
}
public static void MoveAssetToTrash(string relativePath, string fileName, bool saveAssetDatabase = true,
bool refreshAssetDatabase = true, bool printDebugMessage = true)
{
if (string.IsNullOrEmpty(relativePath)) return;
if (string.IsNullOrEmpty(fileName)) return;
// ReSharper disable once SuspiciousTypeConversion.Global
// if (!relativePath[relativePath.Length - 1].Equals(@"\")) relativePath += @"\";
relativePath = CleanPath(relativePath);
if (!AssetDatabase.MoveAssetToTrash(relativePath + fileName + ".asset")) return;
if (printDebugMessage) Debug.Log("The " + fileName + ".asset file has been moved to trash.");
if (saveAssetDatabase) AssetDatabase.SaveAssets();
if (refreshAssetDatabase) AssetDatabase.Refresh();
}
public static Texture GetTexture(string filePath, string fileName, string fileExtension = ".png")
{
if (string.IsNullOrEmpty(filePath)) return null;
if (string.IsNullOrEmpty(fileName)) return null;
// ReSharper disable once SuspiciousTypeConversion.Global
// if (!filePath[filePath.Length - 1].Equals(@"\")) filePath += @"\";
filePath = CleanPath(filePath);
return AssetDatabase.LoadAssetAtPath<Texture>(filePath + fileName + fileExtension);
}
public static Texture2D GetTexture2D(string filePath, string fileName, string fileExtension = ".png")
{
if (string.IsNullOrEmpty(filePath)) return null;
if (string.IsNullOrEmpty(fileName)) return null;
// ReSharper disable once SuspiciousTypeConversion.Global
// if (!filePath[filePath.Length - 1].Equals(@"\")) filePath += @"\";
filePath = CleanPath(filePath);
return AssetDatabase.LoadAssetAtPath<Texture2D>(filePath + fileName + fileExtension);
}
#endif
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: dbce9d27e5ed4d74ab0313e576cc3766
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
-33
View File
@@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: 8d96be196b7f1334e97f1e5ef43a6813
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: