/// <summary> /// Draw the inspector. /// </summary> public override void OnInspectorGUI() { #if UNITY_4_3 EditorGUIUtility.LookLikeControls(130f); #else EditorGUIUtility.labelWidth = 130f; #endif m = target as NJGMapZone; NJGEditorTools.DrawEditMap(); GUILayout.BeginHorizontal("AppToolbar"); EditorGUILayout.LabelField(new GUIContent("Zone Name Preview", ""), GUILayout.Width(130f)); GUI.contentColor = m.color; EditorGUILayout.LabelField(new GUIContent(m.zone, ""), EditorStyles.boldLabel); GUI.contentColor = Color.white; GUILayout.EndHorizontal(); string level = NJGEditorTools.DrawList("Level", NJGMapBase.instance.GetLevels(), m.level); string zone = NJGEditorTools.DrawList("Zone", NJGMapBase.instance.GetZones(m.level), m.zone); string triggerTag = EditorGUILayout.TagField("Trigger Tag", m.triggerTag); int colliderRadius = (int)EditorGUILayout.Slider("Collider Radius", m.colliderRadius, 1, 1000); bool generateOnTrigger = EditorGUILayout.Toggle("Generate On Trigger", m.generateOnTrigger); string name = "Zone - [" + NJGMapZone.list.IndexOf(m) + "] " + m.zone; if (m.name != name || m.level != level || m.zone != zone || m.triggerTag != triggerTag || m.colliderRadius != colliderRadius || m.generateOnTrigger != generateOnTrigger) { m.name = name; m.level = level; m.zone = zone; m.triggerTag = triggerTag; m.colliderRadius = colliderRadius; m.zoneCollider.radius = colliderRadius; m.generateOnTrigger = generateOnTrigger; NJGEditorTools.RegisterUndo("NJG Zone Update", m); } /*if (NJGMapBase.instance != null) * { * if (NJGMapBase.instance.atlas != null) * { * extraSpace = Mathf.Max(0f, extraSpace - 30f); * } * }*/ NJGEditorTools.DrawSeparator(); GUILayout.BeginHorizontal(); GUI.backgroundColor = Color.green; if (GUILayout.Button("Add New Zone")) { NJGMenu.AddMapZone(); } GUI.backgroundColor = Color.white; GUI.backgroundColor = Color.red; if (GUILayout.Button("Delete Zone")) { Delete(); } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); EditorGUILayout.Separator(); }
//float extraSpace = 0; /// <summary> /// Draw the Map Marker inspector. /// </summary> public override void OnInspectorGUI() { #if UNITY_4_3 EditorGUIUtility.LookLikeControls(120f); #else EditorGUIUtility.labelWidth = 120f; #endif m = target as NJGMapItem; NJGEditorTools.DrawEditMap(); if (UIMiniMapBase.inst != null) { string info = "Map Position: " + UIMiniMapBase.inst.WorldToMap(m.cachedTransform.position).ToString(); GUI.color = Color.cyan; EditorGUILayout.LabelField(info, EditorStyles.boldLabel); GUI.color = Color.white; } NJGEditorTools.DrawSeparator(); int type = 0; if (NJG.NJGMapBase.instance != null) { type = NJGEditorTools.DrawList("Marker Type", NJG.NJGMapBase.instance.mapItemTypes, m.type); } string tooltip = "You can use to display name + anything else you want.\nFor example: Ore [FF0000]+100 Mineral[-]"; string content = ""; if (type != 0) { EditorGUILayout.LabelField(new GUIContent("Tooltip Content", tooltip)); content = EditorGUILayout.TextArea(m.content); GUI.backgroundColor = Color.gray; EditorGUILayout.HelpBox(tooltip, MessageType.Info); GUI.backgroundColor = Color.white; } //m.drawDirection = EditorGUILayout.Toggle("Draw Direction Line", m.drawDirection); bool revealFOW = EditorGUILayout.Toggle("Reveal FOW", m.revealFOW); GUI.enabled = m.revealFOW; int revealDistance = (int)EditorGUILayout.Slider("Reveal Distance", m.revealDistance, 0, 100); GUI.enabled = true; GUI.backgroundColor = Color.gray; EditorGUILayout.HelpBox("Overrides Global Reveal Distance, if value = 0 it will use the global reveal distance.", MessageType.Info); GUI.backgroundColor = Color.white; /*if (NJG.NJGMapBase.instance != null) * { * if (NJG.NJGMapBase.instance.atlas != null) * { * GUILayout.BeginHorizontal(); * EditorGUILayout.LabelField("Icon Sprite", GUILayout.Width(100.0f)); * * // Draw sprite preview. * Material mat = NJG.NJGMapBase.instance.atlas.spriteMaterial; * * if (mat != null) * { * Texture2D tex = mat.mainTexture as Texture2D; * * if (tex != null) * { * UIAtlas.Sprite sprite = m.sprite; * Rect rect = sprite.outer; * if (NJG.NJGMapBase.instance.atlas.coordinates == UIAtlas.Coordinates.Pixels) * { * rect = NGUIMath.ConvertToTexCoords(rect, tex.width, tex.height); * } * * GUILayout.Space(4f); * GUILayout.Label("", GUILayout.Height(NJGMapBase.instance.iconSize)); * GUI.color = m.color; * DrawSprite(tex, rect, null, false, NJGMapBase.instance.iconSize); * GUI.color = Color.white; * * extraSpace = NJGMapBase.instance.iconSize * (float)sprite.outer.height / sprite.outer.width; * } * * } * GUILayout.EndHorizontal(); * * extraSpace = Mathf.Max(0f, extraSpace - 30f); * //GUILayout.Space(extraSpace); * } * EditorGUILayout.Separator(); * }*/ EditorGUILayout.Separator(); if (m.type != type || m.content != content || m.revealFOW != revealFOW || m.revealDistance != revealDistance) { m.type = type; m.content = content; m.revealFOW = revealFOW; m.revealDistance = revealDistance; NJGEditorTools.RegisterUndo("Map Item Properties", m); } }
/// <summary> /// Draw the inspector. /// </summary> public override void OnInspectorGUI() { #if UNITY_4_3 EditorGUIUtility.LookLikeControls(130f); #else EditorGUIUtility.labelWidth = 130f; #endif m = target as MapZone; if (renderLayers == null) { renderLayers = serializedObject.FindProperty("renderLayers"); } NJGEditorTools.DrawEditMap(); GUILayout.BeginHorizontal("AppToolbar"); EditorGUILayout.LabelField(new GUIContent("Zone Name Preview", ""), GUILayout.Width(130f)); GUI.contentColor = m.color; EditorGUILayout.LabelField(new GUIContent(m.zone, ""), EditorStyles.boldLabel); GUI.contentColor = Color.white; GUILayout.EndHorizontal(); string level = NJGEditorTools.DrawList("Level", NJGMap.instance.GetLevels(), m.level); string zone = NJGEditorTools.DrawList("Zone", NJGMap.instance.GetZones(m.level), m.zone); string triggerTag = EditorGUILayout.TagField("Trigger Tag", m.triggerTag); int colliderRadius = (int)EditorGUILayout.Slider("Collider Radius", m.colliderRadius, 1, 1000); GUILayout.BeginHorizontal(); bool generateOnTrigger = EditorGUILayout.Toggle("Render On Trigger", m.generateOnTrigger, GUILayout.Width(140f)); GUI.contentColor = generateOnTrigger ? Color.cyan : Color.gray; EditorGUILayout.LabelField("Render the map when the target collides with this zone."); GUI.contentColor = Color.white; GUILayout.EndHorizontal(); GUI.enabled = generateOnTrigger; GUILayout.BeginHorizontal(); bool useZoneBounds = EditorGUILayout.Toggle("Use Zone Bounds", m.useZoneBounds, GUILayout.Width(140f)); GUI.contentColor = useZoneBounds ? Color.cyan : Color.gray; EditorGUILayout.LabelField("Use this zone bounds to render the map."); GUI.contentColor = Color.white; GUILayout.EndHorizontal(); EditorGUILayout.PropertyField(renderLayers, new GUIContent("Render Layers", "Which layers are going to be used for rendering.")); GUILayout.BeginHorizontal(); float zoom = EditorGUILayout.Slider(new GUIContent("Zoom", "Custom zoom level"), m.zoom, m.minZoom, m.maxZoom); if (m.zoom != zoom) { m.zoom = Mathf.Clamp(zoom, m.minZoom, m.maxZoom); NJGEditorTools.RegisterUndo("NJGZone Settings", m); } GUILayout.EndHorizontal(); GUI.enabled = true; string name = "Zone - [" + MapZone.list.IndexOf(m) + "] " + m.zone; if (m.name != name || m.level != level || m.zone != zone || m.triggerTag != triggerTag || m.colliderRadius != colliderRadius || m.generateOnTrigger != generateOnTrigger || m.useZoneBounds != useZoneBounds) { m.name = name; m.level = level; m.zone = zone; m.triggerTag = triggerTag; m.colliderRadius = colliderRadius; m.zoneCollider.radius = colliderRadius; m.generateOnTrigger = generateOnTrigger; m.useZoneBounds = useZoneBounds; NJGEditorTools.RegisterUndo("NJG Zone Update", m); } /*if (NJGMap.instance != null) * { * if (NJGMap.instance.atlas != null) * { * extraSpace = Mathf.Max(0f, extraSpace - 30f); * } * }*/ EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); GUI.backgroundColor = Color.green; if (GUILayout.Button("Add New Zone")) { NJGMenu.AddMapZone(); } GUI.backgroundColor = Color.white; GUI.backgroundColor = Color.red; if (GUILayout.Button("Delete Zone")) { Delete(); } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); EditorGUILayout.Separator(); }