fix: 1、更换命名空间和文件夹名字
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6086407cb7429a448811c2130527e8fe
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f26df653143eba43aa3ad437ae2b615
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b29e98153ec2fbd44b8f7da1b41194e8, type: 3}
|
||||
m_Name: SpineSettings
|
||||
m_EditorClassIdentifier:
|
||||
defaultScale: 0.01
|
||||
defaultMix: 0.2
|
||||
defaultShader: Spine/Skeleton
|
||||
defaultZSpacing: 0
|
||||
defaultInstantiateLoop: 1
|
||||
showHierarchyIcons: 1
|
||||
setTextureImporterSettings: 1
|
||||
textureSettingsReference: Assets/ZooMatch/Plugins/Spine/Editor/spine-unity/Editor/ImporterPresets/PMATexturePreset.preset
|
||||
blendModeMaterialMultiply: {fileID: 0}
|
||||
blendModeMaterialScreen: {fileID: 0}
|
||||
blendModeMaterialAdditive: {fileID: 0}
|
||||
atlasTxtImportWarning: 1
|
||||
textureImporterWarning: 1
|
||||
componentMaterialWarning: 1
|
||||
autoReloadSceneSkeletons: 1
|
||||
handleScale: 1
|
||||
mecanimEventIncludeFolderName: 1
|
||||
timelineUseBlendDuration: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f98d145a7b7484649aa1bc571cfae98c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31b3a1433a97dc04a93df4ad963ba5fe
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ZooMatch.Editor
|
||||
{
|
||||
public class AssetBundleBuildKit
|
||||
{
|
||||
static void SetABName(string assetPath)
|
||||
{
|
||||
var importerPath = $"Assets{assetPath[Application.dataPath.Length..]}";
|
||||
importerPath = importerPath.Replace("\\", "/");
|
||||
const string assetBundleRootPath = ZooMatchConstant.croas;
|
||||
|
||||
if (importerPath.StartsWith(assetBundleRootPath))
|
||||
{
|
||||
var bundleName = importerPath.Replace(assetBundleRootPath, "");
|
||||
|
||||
var endIndex = bundleName.LastIndexOf("/", StringComparison.Ordinal);
|
||||
|
||||
if (endIndex <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var fileInfo = new FileInfo(importerPath);
|
||||
|
||||
if ((fileInfo.Attributes & FileAttributes.Directory) == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
bundleName = bundleName.ToLower().Substring(0, endIndex).Replace("/", ".");
|
||||
|
||||
var importer = AssetImporter.GetAtPath(importerPath);
|
||||
if (importer != null)
|
||||
{
|
||||
importer.assetBundleName = $"{bundleName}{ZooMatchConstant.setbun}";
|
||||
if (importer.assetBundleName != null)
|
||||
{
|
||||
importer.assetBundleVariant = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(importerPath);
|
||||
Debug.LogError(endIndex);
|
||||
Debug.LogError(e.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetAssetBundlesName(string _assetsPath)
|
||||
{
|
||||
var dir = new DirectoryInfo(_assetsPath);
|
||||
|
||||
var files = dir.GetFileSystemInfos();
|
||||
|
||||
for (var i = 0; i < files.Length; i++)
|
||||
{
|
||||
if (files[i] is DirectoryInfo)
|
||||
{
|
||||
SetAssetBundlesName(files[i].FullName);
|
||||
}
|
||||
else if (!files[i].Name.EndsWith(".meta"))
|
||||
{
|
||||
SetABName(files[i].FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearAssetBundlesName()
|
||||
{
|
||||
var abNames = AssetDatabase.GetAllAssetBundleNames();
|
||||
for (var i = 0; i < abNames.Length; i++)
|
||||
{
|
||||
AssetDatabase.RemoveAssetBundleName(abNames[i], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31e51c9127634bf478349315a3424cf3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,130 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ZooMatch.Editor
|
||||
{
|
||||
public class BuildSome
|
||||
{
|
||||
[MenuItem("Tools/Build")]
|
||||
public static void BuildAssetBundle()
|
||||
{
|
||||
AssetBundleBuildKit.ClearAssetBundlesName();
|
||||
|
||||
AssetBundleBuildKit.SetAssetBundlesName(ZooMatchConstant.croas);
|
||||
|
||||
EditorApplication.isPlaying = false;
|
||||
|
||||
var dir = ZooMatchConstant.tbund;
|
||||
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.Delete(dir, true);
|
||||
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
|
||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
|
||||
var manifest = BuildPipeline.BuildAssetBundles(dir, BuildAssetBundleOptions.ChunkBasedCompression,
|
||||
buildTarget);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
EncryptAssetBundle();
|
||||
|
||||
BuildAssetBundleFileIndex(manifest);
|
||||
|
||||
Application.OpenURL(dir + "/..");
|
||||
}
|
||||
|
||||
|
||||
private static void EncryptAssetBundle()
|
||||
{
|
||||
var dir = ZooMatchConstant.tbund;
|
||||
|
||||
var filePaths = Directory.GetFiles(dir, $"*{ZooMatchConstant.setbun}",
|
||||
SearchOption.TopDirectoryOnly);
|
||||
|
||||
|
||||
var encryptPath = $"{Application.dataPath}/../AssetBundlesEncrypt";
|
||||
|
||||
if (!Directory.Exists(encryptPath))
|
||||
{
|
||||
Directory.CreateDirectory(encryptPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.Delete(encryptPath, true);
|
||||
|
||||
Directory.CreateDirectory(encryptPath);
|
||||
}
|
||||
|
||||
foreach (var assetBundleFile in filePaths)
|
||||
{
|
||||
if (!assetBundleFile.EndsWith(".meta") && !assetBundleFile.Contains(".DS_Store"))
|
||||
{
|
||||
var assetBundleName = assetBundleFile.Replace(dir, string.Empty).Replace("\\", "");
|
||||
var encryptFilePath = Path.Combine(encryptPath, assetBundleName);
|
||||
AESForFileKit.EncryptFile(assetBundleFile, encryptFilePath,
|
||||
ZooMatchConstant.admsie);
|
||||
|
||||
File.Copy(encryptFilePath, Path.Combine(dir, assetBundleName), true);
|
||||
}
|
||||
}
|
||||
|
||||
Directory.Delete(encryptPath, true);
|
||||
}
|
||||
|
||||
private static void BuildAssetBundleFileIndex(AssetBundleManifest manifest)
|
||||
{
|
||||
var dir = ZooMatchConstant.tbund;
|
||||
var dirFile = $"{ZooMatchConstant.tbund}/../";
|
||||
|
||||
var filePath = Path.Combine(dirFile, ZooMatchConstant.zyzootx);
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
|
||||
var filePaths = Directory.GetFiles(dir, $"*{ZooMatchConstant.setbun}",
|
||||
SearchOption.TopDirectoryOnly);
|
||||
|
||||
using var fileStream = new FileStream(filePath, FileMode.CreateNew);
|
||||
|
||||
using var streamWriter = new StreamWriter(fileStream);
|
||||
|
||||
var totalAssetBundlePath = $"{dir}/{ZooMatchConstant.undles}";
|
||||
|
||||
var totalAssetBundleManifestPath = $"{dir}/{ZooMatchConstant.lesest}";
|
||||
|
||||
var totalMD5 = MD5Kit.GetFileMD5(totalAssetBundlePath);
|
||||
streamWriter.WriteLine(GetAssetBundleFileIndex(ZooMatchConstant.undles, totalMD5));
|
||||
|
||||
var manifestMD5 = MD5Kit.GetFileMD5(totalAssetBundleManifestPath);
|
||||
streamWriter.WriteLine(GetAssetBundleFileIndex(ZooMatchConstant.lesest,
|
||||
manifestMD5));
|
||||
foreach (var assetBundleFile in filePaths)
|
||||
{
|
||||
if (!assetBundleFile.EndsWith(".meta") && !assetBundleFile.Contains(".DS_Store"))
|
||||
{
|
||||
var fileMD5 = MD5Kit.GetFileMD5(assetBundleFile);
|
||||
|
||||
var assetBundleName = assetBundleFile.Replace(dir, string.Empty).Replace("\\", "");
|
||||
|
||||
streamWriter.WriteLine(GetAssetBundleFileIndex(assetBundleName, fileMD5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetAssetBundleFileIndex(string assetBundleName, string assetBundleFileMD5)
|
||||
{
|
||||
return $"{assetBundleName}{ZooMatchConstant.fgklpk}{assetBundleFileMD5}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed953085dc79620428de22e21e047db9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,246 @@
|
||||
using FairyGUI;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZooMatch.Editor
|
||||
{
|
||||
public static class FGUIContollerConstantKit
|
||||
{
|
||||
private const string content =
|
||||
@"
|
||||
|
||||
/// <summary>
|
||||
/// FGUI控制器自动生成
|
||||
/// </summary>
|
||||
namespace FGUI.{0}
|
||||
{
|
||||
public partial class className
|
||||
{
|
||||
{1} }
|
||||
}";
|
||||
|
||||
private static Dictionary<string, string> classDic = new();
|
||||
private static Dictionary<string, string> constClassDic = new();
|
||||
|
||||
private static string C_DestFolderPath =
|
||||
Application.dataPath + "/ZooMatch/FGUI/ControlDefine/Common/";
|
||||
|
||||
private static string DestFolderPath =
|
||||
Application.dataPath + "/ZooMatch/FGUI/ControlDefine/Project/";
|
||||
|
||||
[MenuItem("Tools/CreateCtrl")]
|
||||
public static void CreateAllControllerScripts()
|
||||
{
|
||||
UIPackage.RemoveAllPackages();
|
||||
|
||||
CreateControllerScripts(true);
|
||||
CreateControllerScripts(false);
|
||||
|
||||
UIPackage.RemoveAllPackages();
|
||||
var stage = GameObject.Find("Stage");
|
||||
if (stage != null)
|
||||
{
|
||||
Object.DestroyImmediate(stage);
|
||||
}
|
||||
|
||||
var stageCamera = GameObject.Find("Stage Camera");
|
||||
if (stageCamera != null)
|
||||
{
|
||||
Object.DestroyImmediate(stageCamera);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void CreateController_ScriptsCommon()
|
||||
{
|
||||
UIPackage.RemoveAllPackages();
|
||||
|
||||
CreateControllerScripts(true);
|
||||
|
||||
UIPackage.RemoveAllPackages();
|
||||
}
|
||||
|
||||
|
||||
public static void CreateController_ScriptsProject()
|
||||
{
|
||||
UIPackage.RemoveAllPackages();
|
||||
|
||||
CreateControllerScripts(false);
|
||||
|
||||
UIPackage.RemoveAllPackages();
|
||||
}
|
||||
|
||||
private static void CreateControllerScripts(bool isCreateCommon)
|
||||
{
|
||||
classDic.Clear();
|
||||
constClassDic.Clear();
|
||||
|
||||
string[] ids = AssetDatabase.FindAssets("_fui t:textAsset");
|
||||
foreach (var item in ids)
|
||||
{
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(item);
|
||||
int pos = assetPath.LastIndexOf("_fui");
|
||||
if (pos == -1)
|
||||
continue;
|
||||
|
||||
assetPath = assetPath.Substring(0, pos);
|
||||
LoadOneUI(assetPath, isCreateCommon);
|
||||
}
|
||||
|
||||
CreateScripts(isCreateCommon);
|
||||
}
|
||||
|
||||
private static void CreateScripts(bool isCreateCommon)
|
||||
{
|
||||
if (isCreateCommon)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Directory.Exists(DestFolderPath))
|
||||
{
|
||||
Directory.Delete(DestFolderPath, true);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(DestFolderPath);
|
||||
}
|
||||
|
||||
string startPre = isCreateCommon ? C_DestFolderPath : DestFolderPath;
|
||||
foreach (var item in classDic)
|
||||
{
|
||||
if (item.Key.StartsWith(startPre))
|
||||
FileKit.CreateTxt(item.Key, item.Value, true);
|
||||
}
|
||||
|
||||
foreach (var item in constClassDic)
|
||||
{
|
||||
if (item.Key.StartsWith(startPre))
|
||||
FileKit.CreateTxt(item.Key, item.Value, true);
|
||||
}
|
||||
|
||||
if (isCreateCommon)
|
||||
Debug.Log("[FGUIContollerCreateTool]生成通用界面控制器常量完成:" + startPre);
|
||||
else
|
||||
Debug.Log("[FGUIContollerCreateTool]生成项目界面控制器常量完成:" + startPre);
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
private static void LoadOneUI(string resPath, bool isCreateCommon)
|
||||
{
|
||||
string objName = new FileInfo(Path.GetFullPath(resPath)).Name;
|
||||
UIPackage pkg = UIPackage.GetByName(objName);
|
||||
if (pkg == null)
|
||||
{
|
||||
pkg = UIPackage.AddPackage(resPath);
|
||||
}
|
||||
|
||||
foreach (var item in pkg.GetItems())
|
||||
{
|
||||
if (item.type == PackageItemType.Component)
|
||||
{
|
||||
GComponent gComponent = null;
|
||||
|
||||
var tmpGomponent = pkg.CreateObject(item.name);
|
||||
gComponent = tmpGomponent as GComponent;
|
||||
|
||||
if (gComponent == null)
|
||||
{
|
||||
DisposeGObject(tmpGomponent);
|
||||
continue;
|
||||
}
|
||||
|
||||
string tmpPropertyStr = "";
|
||||
string constPropertyStr = "";
|
||||
List<string> nameList = new List<string>();
|
||||
foreach (var tmp in gComponent.Controllers)
|
||||
{
|
||||
nameList.Clear();
|
||||
for (int i = 0; i < tmp.pageCount; i++)
|
||||
{
|
||||
string name = tmp.GetPageName(i).Replace(" ", "");
|
||||
if (nameList.Contains(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
nameList.Add(name);
|
||||
|
||||
string summary = @" /// <summary>
|
||||
/// {0}:{1}
|
||||
/// </summary>
|
||||
";
|
||||
summary = string.Format(summary, i, tmp.GetPageName(i));
|
||||
|
||||
tmpPropertyStr += summary;
|
||||
constPropertyStr += summary;
|
||||
string contName = tmp.name.Replace("cont_", "");
|
||||
contName = FirstLetterToUpper(contName);
|
||||
tmpPropertyStr += string.Format("public int _{0}_{1} = {2};\r\n", contName, name, i);
|
||||
constPropertyStr += string.Format("public const int {0}_{1} = {2};\r\n", contName, name, i);
|
||||
}
|
||||
}
|
||||
|
||||
List<Controller> controllers = gComponent.Controllers;
|
||||
DisposeGObject(gComponent);
|
||||
if (controllers.Count != 0)
|
||||
{
|
||||
if (isCreateCommon)
|
||||
{
|
||||
if (!pkg.name.StartsWith("C"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pkg.name.StartsWith("C"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
string objClassContent = content.Replace("{0}", pkg.name).Replace("{1}", tmpPropertyStr)
|
||||
.Replace("className", item.name);
|
||||
string constClassContent = content.Replace("{0}", pkg.name).Replace("{1}", constPropertyStr)
|
||||
.Replace("className", item.name);
|
||||
string prePath = pkg.name.StartsWith("C") ? C_DestFolderPath : DestFolderPath;
|
||||
string path = prePath + pkg.name + "/" + item.name + "_AutoCreator.cs";
|
||||
string constPath = prePath + pkg.name + "/" + item.name + "_Const.cs";
|
||||
if (!classDic.ContainsKey(path))
|
||||
{
|
||||
classDic.Add(path, objClassContent);
|
||||
constClassDic.Add(constPath, constClassContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void DisposeGObject(GObject gObject)
|
||||
{
|
||||
gObject.Dispose();
|
||||
if (gObject.displayObject != null)
|
||||
{
|
||||
if (gObject.displayObject.gameObject)
|
||||
{
|
||||
Object.Destroy(gObject.displayObject.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string FirstLetterToUpper(string str)
|
||||
{
|
||||
if (str == null)
|
||||
return null;
|
||||
|
||||
if (str.Length > 1)
|
||||
return char.ToUpper(str[0]) + str.Substring(1);
|
||||
|
||||
return str.ToUpper();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81aeb2cc6bde11b47bce1e10f10a099e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ZooMatch.Editor
|
||||
{
|
||||
public static class FileKit
|
||||
{
|
||||
public static void CreateTxt(string path, string Txt, bool IsCover = false, bool IsAssetPath = false)
|
||||
{
|
||||
if (IsAssetPath)
|
||||
{
|
||||
path = Application.dataPath.Replace("Assets", string.Empty) + path;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(GetFullDiretoryPath(path)))
|
||||
{
|
||||
Directory.CreateDirectory(GetFullDiretoryPath(path));
|
||||
}
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
if (!IsCover)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
File.Delete(path);
|
||||
}
|
||||
|
||||
File.WriteAllText(path, Txt, new UTF8Encoding(false));
|
||||
}
|
||||
|
||||
public static string GetFullDiretoryPath(string filePath)
|
||||
{
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
return filePath.Replace(fileName, string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfb22dd27fba6ca41ac694652c2c7abf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user