mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-13 06:59:46 +07:00
more readable world settings inspector
This commit is contained in:
@@ -31,6 +31,18 @@ namespace IsoTools.Internal {
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DoFoldoutHeaderGroup(bool foldout, string header, System.Action act) {
|
||||
foldout = EditorGUILayout.BeginFoldoutHeaderGroup(foldout, header);
|
||||
try {
|
||||
if ( foldout ) {
|
||||
act();
|
||||
}
|
||||
} finally {
|
||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||
}
|
||||
return foldout;
|
||||
}
|
||||
|
||||
public static void DrawWorldProperties(IsoWorld[] iso_worlds) {
|
||||
if ( iso_worlds.Length > 0 ) {
|
||||
var so = new SerializedObject(iso_worlds);
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
namespace IsoTools.Internal {
|
||||
[CustomEditor(typeof(IsoObject)), CanEditMultipleObjects]
|
||||
class IsoObjectEditor : Editor {
|
||||
static bool _showWorldSettings = false;
|
||||
|
||||
Dictionary<IsoWorld, List<IsoObject>> _isoObjects = new Dictionary<IsoWorld, List<IsoObject>>();
|
||||
Dictionary<IsoWorld, List<IsoObject>> _otherObjects = new Dictionary<IsoWorld, List<IsoObject>>();
|
||||
@@ -41,20 +42,33 @@ namespace IsoTools.Internal {
|
||||
}
|
||||
|
||||
void DrawCustomInspector() {
|
||||
if ( DrawDetachedInspector() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var iso_worlds = _isoObjects.Keys.ToArray();
|
||||
IsoEditorUtils.DrawWorldProperties(iso_worlds);
|
||||
IsoEditorUtils.DrawSelfWorldProperty(iso_worlds);
|
||||
DrawDetachedInspector();
|
||||
if ( iso_worlds.Length == 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
_showWorldSettings = IsoEditorUtils.DoFoldoutHeaderGroup(_showWorldSettings, "World Settings", () => {
|
||||
IsoEditorUtils.DrawSelfWorldProperty(iso_worlds);
|
||||
IsoEditorUtils.DrawWorldProperties(iso_worlds);
|
||||
});
|
||||
}
|
||||
|
||||
void DrawDetachedInspector() {
|
||||
bool DrawDetachedInspector() {
|
||||
var iso_object = targets.Length == 1 ? target as IsoObject : null;
|
||||
if ( iso_object && iso_object.IsActive() && !iso_object.isoWorld ) {
|
||||
var detached = iso_object && iso_object.IsActive() && !iso_object.isoWorld;
|
||||
|
||||
if ( detached ) {
|
||||
EditorGUILayout.HelpBox(
|
||||
"Detached IsoObject\nNeed to be a child of IsoWorld",
|
||||
MessageType.Warning,
|
||||
true);
|
||||
}
|
||||
|
||||
return detached;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
namespace IsoTools.Internal {
|
||||
[CustomEditor(typeof(IsoParent)), CanEditMultipleObjects]
|
||||
public class IsoParentEditor : Editor {
|
||||
static bool _showWorldSettings = false;
|
||||
|
||||
Dictionary<IsoWorld, List<IsoParent>> _isoParents = new Dictionary<IsoWorld, List<IsoParent>>();
|
||||
Dictionary<IsoWorld, List<IsoObject>> _isoObjects = new Dictionary<IsoWorld, List<IsoObject>>();
|
||||
@@ -44,9 +45,33 @@ namespace IsoTools.Internal {
|
||||
}
|
||||
|
||||
void DrawCustomInspector() {
|
||||
var iso_worlds = _isoParents.Keys.ToArray();
|
||||
IsoEditorUtils.DrawWorldProperties(iso_worlds);
|
||||
IsoEditorUtils.DrawSelfWorldProperty(iso_worlds);
|
||||
if ( DrawDetachedInspector() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var iso_worlds = _isoObjects.Keys.ToArray();
|
||||
if ( iso_worlds.Length == 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
_showWorldSettings = IsoEditorUtils.DoFoldoutHeaderGroup(_showWorldSettings, "World Settings", () => {
|
||||
IsoEditorUtils.DrawSelfWorldProperty(iso_worlds);
|
||||
IsoEditorUtils.DrawWorldProperties(iso_worlds);
|
||||
});
|
||||
}
|
||||
|
||||
bool DrawDetachedInspector() {
|
||||
var iso_parent = targets.Length == 1 ? target as IsoParent : null;
|
||||
var detached = iso_parent && iso_parent.IsActive() && !iso_parent.isoWorld;
|
||||
|
||||
if ( detached ) {
|
||||
EditorGUILayout.HelpBox(
|
||||
"Detached IsoParent\nNeed to be a child of IsoWorld",
|
||||
MessageType.Warning,
|
||||
true);
|
||||
}
|
||||
|
||||
return detached;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace IsoTools {
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
[Header("World Settings")]
|
||||
[Header("Isometric Settings")]
|
||||
[SerializeField]
|
||||
float _tileSize = DefTileSize;
|
||||
public float tileSize {
|
||||
|
||||
Reference in New Issue
Block a user