Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DefaultSortingMode to ST2U Editor props #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void ApplyTemplateToObject(XElement xObject)
}
}

public void ApplyDefaultSettings()
virtual public void ApplyDefaultSettings()
{
var settings = ST2USettings.GetOrCreateST2USettings();
m_PixelsPerUnit = settings.PixelsPerUnit;
Expand Down Expand Up @@ -174,7 +174,7 @@ protected void AssignUnityLayer(SuperCustomProperties properties)
}
}

private void WrapImportContext(AssetImportContext ctx)
virtual protected void WrapImportContext(AssetImportContext ctx)
{
var settings = ST2USettings.GetOrCreateST2USettings();
settings.RefreshCustomObjectTypes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class TmxAssetImporter : TiledAssetImporter
public bool TilesAsObjects { get { return m_TilesAsObjects; } }

[SerializeField]
private SortingMode m_SortingMode = SortingMode.Stacked;
private SortingMode m_SortingMode;
public SortingMode SortingMode { get { return m_SortingMode; } }

[SerializeField]
Expand All @@ -44,6 +44,23 @@ public partial class TmxAssetImporter : TiledAssetImporter
[SerializeField]
private List<SuperTileset> m_InternalTilesets;

override public void ApplyDefaultSettings()
{
base.ApplyDefaultSettings();
var settings = ST2USettings.GetOrCreateST2USettings();
m_SortingMode = settings.SortingMode;
EditorUtility.SetDirty(this);
}

override protected void WrapImportContext(UnityEditor.AssetImporters.AssetImportContext ctx) {
base.WrapImportContext(ctx);

if ((int)m_SortingMode == 0)
{
m_SortingMode = SuperImportContext.Settings.SortingMode;
}
}

protected override void InternalOnImportAsset()
{
base.InternalOnImportAsset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public int EdgesPerEllipse
private int m_AnimationFramerate = 20;
public int AnimationFramerate { get { return m_AnimationFramerate; } }

[SerializeField]
private SortingMode m_SortingMode = SortingMode.Stacked;
public SortingMode SortingMode { get { return m_SortingMode; } }

[SerializeField]
private Material m_DefaultMaterial = null;
public Material DefaultMaterial { get { return m_DefaultMaterial; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class SettingsContent
public static readonly GUIContent m_PixelsPerUnitContent = new GUIContent("Default Pixels Per Unit", "How many pixels in the sprite correspond to one unit in the world. (Default Setting)");
public static readonly GUIContent m_EdgesPerEllipseContent = new GUIContent("Default Edges Per Ellipse", "How many edges to use when appromixating ellipse/circle colliders. (Default Setting)");
public static readonly GUIContent m_AnimationFramerateContent = new GUIContent("Animation Framerate", "How many frames per second for tile animations.");
public static readonly GUIContent m_SortingModeContent = new GUIContent("Default Sorting Mode", "Set to the default sorting mode you want to be used in newly imported .tmx files imported by SuperTiled2Unity.");
public static readonly GUIContent m_DefaultMaterialContent = new GUIContent("Default Material", "Set to the material you want to use for sprites and tiles imported by SuperTiled2Unity. Leave empy to use built-in sprite material.");
public static readonly GUIContent m_MaterialMatchingsContent = new GUIContent("Material Matchings", "Match these materials by Tiled Layer names.");
public static readonly GUIContent m_ObjectTypesXmlContent = new GUIContent("Object Types Xml", "Set to an Object Types Xml file exported from Tiled Object Type Editor.");
Expand Down Expand Up @@ -123,6 +124,7 @@ private void DoGuiSettings()
{
var ppuProperty = m_S2TUSettingsObject.FindProperty("m_PixelsPerUnit");
var edgesProperty = m_S2TUSettingsObject.FindProperty("m_EdgesPerEllipse");
var sortingModeProperty = m_S2TUSettingsObject.FindProperty("m_SortingMode");
var materialProperty = m_S2TUSettingsObject.FindProperty("m_DefaultMaterial");
var animationPrpoerty = m_S2TUSettingsObject.FindProperty("m_AnimationFramerate");

Expand All @@ -144,6 +146,9 @@ private void DoGuiSettings()
edgesProperty.intValue = Mathf.Clamp(edgesProperty.intValue, 6, 256);
}

// Default Sorting Mode
EditorGUILayout.PropertyField(sortingModeProperty, SettingsContent.m_SortingModeContent);

// Default Material
EditorGUILayout.PropertyField(materialProperty, SettingsContent.m_DefaultMaterialContent);
EditorGUILayout.Space();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public enum SortingMode
{
Stacked = 0,
CustomSortAxis,
Stacked = 10,
CustomSortAxis = 1,
}
}