Permalink
Browse files

Begin cleaning up UI quirkiness and memory churn.

  • Loading branch information...
Jon Frisby Jon Frisby
Jon Frisby authored and Jon Frisby committed Dec 18, 2009
1 parent dcdeb3c commit e555225f58d4db4ababe88aaa299db207daffeca
Showing with 38 additions and 31 deletions.
  1. +5 −6 Package/Editor/PathComponentEditor.cs
  2. +33 −25 Source/Inspector.cs
@@ -48,14 +48,11 @@ public Transform Transform
}
+ private static string[] selector = new string[] { "Always", "Selected" };
public override void OnInspectorGUI()
{
+ EditorGUIUtility.LookLikeControls();
PathControl control;
- string[] selector;
-
- selector = new string[ 2 ];
- selector[ 0 ] = "Always";
- selector[ 1 ] = "When selected";
control = target as PathControl;
@@ -69,7 +66,9 @@ public override void OnInspectorGUI()
GUILayout.EndHorizontal();
// Standard marker size
- control.standardMarkerSize = EditorGUILayout.FloatField( "Marker size", control.standardMarkerSize );
+ GUILayout.BeginHorizontal( GUILayout.Width( PathLibrary.Resources.DefaultLeftColumnWidth ) );
+ control.standardMarkerSize = EditorGUILayout.FloatField( "Marker size", control.standardMarkerSize );
+ GUILayout.EndHorizontal();
// Collection
control.pathAsset = EditorGUILayout.ObjectField( "Collection", control.pathAsset, typeof( PathAsset ) );
View
@@ -42,23 +42,19 @@ Transform Transform
public class Inspector
{
- private static Inspector instance;
+ private static Inspector instance;
-
-
- public static Inspector Instance
- {
- get
- {
+ public static Inspector Instance
+ {
+ get
+ {
if( instance == null )
{
new Inspector();
}
- return instance;
- }
- }
-
-
+ return instance;
+ }
+ }
private bool showNetwork, showNode, showConnection, networkTags, nodeTags, connectionTags, bidirectionalConnect;
private Mesh meshReference;
@@ -95,7 +91,10 @@ public Inspector()
instance = this;
}
-
+ private static void Spacer() {
+// GUILayout.Space( 30.0f );
+ EditorGUILayout.Separator();
+ }
public void OnGUI( IInspector inspector )
{
@@ -120,7 +119,7 @@ public void OnGUI( IInspector inspector )
}
else
{
- GUILayout.Space( 30.0f );
+ Spacer();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label( "No PathBrowser selection." );
@@ -134,7 +133,7 @@ public void OnGUI( IInspector inspector )
}
}
- GUILayout.Space( 30.0f );
+ Spacer();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
@@ -147,16 +146,18 @@ public void OnGUI( IInspector inspector )
}
-
+ private Texture2D[] tagsToggle = null;
public void OnNetworkGUI( IInspector inspector )
{
Vector3 newPosition, newSize;
- Texture2D[] tagsToggle = new Texture2D[ 2 ];
+ if( tagsToggle == null )
+ {
+ tagsToggle = new Texture2D[ 2 ];
+ }
tagsToggle[ 1 ] = Resources.Tag;
- GUILayout.Space( 30.0f );
-
+ EditorGUILayout.Separator();
GUILayout.BeginHorizontal();
GUILayout.Space( 15.0f );
@@ -239,6 +240,13 @@ public void OnNetworkGUI( IInspector inspector )
if( meshReference != null )
{
+ if( GUILayout.Button( "Autosize" ) )
+ {
+ Bounds b = meshReference.bounds;
+ Editor.Instance.SelectedNetwork.Position = b.center;
+ Editor.Instance.SelectedNetwork.Size = b.size;
+ Editor.Instance.SaveCollection();
+ }
if( GUILayout.Button( "Build" ) && ( Editor.Instance.SelectedNetwork.Nodes.Length == 0 || EditorUtility.DisplayDialog( "Rebuild?", "Are you certain that you wish to rebuild the navmesh '" + Editor.Instance.SelectedNetwork.ToString() + "'?\n\nWARNING: All current data in the navmesh will be lost. This cannot be undone.", "Rebuild", "Cancel" ) ) )
{
( ( NavmeshAsset )Editor.Instance.SelectedNetwork ).Generate( meshReference );
@@ -289,7 +297,7 @@ public void OnNodeGUI( IInspector inspector )
tagsToggle[ 1 ] = Resources.Tag;
//GUILayout.Label( "", Resources.TextLineStyle, GUILayout.Height( 1 ) );
- GUILayout.Space( 30.0f );
+ Spacer();
// Node properties //
@@ -625,7 +633,7 @@ public void OnNodeGUI( IInspector inspector )
sharedTags = Resources.SharedTags( Editor.Instance.SelectedNode );
GUILayout.BeginHorizontal( /*"Toolbar"*/ );
- GUILayout.Space( 30.0f );
+ Spacer();
//GUILayout.Label( "Tags" );
//GUILayout.FlexibleSpace();
@@ -684,7 +692,7 @@ public void OnNodeGUI( IInspector inspector )
// Node tags list //
GUILayout.BeginHorizontal();
- GUILayout.Space( 30.0f );
+ Spacer();
GUILayout.BeginVertical();
if( Editor.Instance.SelectedNode.Count == 1 )
@@ -725,7 +733,7 @@ public void OnConnectionGUI( IInspector inspector )
tagsToggle[ 1 ] = Resources.Tag;
- GUILayout.Space( 30.0f );
+ Spacer();
GUILayout.BeginHorizontal();
GUILayout.Space( 15.0f );
@@ -867,7 +875,7 @@ private int OnTagListGUI( TaggedAsset taggedAsset, int selectedTag )
string addedTag;
GUILayout.BeginHorizontal();
- GUILayout.Space( 30.0f );
+ Spacer();
addedTag = Resources.PulldownPopup( "Add tag", new ArrayList( Editor.Instance.Collection.Tags ), "No tags in collection" ) as string;
if( addedTag != null )
@@ -886,7 +894,7 @@ private int OnTagListGUI( TaggedAsset taggedAsset, int selectedTag )
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
- GUILayout.Space( 30.0f );
+ Spacer();
GUILayout.BeginVertical();
if( taggedAsset.Tags.Length == 0 )
{

0 comments on commit e555225

Please sign in to comment.