update tex pack

This commit is contained in:
StarBeats 2025-11-11 15:19:01 +08:00
parent 789d0e3a69
commit 2c49be5735
11 changed files with 585 additions and 57 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

View File

@ -0,0 +1,114 @@
fileFormatVersion: 2
guid: f7da50a7dd2427945a04ecfb0815a421
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0
mipMapFadeDistanceStart: 0
mipMapFadeDistanceEnd: 0
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 0
maxTextureSize: 0
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 0
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 0
spriteMode: 0
spriteExtrude: 0
spriteMeshType: 0
alignment: 0
spritePivot: {x: 0, y: 0}
spritePixelsToUnits: 0
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 0
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: 0
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -30,27 +30,13 @@ namespace TexturePacker
public EPackType PackType = EPackType.Atlas;
public SerializedDictionary<Texture2D, TextureInfo> OriginTexture2TextureInfo = new();
public List<Texture2D> Textures;
public List<UnityEngine.Object> Fbxs;
public Texture2D TextureAtlas;
public float AtlasScale;
public string TextureAtlasPath;
public Texture2DArray TextureArray;
public string TextureArrayPath;
public bool IsNormalMap;
[ContextMenu("Test")]
private void Test()
{
Texture2D offsetTex = new Texture2D(Textures.Count, 1, TextureFormat.RG16, false);
for (int i = 0; i < Textures.Count; i++)
{
var tex = Textures[i];
var info = OriginTexture2TextureInfo[tex];
offsetTex.SetPixel(i, 0, new Color(info.Offset.x, info.Offset.y, 0));
}
var path = EditorUtility.SaveFilePanelInProject("保存offset图", "OffsetMap", "png", "");
File.WriteAllBytes(path, offsetTex.EncodeToPNG());
}
}
}

View File

@ -1,11 +1,15 @@
using log4net.Util;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using TexturePacker;
using Unity.Collections;
using Unity.Mathematics;
using UnityEditor;
using UnityEditor.Formats.Fbx.Exporter;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
@ -24,6 +28,12 @@ public sealed class TexturePackerEditor : EditorWindow
private List<Texture2D> selectedTexs = new();
private List<Rect> texRects = new();
private static Type gameObjectInspectorType;
private List<Editor> gameObjectInspectorView = new();
private List<UnityEngine.Object> models = new();
private List<Rect> modelRects = new();
private Button btApplyMesh;
private Vector2 cellSize = new Vector2(100, 100);
private const int MaxArraySize = 255;
@ -40,6 +50,8 @@ public sealed class TexturePackerEditor : EditorWindow
private Label infoLabel = null;
private GraphicsFormat graphicsFormat = GraphicsFormat.R32G32B32A32_SFloat;
private bool dockPreviewWindowFail = false;
public enum ETextureSize
{
_128 = 1 << 7,
@ -48,26 +60,105 @@ public sealed class TexturePackerEditor : EditorWindow
_1024 = 1 << 10,
}
static readonly object fbxExportSetting = null;
static Delegate exportObjectFunc;
static TexturePackerEditor()
{
var editorCore = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name.Equals("UnityEditor.CoreModule")).FirstOrDefault();
var type = editorCore.GetType("UnityEditor.PropertyEditor");
var methodInfo = type.GetMethod("OpenPropertyEditor", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, null, new Type[] { typeof(UnityEngine.Object), typeof(bool) }, null);
fnOpenPropertyEditor = methodInfo.CreateDelegate(typeof(Func<UnityEngine.Object, bool, EditorWindow>)) as Func<UnityEngine.Object, bool, EditorWindow>;
gameObjectInspectorType = editorCore.GetType("UnityEditor.GameObjectInspector");
var fbxAssembly = Assembly.GetAssembly(typeof(ModelExporter));
var exportMethodInfo = typeof(ModelExporter).GetMethod("ExportObject", BindingFlags.NonPublic | BindingFlags.Static);
exportObjectFunc = exportMethodInfo.CreateDelegate(Expression.GetDelegateType(exportMethodInfo.GetParameters().Select(p => p.ParameterType).Concat(new[] { exportMethodInfo.ReturnType }).ToArray()));
Type exportModelSettingsSerialize = fbxAssembly.GetType("UnityEditor.Formats.Fbx.Exporter.ExportModelSettingsSerialize");
fbxExportSetting = Activator.CreateInstance(exportModelSettingsSerialize);
foreach (var item in exportModelSettingsSerialize.GetMethods().Union(exportModelSettingsSerialize.BaseType.GetMethods()))
{
switch (item.Name)
{
case "SetExportFormat":
{
item.Invoke(fbxExportSetting, new object[] { 1 });
item.Invoke(fbxExportSetting, new object[] { Enum.Parse(fbxAssembly.GetType("UnityEditor.Formats.Fbx.Exporter.ExportSettings+ExportFormat"), "1") });
break;
}
case "SetAnimatedSkinnedMesh":
{
item.Invoke(fbxExportSetting, new object[] { false });
break;
}
case "SetUseMayaCompatibleNames":
{
item.Invoke(fbxExportSetting, new object[] { false });
break;
}
case "SetModelAnimIncludeOption":
{
item.Invoke(fbxExportSetting, new object[] { Enum.Parse(fbxAssembly.GetType("UnityEditor.Formats.Fbx.Exporter.ExportSettings+Include"), "0") });
break;
}
case "SetLODExportType":
{
item.Invoke(fbxExportSetting, new object[] { Enum.Parse(fbxAssembly.GetType("UnityEditor.Formats.Fbx.Exporter.ExportSettings+LODExportType"), "0") });
break;
}
case "SetEmbedTextures":
{
item.Invoke(fbxExportSetting, new object[] { false });
break;
}
case "SetPreserveImportSettings":
{
item.Invoke(fbxExportSetting, new object[] { false });
break;
}
case "SetKeepInstances":
{
item.Invoke(fbxExportSetting, new object[] { false });
break;
}
case "SetExportUnredererd":
{
item.Invoke(fbxExportSetting, new object[] { false });
break;
}
default:
break;
}
}
}
[MenuItem("Tools/Performance/TexturePackerEditor")]
public static void OpenTexturePackerEditor()
{
TexturePackerEditor wnd = GetWindow<TexturePackerEditor>();
TexturePackerEditor wnd = CreateInstance<TexturePackerEditor>();
wnd.titleContent = new GUIContent("TexturePackerEditor");
wnd.Show();
}
public static void OpenTexturePackerEditor(Texture2D[] textures)
{
TexturePackerEditor wnd = CreateInstance<TexturePackerEditor>();
wnd.titleContent = new GUIContent("TexturePackerEditor");
for (int i = 0; i < textures.Length; i++)
{
wnd.AddTexture(textures[i]);
}
wnd.Show();
}
[UnityEditor.Callbacks.OnOpenAsset(0)]
private static bool OnOpenTextureMapInfo(int instanceID, int line)
{
var textureMapInfo = EditorUtility.InstanceIDToObject(instanceID) as TextureMapInfo;
if(!textureMapInfo)
if (!textureMapInfo)
{
return false;
}
@ -96,6 +187,8 @@ public sealed class TexturePackerEditor : EditorWindow
var btArray = root.Q<Button>("btArray");
var btAtlas = root.Q<Button>("btAtlas");
var btSave = root.Q<Button>("btSave");
btApplyMesh = root.Q<Button>("btApplyMesh");
infoLabel = root.Q<Label>("infoLabel");
var slAtlasPadding = root.Q<SliderInt>("slAtlasPadding");
@ -111,7 +204,7 @@ public sealed class TexturePackerEditor : EditorWindow
textureSizeEnum.RegisterCallback<ChangeEvent<Enum>>((e) =>
{
var newTextureSize = (int)(ETextureSize)e.newValue;
if(textureSize != newTextureSize)
if (textureSize != newTextureSize)
{
textureSize = newTextureSize;
UpdateResult();
@ -149,9 +242,11 @@ public sealed class TexturePackerEditor : EditorWindow
imageListContainer = root.Q<IMGUIContainer>("imgList");
imageListContainer.onGUIHandler = OnImageListGUI;
imageListContainer.RegisterCallback<MouseDownEvent>((e) =>
{
var mousePos = Event.current.mousePosition - toolbarOffset;
int clickIndex = -1;
for (int i = 0; i < texRects.Count; i++)
{
if (texRects[i].Contains(mousePos))
@ -160,32 +255,105 @@ public sealed class TexturePackerEditor : EditorWindow
break;
}
}
if (Event.current.type == EventType.MouseDown && Event.current.clickCount == 2)
{
if (clickIndex == -1)
{
for (int i = 0; i < modelRects.Count; i++)
{
if (modelRects[i].Contains(mousePos))
{
clickIndex = i;
break;
}
}
if (clickIndex != -1)
{
EditorGUIUtility.PingObject(models[clickIndex]);
}
}
else if (clickIndex != -1)
{
EditorGUIUtility.PingObject(selectedTexs[clickIndex]);
}
}
});
imageListContainer.RegisterCallback<MouseUpEvent>((e) =>
{
var swpaIndex = -1;
var swapIndex = -1;
var mousePos = Event.current.mousePosition - toolbarOffset;
for (int i = 0; i < texRects.Count; i++)
{
if (texRects[i].Contains(mousePos))
{
swpaIndex = i;
swapIndex = i;
break;
}
}
if (swpaIndex != -1 && selectIndexForMove != -1)
if (swapIndex != -1 && selectIndexForMove != -1)
{
if (selectIndexForMove != swpaIndex)
if (selectIndexForMove != swapIndex)
{
(selectedTexs[selectIndexForMove], selectedTexs[swpaIndex]) = (selectedTexs[swpaIndex], selectedTexs[selectIndexForMove]);
(texRects[selectIndexForMove], texRects[swpaIndex]) = (texRects[swpaIndex], texRects[selectIndexForMove]);
(selectedTexs[selectIndexForMove], selectedTexs[swapIndex]) = (selectedTexs[swapIndex], selectedTexs[selectIndexForMove]);
(texRects[selectIndexForMove], texRects[swapIndex]) = (texRects[swapIndex], texRects[selectIndexForMove]);
UpdateResult();
}
}
selectIndexForMove = -1;
});
imageListContainer.RegisterCallback<DragUpdatedEvent>((e) =>
{
var mousePos = Event.current.mousePosition - toolbarOffset;
var replaceIdx = -1;
for (int i = 0; i < modelRects.Count; i++)
{
if (modelRects[i].Contains(mousePos))
{
replaceIdx = i;
break;
}
}
if (replaceIdx != -1 && DragAndDrop.objectReferences.Length > 0)
{
if (AssetDatabase.GetAssetPath(DragAndDrop.objectReferences[0]).ToLower().EndsWith(".fbx"))
{
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
}
}
});
imageListContainer.RegisterCallback<DragExitedEvent>((e) =>
{
var mousePos = Event.current.mousePosition - toolbarOffset;
var replaceIdx = -1;
for (int i = 0; i < modelRects.Count; i++)
{
if (modelRects[i].Contains(mousePos))
{
replaceIdx = i;
break;
}
}
if (replaceIdx != -1 && DragAndDrop.objectReferences.Length > 0)
{
if (AssetDatabase.GetAssetPath(DragAndDrop.objectReferences[0]).ToLower().EndsWith(".fbx"))
{
ReplaceModel(replaceIdx, DragAndDrop.objectReferences[0]);
}
}
});
btApplyMesh.clicked += () =>
{
ModifyMesh();
};
}
private void SetNormalOriginTextureFormat(bool toNormal)
@ -193,7 +361,7 @@ public sealed class TexturePackerEditor : EditorWindow
foreach (var item in selectedTexs)
{
var ti = TextureImporter.GetAtPath(AssetDatabase.GetAssetPath(item)) as TextureImporter;
if(toNormal)
if (toNormal)
{
ti.textureType = TextureImporterType.NormalMap;
}
@ -216,6 +384,7 @@ public sealed class TexturePackerEditor : EditorWindow
int currentRow = 0;
var bkColor = GUI.backgroundColor;
EditorGUILayout.LabelField("Texture:");
for (int i = 0; i < count; i++)
{
@ -236,9 +405,6 @@ public sealed class TexturePackerEditor : EditorWindow
GUI.backgroundColor = bkColor;
}
// insert ?
//EditorGUI.DrawRect
if (GUI.Button(rect, selectedTexs[i]))
{
if (selectIndex == i)
@ -256,11 +422,13 @@ public sealed class TexturePackerEditor : EditorWindow
currentColumn = 0;
}
}
GUI.backgroundColor = bkColor;
if (selectIndexForMove != -1)
{
GUI.Button(new Rect(Event.current.mousePosition, cellSize), selectedTexs[selectIndexForMove]);
}
if (selectIndex != -1)
{
infoLabel.visible = true;
@ -283,6 +451,38 @@ public sealed class TexturePackerEditor : EditorWindow
{
GUILayout.EndHorizontal();
}
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
EditorGUILayout.LabelField("Model:");
GUILayout.BeginHorizontal();
for (int i = 0; i < gameObjectInspectorView.Count; i++)
{
var pv = gameObjectInspectorView[i];
var rect = EditorGUILayout.GetControlRect(GUILayout.Width(cellSize.x * 2), GUILayout.Height(cellSize.y * 2));
modelRects[i] = rect;
pv.DrawPreview(rect);
}
GUILayout.EndHorizontal();
if (dockPreviewWindowFail)
{
dockPreviewWindowFail = false;
try
{
if (atlasPropertiesWindow != null)
{
this.Dock(atlasPropertiesWindow, Docker.DockPosition.Right);
}
if (arrayPropertiesWindow != null)
{
this.Dock(arrayPropertiesWindow, Docker.DockPosition.Right);
}
}
catch
{
dockPreviewWindowFail = true;
}
}
}
private void InitWithTextureMapInfo(TextureMapInfo textureMapInfo)
@ -305,14 +505,22 @@ public sealed class TexturePackerEditor : EditorWindow
slAtlasPadding.visible = false;
}
if(textureMapInfo.IsNormalMap)
if (textureMapInfo.IsNormalMap)
{
root.Q<Toggle>("tgIsNormal").value = true;
SetNormalOriginTextureFormat(!textureMapInfo.IsNormalMap);
}
selectedTexs = textureMapInfo.Textures;
texRects = new List<Rect>(new Rect[selectedTexs.Count]);
foreach (var item in textureMapInfo.Textures)
{
AddTexture(item);
}
foreach (var item in textureMapInfo.Fbxs)
{
AddModel(item);
}
}
private void OnGUI()
@ -349,10 +557,9 @@ public sealed class TexturePackerEditor : EditorWindow
break;
case EventType.DragUpdated:
{
for (var i = 0; i < DragAndDrop.objectReferences.Length; i++)
{
if (DragAndDrop.objectReferences[i] is Texture)
if (DragAndDrop.objectReferences[i] is Texture || AssetDatabase.GetAssetPath(DragAndDrop.objectReferences[0]).ToLower().EndsWith(".fbx"))
{
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
break;
@ -369,6 +576,10 @@ public sealed class TexturePackerEditor : EditorWindow
{
AddTexture(tex);
}
else if (AssetDatabase.GetAssetPath(DragAndDrop.objectReferences[0]).ToLower().EndsWith(".fbx"))
{
AddModel(DragAndDrop.objectReferences[i]);
}
}
}
break;
@ -378,6 +589,11 @@ public sealed class TexturePackerEditor : EditorWindow
break;
case EventType.MouseLeaveWindow:
break;
case EventType.Repaint:
{
btApplyMesh.visible = models.Count > 0;
break;
}
default:
break;
}
@ -441,7 +657,7 @@ public sealed class TexturePackerEditor : EditorWindow
private void UpdateResult()
{
if(selectedTexs.Count < 2)
if (selectedTexs.Count < 2)
{
return;
}
@ -479,6 +695,7 @@ public sealed class TexturePackerEditor : EditorWindow
}
catch
{
dockPreviewWindowFail = true;
}
}
atlasPropertiesWindow.Repaint();
@ -508,7 +725,14 @@ public sealed class TexturePackerEditor : EditorWindow
if (!arrayPropertiesWindow)
{
arrayPropertiesWindow = fnOpenPropertyEditor(textureArray, true);
this.Dock(arrayPropertiesWindow, Docker.DockPosition.Right);
try
{
this.Dock(arrayPropertiesWindow, Docker.DockPosition.Right);
}
catch
{
dockPreviewWindowFail = true;
}
}
arrayPropertiesWindow.Repaint();
}
@ -516,7 +740,7 @@ public sealed class TexturePackerEditor : EditorWindow
private void AddTexture(Texture2D texture2D)
{
if(TextureMapIndex.Instance.ResultGuid2TextureMap.TryGetValue(AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(texture2D)), out var mapInfo))
if (TextureMapIndex.Instance.ResultGuid2TextureMap.TryGetValue(AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(texture2D)), out var mapInfo))
{
selectedTexs.Clear();
textureMapInfo = mapInfo;
@ -529,7 +753,7 @@ public sealed class TexturePackerEditor : EditorWindow
return;
}
if(selectedTexs.Count == MaxArraySize)
if (selectedTexs.Count == MaxArraySize)
{
EditorUtility.DisplayDialog("提示", $"贴图数量最多 {MaxArraySize}", "ok");
return;
@ -564,22 +788,48 @@ public sealed class TexturePackerEditor : EditorWindow
{
texRects.RemoveAt(idx);
selectedTexs.RemoveAt(idx);
if (models.Count > idx)
{
models.RemoveAt(idx);
modelRects.RemoveAt(idx);
gameObjectInspectorView.RemoveAt(idx);
}
}
imgCntLabel.text = selectedTexs.Count.ToString();
UpdateResult();
}
private void AddModel(UnityEngine.Object gameObject)
{
if (!models.Contains(gameObject) && models.Count < selectedTexs.Count)
{
models.Add(gameObject);
modelRects.Add(new());
gameObjectInspectorView.Add(Editor.CreateEditor(gameObject, gameObjectInspectorType));
}
}
private void ReplaceModel(int replaceIdx, UnityEngine.Object gameObject)
{
if (gameObject != models[replaceIdx])
{
models[replaceIdx] = gameObject;
gameObjectInspectorView[replaceIdx] = Editor.CreateEditor(gameObject, gameObjectInspectorType);
}
}
private void UpdateMapinfoBeforeSave()
{
textureMapInfo.Textures = selectedTexs;
textureMapInfo.Fbxs = models;
var hasAlpha = GraphicsFormatUtility.HasAlphaChannel(selectedTexs[0].graphicsFormat);
for (int i = 1; i < selectedTexs.Count; i++)
{
var tex = selectedTexs[i];
if (hasAlpha != GraphicsFormatUtility.HasAlphaChannel(tex.graphicsFormat))
{
if(!EditorUtility.DisplayDialog("警告", $"源贴图 alpha 不一致 :{tex.name}", "继续", "取消"))
if (!EditorUtility.DisplayDialog("警告", $"源贴图 alpha 不一致 :{tex.name}", "继续", "取消"))
{
return;
}
@ -619,7 +869,7 @@ public sealed class TexturePackerEditor : EditorWindow
}
AssetDatabase.ImportAsset(textureMapInfo.TextureAtlasPath);
if(TextureImporter.GetAtPath(textureMapInfo.TextureAtlasPath) is TextureImporter ti)
if (TextureImporter.GetAtPath(textureMapInfo.TextureAtlasPath) is TextureImporter ti)
{
ti.SetTextureSettings(new TextureImporterSettings()
{
@ -666,7 +916,7 @@ public sealed class TexturePackerEditor : EditorWindow
{
using var fr = File.Open(textureMapInfo.TextureArrayPath, FileMode.OpenOrCreate);
using MemoryStream memoryStream = new MemoryStream();
for (int i = textureArray.depth - 1; i >=0 ; --i)
for (int i = textureArray.depth - 1; i >= 0; --i)
{
var array = req.GetData<byte>(i);
memoryStream.Write(array);
@ -714,7 +964,7 @@ public sealed class TexturePackerEditor : EditorWindow
else
{
var path = EditorUtility.SaveFilePanelInProject("保存映射关系", DateTime.Now.ToString("yy_MM_dd_hhmmss"), "asset", "保存源贴图到 atlas 对应关系", TextureMapInfo.TextureMapDir);
if(string.IsNullOrEmpty(path))
if (string.IsNullOrEmpty(path))
{
return;
}
@ -727,6 +977,43 @@ public sealed class TexturePackerEditor : EditorWindow
AssetDatabase.Refresh();
}
private void ModifyMesh()
{
for (int i = 0; i < models.Count; i++)
{
var model = models[i] as GameObject;
var mfs = model.GetComponentsInChildren<MeshFilter>();
var tex = selectedTexs[i];
var info = textureMapInfo.OriginTexture2TextureInfo[tex];
for (int j = 0; j < mfs.Length; j++)
{
var mf = mfs[j];
if (textureMapInfo.PackType == TextureMapInfo.EPackType.Atlas)
{
NativeArray<float2> uv2 = new (mf.sharedMesh.vertexCount, Allocator.Temp);
for (int k = 0; k < mf.sharedMesh.uv.Length; k++)
{
var uv = mf.sharedMesh.uv[k];
uv2[k] = uv * textureMapInfo.AtlasScale + (Vector2)info.Offset;
}
mf.sharedMesh.SetUVs(0, uv2);
uv2.Dispose();
}
else
{
using NativeArray<int2> uv = new (mf.sharedMesh.vertexCount, Allocator.Temp);
uv.AsSpan().Fill(new int2(info.ArrayIndex));
mf.sharedMesh.SetUVs(3, uv);
}
}
var path = AssetDatabase.GetAssetPath(model);
exportObjectFunc.DynamicInvoke(path, model, fbxExportSetting);
}
AssetDatabase.Refresh();
}
private void OnDestroy()
{
SetNormalOriginTextureFormat(textureMapInfo.IsNormalMap);

View File

@ -3,11 +3,12 @@
<uie:Toolbar style="font-size: 16px; height: auto; flex-wrap: nowrap; align-items: auto; align-self: auto; justify-content: flex-start; flex-direction: row;">
<ui:Button text="Atlas" parse-escape-sequences="true" display-tooltip-when-elided="true" name="btAtlas" style="visibility: visible; overflow: hidden; opacity: 1; flex-wrap: nowrap; border-top-left-radius: 5px; border-top-right-radius: 0; border-bottom-right-radius: 0; border-bottom-left-radius: 5px; margin-right: 0; font-size: 16px; -unity-background-scale-mode: stretch-to-fill; background-color: rgb(88, 88, 88);" />
<ui:Button text="Array" parse-escape-sequences="true" display-tooltip-when-elided="true" name="btArray" style="border-top-left-radius: 0; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 0; margin-left: 0; font-size: 16px; background-color: rgb(88, 88, 88);" />
<ui:Label tabindex="-1" text="0" parse-escape-sequences="true" display-tooltip-when-elided="true" name="imgCntLabel" style="flex-direction: row; justify-content: space-between; align-items: auto; align-self: stretch; margin-left: 4px; -unity-text-align: middle-center;" />
<ui:Toggle label="法线图" name="tgIsNormal" style="width: 150px; left: auto; right: auto; flex-direction: row; align-items: stretch; justify-content: center; align-self: center; white-space: normal; text-overflow: clip; -unity-text-align: middle-right; margin-right: 2px;" />
<ui:SliderInt label="图集间距" high-value="5" name="slAtlasPadding" style="width: 200px; -unity-text-align: middle-right; white-space: nowrap; text-overflow: clip; font-size: 15px;" />
<ui:EnumField label="贴图尺寸" type="TexturePackerEditor+ETextureSize, Assembly-CSharp-Editor" value="_512" name="textureSizeEnum" style="width: 181px; justify-content: flex-end; -unity-text-align: upper-right;" />
<ui:Button text="Save" parse-escape-sequences="true" display-tooltip-when-elided="true" name="btSave" style="translate: 100px 0;" />
<ui:Label tabindex="-1" text="0" parse-escape-sequences="true" display-tooltip-when-elided="true" name="imgCntLabel" style="flex-direction: row; justify-content: space-between; align-items: auto; align-self: stretch; margin-left: auto; -unity-text-align: middle-center;" />
<ui:Toggle label="法线图" name="tgIsNormal" style="width: 150px; left: auto; right: auto; flex-direction: row; align-items: stretch; justify-content: center; align-self: center; white-space: normal; text-overflow: clip; -unity-text-align: upper-right; margin-right: 2px; margin-left: auto;" />
<ui:SliderInt label="图集间距" high-value="5" name="slAtlasPadding" style="width: 200px; -unity-text-align: upper-right; white-space: nowrap; text-overflow: clip; font-size: 15px; align-items: auto; margin-left: auto;" />
<ui:EnumField label="贴图尺寸" type="TexturePackerEditor+ETextureSize, Assembly-CSharp-Editor" value="_512" name="textureSizeEnum" style="width: 181px; justify-content: flex-end; -unity-text-align: upper-right; margin-left: auto;" />
<ui:Button text="Save" parse-escape-sequences="true" display-tooltip-when-elided="true" name="btSave" style="translate: 0 0; margin-left: auto; -unity-text-align: upper-right;" />
<ui:Button text="modify mesh" parse-escape-sequences="true" display-tooltip-when-elided="true" name="btApplyMesh" style="white-space: nowrap; margin-left: auto; -unity-text-align: upper-right; height: auto;" />
</uie:Toolbar>
<ui:Label tabindex="-1" text="Label" parse-escape-sequences="true" display-tooltip-when-elided="true" name="infoLabel" style="visibility: hidden;" />
<ui:VisualElement style="flex-grow: 1; flex-direction: row; height: 100%;">

View File

@ -0,0 +1,122 @@
fileFormatVersion: 2
guid: e02b6f4e13ec5154f926cc25abdfcb90
ModelImporter:
serializedVersion: 22200
internalIDToNameTable: []
externalObjects:
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: StoneStep_01_Mat
second: {fileID: 2100000, guid: 94f076026d5c9d14795bb7a4215031b1, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: lambert1
second: {fileID: 2100000, guid: a1d05856298c62a4ea20cc2c8a810088, type: 2}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 1
meshes:
lODScreenPercentages:
- 0.25
- 0.125
- 0.01
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 15
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
%YAML 1.1
%TAG !u! tag:yousandi.cn,2023:
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-715305882301647664
MonoBehaviour:
m_ObjectHideFlags: 3

View File

@ -25,7 +25,7 @@ struct Attributes
float2 texcoord : TEXCOORD0;
float2 staticLightmapUV : TEXCOORD1;
float2 dynamicLightmapUV : TEXCOORD2;
float4 color : COLOR;
int2 arrayIndex : TEXCOORD3;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
@ -191,7 +191,7 @@ Varyings LitPassVertex(Attributes input)
#endif
output.positionCS = vertexInput.positionCS;
output.arraryIndex = int4(input.color * 255);
output.arraryIndex = int4(input.arrayIndex.xxxx);
return output;
}

View File

@ -3,6 +3,7 @@
"com.unity.burst": "1.8.19",
"com.unity.cinemachine": "2.10.3",
"com.unity.collab-proxy": "2.7.1",
"com.unity.formats.fbx": "4.2.1",
"com.unity.ide.rider": "3.0.35",
"com.unity.ide.visualstudio": "2.0.22",
"com.unity.ide.vscode": "1.2.5",

View File

@ -1,5 +1,12 @@
{
"dependencies": {
"com.autodesk.fbx": {
"version": "4.2.1",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.cn"
},
"com.unity.burst": {
"version": "1.8.19",
"depth": 0,
@ -50,6 +57,16 @@
"dependencies": {},
"url": "https://packages.unity.cn"
},
"com.unity.formats.fbx": {
"version": "4.2.1",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.timeline": "1.7.1",
"com.autodesk.fbx": "4.2.1"
},
"url": "https://packages.unity.cn"
},
"com.unity.ide.rider": {
"version": "3.0.35",
"depth": 0,