8 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
max 05b4ea9f80 Update MA_TextureAtlasserProInspectorView.cs
Fix 2020.2+ mesh input fields.
2021-04-08 23:51:05 +02:00
max 0933abdace Update MA_TextureAtlasserProInspectorView.cs 2021-04-03 17:09:27 +02:00
max 5d112a2ced Update MA_TextureAtlasserProInspectorView.cs
Dirty fix for 2020.2+ versions with reordable list.
2021-04-02 17:31:24 +02:00
3 changed files with 159 additions and 139 deletions
@@ -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");
@@ -109,8 +115,11 @@ namespace MA_TextureAtlasserPro
} }
SerializedProperty meshesSP = modelGroupsSP.GetArrayElementAtIndex(i).FindPropertyRelative("meshes"); SerializedProperty meshesSP = modelGroupsSP.GetArrayElementAtIndex(i).FindPropertyRelative("meshes");
#if UNITY_2020_2_OR_NEWER
meshesSP.isExpanded = EditorGUILayout.Foldout(meshesSP.isExpanded, "Meshes", true);
#else
EditorGUILayout.PropertyField(meshesSP, false, GUILayout.ExpandWidth(false), GUILayout.MaxWidth(editorViewRect.width * 0.5f)); EditorGUILayout.PropertyField(meshesSP, false, GUILayout.ExpandWidth(false), GUILayout.MaxWidth(editorViewRect.width * 0.5f));
#endif
if (meshesSP.isExpanded) if (meshesSP.isExpanded)
{ {
for (int j = 0; j < curWindow.textureAtlas.selectedTextureQuad.modelGroups[i].meshes.Count; j++) for (int j = 0; j < curWindow.textureAtlas.selectedTextureQuad.modelGroups[i].meshes.Count; j++)
@@ -161,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();