modify scripts
This commit is contained in:
@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
namespace WordsToolkit.Scripts.Editor
|
||||
{
|
||||
public class CustomModelPostProcessor : AssetPostprocessor
|
||||
{
|
||||
private static readonly string SOURCE_PATH = "Assets/WordsToolkit/model/custom";
|
||||
private static readonly string TARGET_PATH = "Assets/StreamingAssets/WordConnectGameToolkit/model/custom";
|
||||
|
||||
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
|
||||
{
|
||||
bool hasCustomModelChanges = false;
|
||||
|
||||
// Check imported assets
|
||||
foreach (string assetPath in importedAssets)
|
||||
{
|
||||
if (IsCustomModelFile(assetPath))
|
||||
{
|
||||
hasCustomModelChanges = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check moved assets
|
||||
if (!hasCustomModelChanges)
|
||||
{
|
||||
foreach (string assetPath in movedAssets)
|
||||
{
|
||||
if (IsCustomModelFile(assetPath))
|
||||
{
|
||||
hasCustomModelChanges = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasCustomModelChanges)
|
||||
{
|
||||
CopyCustomModelsToStreamingAssets();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsCustomModelFile(string assetPath)
|
||||
{
|
||||
return assetPath.StartsWith(SOURCE_PATH) &&
|
||||
(assetPath.EndsWith(".bin") || assetPath.EndsWith(".json") || assetPath.EndsWith(".txt"));
|
||||
}
|
||||
|
||||
private static void CopyCustomModelsToStreamingAssets()
|
||||
{
|
||||
if (!Directory.Exists(SOURCE_PATH))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Create target directory
|
||||
Directory.CreateDirectory(TARGET_PATH);
|
||||
|
||||
// Get all custom model files
|
||||
string[] files = Directory.GetFiles(SOURCE_PATH, "*", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string sourceFile in files)
|
||||
{
|
||||
// Skip .meta files
|
||||
if (sourceFile.EndsWith(".meta"))
|
||||
continue;
|
||||
|
||||
// Calculate relative path from source directory
|
||||
string relativePath = Path.GetRelativePath(SOURCE_PATH, sourceFile);
|
||||
string targetFile = Path.Combine(TARGET_PATH, relativePath);
|
||||
|
||||
// Create target subdirectory if needed
|
||||
string targetDir = Path.GetDirectoryName(targetFile);
|
||||
if (!Directory.Exists(targetDir))
|
||||
{
|
||||
Directory.CreateDirectory(targetDir);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Copy file if it doesn't exist or is newer
|
||||
if (!File.Exists(targetFile) || File.GetLastWriteTime(sourceFile) > File.GetLastWriteTime(targetFile))
|
||||
{
|
||||
File.Copy(sourceFile, targetFile, true);
|
||||
Debug.Log($"[CustomModelPostProcessor] Copied {relativePath} to StreamingAssets");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[CustomModelPostProcessor] Failed to copy {sourceFile}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh the asset database so Unity sees the new files
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
[MenuItem("WordToolkit/Copy Custom Models to StreamingAssets")]
|
||||
private static void ManualCopyCustomModels()
|
||||
{
|
||||
CopyCustomModelsToStreamingAssets();
|
||||
Debug.Log("[CustomModelPostProcessor] Manual copy completed");
|
||||
}
|
||||
|
||||
[MenuItem("WordToolkit/Clean Custom Models from StreamingAssets")]
|
||||
private static void CleanCustomModelsFromStreamingAssets()
|
||||
{
|
||||
if (Directory.Exists(TARGET_PATH))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(TARGET_PATH, true);
|
||||
Debug.Log("[CustomModelPostProcessor] Cleaned custom models from StreamingAssets");
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[CustomModelPostProcessor] Failed to clean StreamingAssets: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a1b585689cce4771abd8ec25020f1a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -23,71 +23,71 @@ namespace WordsToolkit.Scripts.Editor
|
||||
public static string WordConnect = "WordConnect";
|
||||
private static string WordConnectPath = "Assets/WordConnectGameToolkit";
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Shop settings")]
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Shop settings")]
|
||||
public static void IAPProducts()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/CoinsShopSettings.asset");
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Ads settings")]
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Ads settings")]
|
||||
public static void AdsSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/AdsSettings.asset");
|
||||
}
|
||||
|
||||
//DailyBonusSettings
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Daily bonus settings")]
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Daily bonus settings")]
|
||||
public static void DailyBonusSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/DailyBonusSettings.asset");
|
||||
}
|
||||
|
||||
//GameSettings
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Game settings")]
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Game settings")]
|
||||
public static void GameSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/GameSettings.asset");
|
||||
}
|
||||
|
||||
//SpinSettings
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Spin settings")]
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Spin settings")]
|
||||
public static void SpinSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/SpinSettings.asset");
|
||||
}
|
||||
|
||||
//DebugSettings
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Debug settings")]
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Debug settings")]
|
||||
public static void DebugSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/DebugSettings.asset");
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Crossword config")]
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Crossword config")]
|
||||
public static void CrosswordConfig()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/CrosswordConfig.asset");
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Tutorial settings")]
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Tutorial settings")]
|
||||
public static void TutorialSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/TutorialSettings.asset");
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Language configuration")]
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Language configuration")]
|
||||
public static void LanguageConfiguration()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/LanguageConfiguration.asset");
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Gift settings")]
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Gift settings")]
|
||||
public static void GiftSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/GiftSettings.asset");
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/GiftsSettings.asset");
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Scenes/Main scene &1", priority = 0)]
|
||||
[MenuItem( nameof(WordConnect) + "/Scenes/Main scene &1", priority = 0)]
|
||||
public static void MainScene()
|
||||
{
|
||||
EditorSceneManager.OpenScene(WordConnectPath + "/Scenes/main.unity");
|
||||
@ -99,7 +99,7 @@ namespace WordsToolkit.Scripts.Editor
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Scenes/Game scene &2")]
|
||||
[MenuItem( nameof(WordConnect) + "/Scenes/Game scene &2")]
|
||||
public static void GameScene()
|
||||
{
|
||||
var stateManager = Object.FindObjectOfType<StateManager>();
|
||||
@ -107,7 +107,7 @@ namespace WordsToolkit.Scripts.Editor
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Editor/Tile editor", priority = 1)]
|
||||
[MenuItem( nameof(WordConnect) + "/Editor/Tile editor", priority = 1)]
|
||||
public static void ColorEditor()
|
||||
{
|
||||
string folderPath = WordConnectPath + "/Resources/ColorsTile";
|
||||
@ -130,44 +130,37 @@ namespace WordsToolkit.Scripts.Editor
|
||||
EditorGUIUtility.PingObject(tileAsset);
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Documentation/Main", priority = 2)]
|
||||
[MenuItem( nameof(WordConnect) + "/Documentation/Main", priority = 2)]
|
||||
public static void MainDoc()
|
||||
{
|
||||
Application.OpenURL("https://candy-smith.gitbook.io/main");
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Documentation/ADS/Setup ads")]
|
||||
[MenuItem( nameof(WordConnect) + "/Documentation/ADS/Setup ads")]
|
||||
public static void UnityadsDoc()
|
||||
{
|
||||
Application.OpenURL("https://candy-smith.gitbook.io/bubble-shooter-toolkit/tutorials/ads-setup/");
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Documentation/Unity IAP (in-apps)")]
|
||||
[MenuItem( nameof(WordConnect) + "/Documentation/Unity IAP (in-apps)")]
|
||||
public static void Inapp()
|
||||
{
|
||||
Application.OpenURL("https://candy-smith.gitbook.io/main/block-puzzle-game-toolkit/setting-up-in-app-purchase-products");
|
||||
}
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/NLP/Training Language Model")]
|
||||
[MenuItem( nameof(WordConnect) + "/NLP/Training Language Model")]
|
||||
public static void TrainingModel()
|
||||
{
|
||||
Application.OpenURL("https://colab.research.google.com/drive/199zNcB3FPfnrD6E7OiwmwCcf27jMnY1b?usp=sharing");
|
||||
}
|
||||
|
||||
|
||||
[MenuItem(nameof(WordConnect) + "/Reset PlayerPrefs &e")]
|
||||
[MenuItem( nameof(WordConnect) + "/Reset PlayerPrefs &e")]
|
||||
private static void ResetPlayerPrefs()
|
||||
{
|
||||
GameDataManager.ClearALlData();
|
||||
PlayerPrefs.DeleteKey("GameState");
|
||||
Debug.Log("PlayerPrefs are reset");
|
||||
}
|
||||
|
||||
// 🔥 新增菜单项,打开 PrefabBatchViewer 窗口
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Prefab Batch Viewer")]
|
||||
public static void OpenPrefabBatchViewer()
|
||||
{
|
||||
PopupPreview.ShowWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ namespace WordsToolkit.Scripts.Editor
|
||||
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
|
||||
{
|
||||
CheckDefines("Assets/GoogleMobileAds", "ADMOB");
|
||||
CheckUMPAvailable();
|
||||
CheckDefines("Assets/FacebookSDK", "FACEBOOK");
|
||||
CheckDefines("Assets/PlayFabSDK", "PLAYFAB");
|
||||
CheckDefines("Assets/GameSparks", "GAMESPARKS");
|
||||
@ -41,6 +42,18 @@ namespace WordsToolkit.Scripts.Editor
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckUMPAvailable()
|
||||
{
|
||||
if (( Directory.Exists("Assets/GoogleMobileAds")))
|
||||
{
|
||||
DefineSymbolsUtils.AddSymbol("UMP_AVAILABLE");
|
||||
}
|
||||
else
|
||||
{
|
||||
DefineSymbolsUtils.DeleteSymbol("UMP_AVAILABLE");
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckIronsourceFolder()
|
||||
{
|
||||
var str = "Assets/LevelPlay";
|
||||
|
||||
Reference in New Issue
Block a user