Restructured files and folders.

This commit is contained in:
max
2019-11-10 00:03:44 +01:00
parent 13de8b8e2a
commit e7ce849108
118 changed files with 3009 additions and 30 deletions

View File

@ -0,0 +1,106 @@
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using MA_Editor;
using MA_Editor.Grid;
namespace MA_TextureAtlasserPro
{
[System.Serializable]
public class MA_TextureAtlasserProAtlas : ScriptableObject
{
//Editor
public List<MA_TextureAtlasserProQuad> textureQuads;
public MA_TextureAtlasserProQuad selectedTextureQuad;
private Rect editorWorkRect;
public bool showTextures = false;
public MA_TextureAtlasserProExportSettings exportSettings;
//Data
public Vector2 textureAtlasSize;
public List<MA_TextureGroupRegistration> textureGroupRegistration;
public void CreateAtlas(string name, Vector2 size)
{
this.name = name;
textureAtlasSize = size;
}
public void UpdateTextureQuads(Event e, Rect editorViewRect, Vector2 zoomCoordsOrigin, bool useEvents)
{
textureAtlasSize.x = Mathf.Clamp(textureAtlasSize.x, 128, 8192);
textureAtlasSize.y = Mathf.Clamp(textureAtlasSize.y, 128, 8192);
editorWorkRect = new Rect(Vector2.zero - zoomCoordsOrigin, textureAtlasSize);
GUI.backgroundColor = new Color(0, 0, 0, 0.1f);
GUI.Box(editorWorkRect, "");
GUI.Box(new Rect(editorWorkRect.x, editorWorkRect.y - 25, editorWorkRect.width, 20), this.name);
GUI.backgroundColor = Color.white;
MA_Editor.Grid.Grid.DrawZoomableGrid(editorWorkRect, 64, new Color(0, 0, 0, 0.1f), zoomCoordsOrigin);
if(textureQuads != null)
{
foreach (MA_TextureAtlasserProQuad ts in textureQuads)
{
ts.UpdateTextureQuad(e, editorViewRect, editorWorkRect, zoomCoordsOrigin, useEvents, showTextures);
}
}
if(useEvents)
ProcessEvents(e, zoomCoordsOrigin, useEvents);
EditorUtility.SetDirty(this);
}
private void ProcessEvents(Event e, Vector2 zoomCoordsOrigin, bool useEvents)
{
if(e.button == 0)
{
if(e.type == EventType.MouseDown)
{
DeselectQuad();
if(textureQuads != null)
{
foreach(MA_TextureAtlasserProQuad quad in textureQuads)
{
if(new Rect((int)quad.guiRect.x - zoomCoordsOrigin.x, (int)quad.guiRect.y - zoomCoordsOrigin.y, quad.guiRect.width, quad.guiRect.height).Contains(e.mousePosition))
{
SelectQuad(quad);
e.Use();
}
}
}
}
}
}
private void SelectQuad(MA_TextureAtlasserProQuad quad)
{
if(selectedTextureQuad)
{
DeselectQuad();
}
quad.isSelected = true;
selectedTextureQuad = quad;
}
private void DeselectQuad()
{
if(textureQuads != null)
{
foreach(MA_TextureAtlasserProQuad quad in textureQuads)
{
quad.isSelected = false;
}
selectedTextureQuad = null;
}
}
}
}
#endif

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 892d1a7aeb4cc284dbf62e69e125db52
timeCreated: 1519392859
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,63 @@
using UnityEngine;
using System.Collections;
using MA_Texture;
namespace MA_TextureAtlasserPro
{
[System.Serializable]
public class MA_TextureAtlasserProExportSettings : ScriptableObject
{
[HideInInspector]
public bool canModify = true;
public ModelExportSettings modelExportSettings = new ModelExportSettings();
public TextureExportSettings textureExportSettings = new TextureExportSettings();
}
[System.Serializable]
public class ModelExportSettings
{
[Header("Model settings:")]
public ModelFormat modelFormat = ModelFormat.Obj;
public bool replaceModel = false;
public bool uvFlipY = true;
public int uvChannel = 0;
public bool uvWrap = true;
}
[System.Serializable]
public class TextureExportSettings
{
[Header("Texture settings:")]
public TextureFormat textureFormat = TextureFormat.Png;
public TextureType textureType = TextureType.Default;
public MA_TextureUtils.TextureScaleMode textureScaleMode = MA_TextureUtils.TextureScaleMode.Bilinear;
}
public enum ExportPreset
{
Custom,
Default,
Sprites,
ReplaceObjMeshes
}
public enum ModelFormat
{
None,
Obj
}
public enum TextureFormat
{
None,
Png
}
public enum TextureType
{
Default,
Sprite,
SpriteSliced
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f8eb652100ecb804dae35d0cca727164
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,170 @@
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using MA_Editor;
namespace MA_TextureAtlasserPro
{
[System.Serializable]
public class MA_TextureAtlasserProQuad : ScriptableObject
{
//Editor
public bool isSelected = false; //Is this thing selected
public Rect rect; //The internal rect
public Rect guiRect; //The visual clamped and snapped rect
public bool debugMode = false; //Are we debugging, for showing some other things (like handles)
private bool isDragging = false; //Are we editing the pos or size
private bool isDraggingRectHeigt = false;
public Rect dragRectHeight;
private bool isDraggingRectWidth = false;
public Rect dragRectWidth;
private bool isDraggingRectPos = false;
public Rect dragRectPos;
//Data
public List<MA_TextureGroup> textureGroups;
public List<Mesh> meshes;
public void UpdateTextureQuad(Event e, Rect editorViewRect, Rect editorWorkRect, Vector2 zoomCoordsOrigin, bool useEvents, bool showTexture)
{
if(isSelected)
{
GUI.backgroundColor = new Color(0.05f, 0.05f, 0.05f, 0.75f);
}
else
{
GUI.backgroundColor = new Color(1, 1, 1, 0.5f);
}
//Clamp and snap the guiRect
guiRect = new Rect(Mathf.RoundToInt(rect.x / 32) * 32, Mathf.RoundToInt(rect.y / 32) * 32, Mathf.RoundToInt(rect.width / 32) * 32, Mathf.RoundToInt(rect.height / 32) * 32);
//Draw the quad background
if(showTexture && textureGroups != null && textureGroups.Count > 0 && textureGroups[0].texture != null)
GUI.DrawTexture(new Rect(guiRect.x - zoomCoordsOrigin.x, guiRect.y - zoomCoordsOrigin.y, guiRect.width, guiRect.height), textureGroups[0].texture, ScaleMode.StretchToFill);
else
GUI.Box(new Rect(guiRect.x - zoomCoordsOrigin.x, guiRect.y - zoomCoordsOrigin.y, guiRect.width, guiRect.height), "");
GUILayout.BeginArea(new Rect(guiRect.x - zoomCoordsOrigin.x, guiRect.y - zoomCoordsOrigin.y, guiRect.width, guiRect.height));
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
var tempColor = GUI.backgroundColor;
GUI.backgroundColor = new Color(1, 1, 1, 0.7f);
GUILayout.Label(" " + this.name + " ", GUI.skin.box);
GUI.backgroundColor = tempColor;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
if(isSelected)
{
dragRectPos = new Rect(guiRect.width / 2 + guiRect.x - zoomCoordsOrigin.x - 16, guiRect.height / 2 + guiRect.y - zoomCoordsOrigin.y - 16, 32, 32);
dragRectWidth = new Rect(guiRect.width + guiRect.x - zoomCoordsOrigin.x - 16, guiRect.height / 2 + guiRect.y - zoomCoordsOrigin.y - 32, 16, 64);
dragRectHeight = new Rect(guiRect.width / 2 + guiRect.x - zoomCoordsOrigin.x - 32, guiRect.height + guiRect.y - zoomCoordsOrigin.y - 16, 64, 16);
if(debugMode)
{
GUI.Box(new Rect(dragRectPos.x - guiRect.x + zoomCoordsOrigin.x, dragRectPos.y - guiRect.y + zoomCoordsOrigin.y, dragRectPos.width, dragRectPos.height), "");
GUI.Box(new Rect(dragRectWidth.x - guiRect.x + zoomCoordsOrigin.x, dragRectWidth.y - guiRect.y + zoomCoordsOrigin.y, dragRectWidth.width, dragRectWidth.height), "");
GUI.Box(new Rect(dragRectHeight.x - guiRect.x + zoomCoordsOrigin.x, dragRectHeight.y - guiRect.y + zoomCoordsOrigin.y, dragRectHeight.width, dragRectHeight.height), "");
}
}
else
{
}
GUI.backgroundColor = Color.white;
GUILayout.EndArea();
if(useEvents)
ProcessEvents(e, editorViewRect, editorWorkRect, zoomCoordsOrigin);
EditorUtility.SetDirty(this);
}
void ProcessEvents(Event e, Rect editorViewRect, Rect editorWorkRect, Vector2 zoomCoordsOrigin)
{
if(isSelected)
{
//Right mouse
if(e.button == 0)
{
//Mouse drag
if(e.type == EventType.MouseDrag)
{
if(dragRectPos.Contains(e.mousePosition) && isDragging == false)
{
//Debug.Log("P");
isDragging = true;
isDraggingRectPos = true;
}
if(dragRectWidth.Contains(e.mousePosition) && isDragging == false)
{
//Debug.Log("W");
isDragging = true;
isDraggingRectWidth = true;
}
if(dragRectHeight.Contains(e.mousePosition) && isDragging == false)
{
//Debug.Log("W");
isDragging = true;
isDraggingRectHeigt = true;
}
if(isDraggingRectPos)
{
rect.x += e.delta.x;
rect.y += e.delta.y;
}
if(isDraggingRectWidth)
{
rect.width += e.delta.x;
}
if(isDraggingRectHeigt)
{
rect.height += e.delta.y;
}
//Clamp rect with min/max values to stay inside the workrect
rect.width = Mathf.Clamp(rect.width, 64, editorWorkRect.width);
rect.height = Mathf.Clamp(rect.height, 64, editorWorkRect.height);
rect.x = Mathf.Clamp(rect.x, 0, editorWorkRect.width - rect.width);
rect.y = Mathf.Clamp(rect.y, 0, editorWorkRect.height - rect.height);
if(isDragging)
e.Use();
}
}
//Deselect on mouse up
if(e.type == EventType.MouseUp)
{
StopDragging();
}
}
//Stop if we are not selected
else if(!isSelected && isDragging)
{
StopDragging();
}
}
private void StopDragging()
{
//Debug.Log("StopDragging");
isDragging = false;
isDraggingRectPos = false;
isDraggingRectWidth = false;
isDraggingRectHeigt = false;
}
public void SetDebugMode(bool isDebugging)
{
debugMode = isDebugging;
}
}
}
#endif

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 16ad07a78750c7644b710e19e1a23d4a
timeCreated: 1519392859
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,40 @@
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using MA_Editor;
namespace MA_TextureAtlasserPro
{
[System.Serializable]
public class MA_TextureAtlasserProSettings : ScriptableObject
{
[Header("Hotkeys:")]
public bool useHotkeys = false;
public EventModifiers modifierKey = EventModifiers.Alt;
public KeyCode addQuadHotKey = KeyCode.Q;
public KeyCode removeQuadHotKey = KeyCode.R;
public KeyCode duplicateHotKey = KeyCode.D;
public KeyCode zoomInHotKey = KeyCode.Equals;
public KeyCode zoomOutHotKey = KeyCode.Minus;
[Header("Duplication:")]
public bool copySelectedQuadData = true;
public string duplicatedQuadNamePrefix = "new ";
[Header("Selection")]
public bool autoFocus = true;
public bool GetHotKey(Event e, KeyCode shortKey)
{
if (e.type == EventType.KeyDown && e.modifiers == modifierKey && e.keyCode == shortKey)
{
return true;
}
return false;
}
}
}
#endif

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73f5e66553c13034e9b894ef2cc31b66
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,21 @@
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MA_TextureAtlasserPro
{
[System.Serializable]
public class MA_TextureGroup
{
public string name;
public Texture texture = null;
}
[System.Serializable]
public class MA_TextureGroupRegistration
{
public string name;
}
}
#endif

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ad995f47c542a7f4d9148cd7d5c9cfda
timeCreated: 1520097393
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: