private void CheckNullControl() { OnlineMapsControlBase[] controls = api.GetComponents <OnlineMapsControlBase>(); if (controls != null && controls.Length != 0) { return; } EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.HelpBox("Problem detected:\nCan not find OnlineMaps Control component.", MessageType.Error); if (GUILayout.Button("Add Control")) { GenericMenu menu = new GenericMenu(); Type[] types = api.GetType().Assembly.GetTypes(); foreach (Type t in types) { if (t.IsSubclassOf(typeof(OnlineMapsControlBase))) { if (t == typeof(OnlineMapsControlBase2D) || t == typeof(OnlineMapsControlBase3D)) { continue; } string fullName = t.FullName.Substring(10); int controlIndex = fullName.IndexOf("Control"); fullName = fullName.Insert(controlIndex, " "); int textureIndex = fullName.IndexOf("Texture"); if (textureIndex > 0) { fullName = fullName.Insert(textureIndex, " "); } menu.AddItem(new GUIContent(fullName), false, data => { Type ct = data as Type; api.gameObject.AddComponent(ct); pTarget.enumValueIndex = ct == typeof(OnlineMapsTileSetControl) ? (int)OnlineMapsTarget.tileset : (int)OnlineMapsTarget.texture; Repaint(); }, t); } } menu.ShowAsContext(); } EditorGUILayout.EndVertical(); }
private void CheckNullControl() { OnlineMapsControlBase[] controls = map.GetComponents <OnlineMapsControlBase>(); if (controls != null && controls.Length != 0) { return; } EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.HelpBox("Problem detected:\nCan not find OnlineMaps Control component.", MessageType.Error); if (GUILayout.Button("Add Control")) { GenericMenu menu = new GenericMenu(); Type[] types = map.GetType().Assembly.GetTypes(); foreach (Type t in types) { if (t.IsSubclassOf(typeof(OnlineMapsControlBase)) && !t.IsAbstract) { string fullName = t.FullName; if (fullName.StartsWith("OnlineMaps")) { fullName = fullName.Substring(10); } int controlIndex = fullName.IndexOf("Control"); fullName = fullName.Insert(controlIndex, " "); int textureIndex = fullName.IndexOf("Texture"); if (textureIndex > 0) { fullName = fullName.Insert(textureIndex, " "); } menu.AddItem(new GUIContent(fullName), false, data => { Type ct = data as Type; map.gameObject.AddComponent(ct); Repaint(); }, t); } } menu.ShowAsContext(); } EditorGUILayout.EndVertical(); }
public override void OnInspectorGUI() { DrawToolbarGUI(); bool dirty = DrawGeneralGUI(); EditorGUILayout.BeginVertical(GUI.skin.box); showMarkers = Foldout(showMarkers, "2D Markers"); if (showMarkers) { DrawMarkersGUI(); } EditorGUILayout.EndVertical(); if (api.target == OnlineMapsTarget.texture) { EditorGUILayout.BeginVertical(GUI.skin.box); showCreateTexture = Foldout(showCreateTexture, "Create texture"); if (showCreateTexture) { DrawCreateTextureGUI(ref dirty); } EditorGUILayout.EndVertical(); } EditorGUILayout.BeginVertical(GUI.skin.box); showAdvanced = Foldout(showAdvanced, "Advanced"); if (showAdvanced) { DrawAdvancedGUI(ref dirty); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(GUI.skin.box); showTroubleshooting = Foldout(showTroubleshooting, "Troubleshooting"); if (showTroubleshooting) { DrawTroubleshootingGUI(ref dirty); } EditorGUILayout.EndVertical(); OnlineMapsControlBase[] controls = api.GetComponents <OnlineMapsControlBase>(); if (controls == null || controls.Length == 0) { EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.HelpBox("Problem detected:\nCan not find OnlineMaps Control component.", MessageType.Error); if (GUILayout.Button("Add Control")) { GenericMenu menu = new GenericMenu(); Type[] types = api.GetType().Assembly.GetTypes(); foreach (Type t in types) { if (t.IsSubclassOf(typeof(OnlineMapsControlBase))) { if (t == typeof(OnlineMapsControlBase2D) || t == typeof(OnlineMapsControlBase3D)) { continue; } string fullName = t.FullName.Substring(10); int controlIndex = fullName.IndexOf("Control"); fullName = fullName.Insert(controlIndex, " "); int textureIndex = fullName.IndexOf("Texture"); if (textureIndex > 0) { fullName = fullName.Insert(textureIndex, " "); } menu.AddItem(new GUIContent(fullName), false, data => { Type ct = data as Type; api.gameObject.AddComponent(ct); api.target = (ct == typeof(OnlineMapsTileSetControl)) ? OnlineMapsTarget.tileset : OnlineMapsTarget.texture; Repaint(); }, t); } } menu.ShowAsContext(); } EditorGUILayout.EndVertical(); } if (dirty) { EditorUtility.SetDirty(api); Repaint(); } }