5 Commits
Author SHA1 Message Date
max 41e78763bf Merge pull request #13 from yany79/clear-atlas-texture-before-combining
Bugfix: Clear the atlas texture before combining quads.
2026-09-14 11:37:04 +02:00
max df397717a4 Merge pull request #14 from yany79/guard-texture-reinitialize-for-older-unity
Use Texture2D.Reinitialize on Unity 2021.2 and newer.
2026-09-14 11:36:31 +02:00
Juke 6598d8243b Use Texture2D.Reinitialize on Unity 2021.2 and newer. 2026-09-09 16:54:44 +02:00
Juke 3ad2a3cf67 Bugfix: Clear the atlas texture before combining quads. 2026-09-09 16:46:21 +02:00
max b2a005356d Update MA_TextureAtlasserProInspectorView.cs 2022-11-09 20:51:48 +01:00
3 changed files with 18 additions and 1 deletions

No files matched your search

@@ -521,6 +521,13 @@ namespace MA_TextureAtlasserPro
name = atlas.name + "_" + atlas.textureGroupRegistration[i].name name = atlas.name + "_" + atlas.textureGroupRegistration[i].name
}; };
//A new Texture2D is uninitialised, and MA_Combine2D only writes inside each quad's
//guiRect, so every texel no quad covers keeps whatever was left in the buffer. That
//garbage is opaque enough to survive an alpha cutoff and bleeds into the quads
//through the mip chain, so clear the atlas to transparent black before combining.
newTexture.SetPixels32(new Color32[newTexture.width * newTexture.height]);
newTexture.Apply();
foreach (MA_TextureAtlasserProQuad q in atlas.textureQuads) foreach (MA_TextureAtlasserProQuad q in atlas.textureQuads)
{ {
if (q.textureGroups != null && q.textureGroups[i].texture != null) if (q.textureGroups != null && q.textureGroups[i].texture != null)
@@ -13,6 +13,7 @@ namespace MA_TextureAtlasserPro
private MA_TextureAtlasserProQuad lastSelectedQuad; private MA_TextureAtlasserProQuad lastSelectedQuad;
private bool isEditing = false; private bool isEditing = false;
private GUIStyle labelStyle = new GUIStyle(GUI.skin.label); private GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
private Vector2 scrollPos = Vector2.zero;
public MA_TextureAtlasserProInspectorView(MA_TextureAtlasserProWindow currentEditorWindow, string title) : base(currentEditorWindow, title) public MA_TextureAtlasserProInspectorView(MA_TextureAtlasserProWindow currentEditorWindow, string title) : base(currentEditorWindow, title)
{ {
@@ -37,6 +38,10 @@ namespace MA_TextureAtlasserPro
} }
GUILayout.BeginArea(editorViewRect, EditorStyles.helpBox); GUILayout.BeginArea(editorViewRect, EditorStyles.helpBox);
using (var scrollViewScope = new EditorGUILayout.ScrollViewScope(scrollPos, false, false))
{
scrollPos = scrollViewScope.scrollPosition;
GUILayout.BeginVertical(GUILayout.ExpandWidth(true)); GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
GUILayout.Label("Quad Name"); GUILayout.Label("Quad Name");
@@ -90,6 +95,7 @@ namespace MA_TextureAtlasserPro
SerializedObject serializedObject = new SerializedObject(curWindow.textureAtlas.selectedTextureQuad); SerializedObject serializedObject = new SerializedObject(curWindow.textureAtlas.selectedTextureQuad);
serializedObject.Update(); serializedObject.Update();
if (curWindow.textureAtlas.selectedTextureQuad.modelGroups != null) if (curWindow.textureAtlas.selectedTextureQuad.modelGroups != null)
{ {
SerializedProperty modelGroupsSP = serializedObject.FindProperty("modelGroups"); SerializedProperty modelGroupsSP = serializedObject.FindProperty("modelGroups");
@@ -164,7 +170,7 @@ namespace MA_TextureAtlasserPro
GUILayout.Label("x " + curWindow.textureAtlas.selectedTextureQuad.guiRect.x.ToString() + ", y " + curWindow.textureAtlas.selectedTextureQuad.guiRect.y.ToString()); GUILayout.Label("x " + curWindow.textureAtlas.selectedTextureQuad.guiRect.x.ToString() + ", y " + curWindow.textureAtlas.selectedTextureQuad.guiRect.y.ToString());
GUILayout.Label("w " + curWindow.textureAtlas.selectedTextureQuad.guiRect.width.ToString() + ", h " + curWindow.textureAtlas.selectedTextureQuad.guiRect.height.ToString(), labelStyle); GUILayout.Label("w " + curWindow.textureAtlas.selectedTextureQuad.guiRect.width.ToString() + ", h " + curWindow.textureAtlas.selectedTextureQuad.guiRect.height.ToString(), labelStyle);
}
GUILayout.EndVertical(); GUILayout.EndVertical();
GUILayout.EndArea(); GUILayout.EndArea();
} }
@@ -122,7 +122,11 @@ namespace MA_Texture
} }
#if UNITY_2021_2_OR_NEWER
texture.Reinitialize(newWidth, newHeight);
#else
texture.Resize(newWidth, newHeight); texture.Resize(newWidth, newHeight);
#endif
texture.SetPixels(newColors); texture.SetPixels(newColors);
texture.Apply(); texture.Apply();