private void OnMaterialsGUI(ref bool dirty) { bool showMaterialGroup = showMaterials; if (showMaterialGroup) { EditorGUILayout.BeginVertical(GUI.skin.box); } if (buildings.materials == null) { buildings.materials = new OnlineMapsBuildingMaterial[0]; } showMaterials = OnlineMapsEditor.Foldout(showMaterials, "Materials"); if (showMaterials) { int deleteIndex = -1; for (int i = 0; i < buildings.materials.Length; i++) { OnlineMapsBuildingMaterial material = buildings.materials[i]; EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("X", GUILayout.ExpandWidth(false))) { deleteIndex = i; } GUILayout.Label((i + 1) + ": "); EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); material.wall = EditorGUILayout.ObjectField("Wall material", material.wall, typeof(Material), false) as Material; material.roof = EditorGUILayout.ObjectField("Roof material", material.roof, typeof(Material), false) as Material; material.scale = EditorGUILayout.Vector2Field("Scale", material.scale); if (EditorGUI.EndChangeCheck()) { dirty = true; } } if (deleteIndex != -1) { ArrayUtility.RemoveAt(ref buildings.materials, deleteIndex); dirty = true; } if (GUILayout.Button("Add Material")) { ArrayUtility.Add(ref buildings.materials, new OnlineMapsBuildingMaterial()); dirty = true; } } if (showMaterialGroup) { EditorGUILayout.EndVertical(); } }
public override void OnInspectorGUI() { bool dirty = false; OnlineMapsControlBase control = target as OnlineMapsControlBase; OnlineMapsControlBaseEditor.CheckMultipleInstances(control, ref dirty); OnlineMaps api = OnlineMapsControlBaseEditor.GetOnlineMaps(control); OnlineMapsControlBaseEditor.CheckTarget(api, OnlineMapsTarget.texture, ref dirty); #if !IGUI if (GUILayout.Button("Enable iGUI")) { OnlineMapsEditor.AddCompilerDirective("IGUI"); } #else base.OnInspectorGUI(); #endif if (dirty) { EditorUtility.SetDirty(api); Repaint(); } }
private void DrawProvider(ref bool allowCreate) { EditorGUI.BeginChangeCheck(); providerIndex = EditorGUILayout.Popup("Provider", providerIndex, providersTitle); if (EditorGUI.EndChangeCheck()) { activeMapType = providers[providerIndex].types[0]; } if (activeMapType.isCustom) { customProviderURL = EditorGUILayout.TextField("URL: ", customProviderURL); EditorGUILayout.BeginVertical(GUI.skin.box); showCustomProviderTokens = OnlineMapsEditor.Foldout(showCustomProviderTokens, "Available tokens"); if (showCustomProviderTokens) { GUILayout.Label("{zoom}"); GUILayout.Label("{x}"); GUILayout.Label("{y}"); GUILayout.Label("{quad}"); GUILayout.Space(10); } EditorGUILayout.EndVertical(); } }
private void DrawProvider(ref bool allowCreate) { EditorGUI.BeginChangeCheck(); provider = (OnlineMapsProviderEnum) EditorGUILayout.EnumPopup(new GUIContent("Provider: ", "Provider of tiles"), provider); if (EditorGUI.EndChangeCheck()) { mapProviderType = 0; } if (provider == OnlineMapsProviderEnum.custom) { customProviderURL = EditorGUILayout.TextField("URL: ", customProviderURL); EditorGUILayout.BeginVertical(GUI.skin.box); showCustomProviderTokens = OnlineMapsEditor.Foldout(showCustomProviderTokens, "Available tokens"); if (showCustomProviderTokens) { GUILayout.Label("{zoom}"); GUILayout.Label("{x}"); GUILayout.Label("{y}"); GUILayout.Label("{quad}"); GUILayout.Space(10); } EditorGUILayout.EndVertical(); } }
protected void DrawCurvedUIWarning() { EditorGUILayout.HelpBox("To make the map work properly with Curved UI, enable integration.", MessageType.Info); if (GUILayout.Button("Enable Curved UI")) { OnlineMapsEditor.AddCompilerDirective("CURVEDUI"); } }
public override void OnInspectorGUI() { bool dirty = false; OnlineMapsControlBase control = target as OnlineMapsControlBase; OnlineMapsControlBaseEditor.CheckMultipleInstances(control, ref dirty); OnlineMaps map = OnlineMapsControlBaseEditor.GetOnlineMaps(control); OnlineMapsControlBaseEditor.CheckTarget(map, OnlineMapsTarget.texture, ref dirty); #if !NGUI if (GUILayout.Button("Enable NGUI")) { if (EditorUtility.DisplayDialog("Enable NGUI", "You have NGUI in your project?", "Yes, I have NGUI", "Cancel")) { OnlineMapsEditor.AddCompilerDirective("NGUI"); } } #else if (noColliderWarning) { EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.HelpBox("Potential problem detected:\nGameObject has no BoxCollider, so you can not control the map.", MessageType.Warning); if (GUILayout.Button("Add BoxCollider")) { BoxCollider bc = map.gameObject.AddComponent <BoxCollider>(); UITexture uiTexture = map.GetComponent <UITexture>(); if (uiTexture != null) { bc.size = uiTexture.localSize; } } EditorGUILayout.EndVertical(); } base.OnInspectorGUI(); #endif if (dirty) { EditorUtility.SetDirty(map); EditorUtility.SetDirty(control); if (!Application.isPlaying) { #if UNITY_5_3P EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); #endif } else { map.Redraw(); } } }
public override void OnInspectorGUI() { #if !NGUI if (GUILayout.Button("Enable NGUI")) { if (EditorUtility.DisplayDialog("Enable NGUI", "You have NGUI in your project?", "Yes, I have NGUI", "Cancel")) { OnlineMapsEditor.AddCompilerDirective("NGUI"); } } #else base.OnInspectorGUI(); #endif }
private void OnCreateMarkerGUI() { EditorGUILayout.BeginVertical(GUI.skin.box); bool createMarker = pCreateMarkerInUserPosition.boolValue; if (createMarker) { EditorGUILayout.BeginHorizontal(); showCreateMarker = GUILayout.Toggle(showCreateMarker, "", EditorStyles.foldout, GUILayout.ExpandWidth(false), GUILayout.Height(16)); } pCreateMarkerInUserPosition.boolValue = GUILayout.Toggle(pCreateMarkerInUserPosition.boolValue, "Create Marker", toggleStyle); if (createMarker) { EditorGUILayout.EndHorizontal(); } if (pCreateMarkerInUserPosition.boolValue && showCreateMarker) { pMarkerType.enumValueIndex = EditorGUILayout.Popup("Type", pMarkerType.enumValueIndex, new[] { "2D", "3D" }); if (pMarkerType.enumValueIndex == (int)OnlineMapsLocationServiceMarkerType.threeD) { EditorGUILayout.PropertyField(pMarker3DPrefab, new GUIContent("Prefab")); } else { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(pMarker2DTexture, new GUIContent("Texture")); if (EditorGUI.EndChangeCheck() && pMarker2DTexture.objectReferenceValue != null) { OnlineMapsEditor.CheckMarkerTextureImporter(pMarker2DTexture); } EditorGUILayout.PropertyField(pMarker2DAlign, new GUIContent("Align")); } EditorGUILayout.PropertyField(pMarkerTooltip, new GUIContent("Tooltip")); EditorGUILayout.PropertyField(pUseCompassForMarker, new GUIContent("Use Compass")); if (pUseCompassForMarker.boolValue) { EditorGUILayout.PropertyField(pLerpCompassValueForMarker, new GUIContent("Lerp Compass Value")); } } EditorGUILayout.EndVertical(); }
private void OnCreateMarkerGUI() { EditorGUILayout.BeginVertical(GUI.skin.box); bool createMarker = ls.createMarkerInUserPosition; if (createMarker) { EditorGUILayout.BeginHorizontal(); showCreateMarker = GUILayout.Toggle(showCreateMarker, "", EditorStyles.foldout, GUILayout.ExpandWidth(false), GUILayout.Height(16)); } ls.createMarkerInUserPosition = GUILayout.Toggle(ls.createMarkerInUserPosition, "Create Marker", toggleStyle); if (createMarker) { EditorGUILayout.EndHorizontal(); } if (ls.createMarkerInUserPosition && showCreateMarker) { ls.markerType = (OnlineMapsLocationServiceMarkerType)EditorGUILayout.Popup("Type", (int)ls.markerType, new[] { "2D", "3D" }); if (ls.markerType == OnlineMapsLocationServiceMarkerType.threeD) { ls.marker3DPrefab = EditorGUILayout.ObjectField("Prefab", ls.marker3DPrefab, typeof(GameObject), false) as GameObject; } else { EditorGUI.BeginChangeCheck(); ls.marker2DTexture = EditorGUILayout.ObjectField("Texture", ls.marker2DTexture, typeof(Texture2D), false) as Texture2D; if (EditorGUI.EndChangeCheck() && ls.marker2DTexture != null) { OnlineMapsEditor.CheckMarkerTextureImporter(ls.marker2DTexture); } ls.marker2DAlign = (OnlineMapsAlign)EditorGUILayout.EnumPopup("Align", ls.marker2DAlign); } ls.markerTooltip = EditorGUILayout.TextField("Tooltip", ls.markerTooltip); ls.useCompassForMarker = EditorGUILayout.Toggle("Use Compass", ls.useCompassForMarker); } EditorGUILayout.EndVertical(); }
public override void OnInspectorGUI() { #if !RWT && !RWT3 if (GUILayout.Button("Enable Real World Terrain")) { if (EditorUtility.DisplayDialog("Enable Real World Terrain", "You have Real World Terrain in your project?", "Yes, I have Real World Terrain", "Cancel")) { Assembly assembly = typeof(OnlineMapsRWTConnectorEditor).Assembly; if (assembly.GetType("InfinityCode.RealWorldTerrain.Windows.RealWorldTerrainWindow") != null) { OnlineMapsEditor.AddCompilerDirective("RWT3"); } else { OnlineMapsEditor.AddCompilerDirective("RWT"); } } } #else OnlineMapsRWTConnector connector = (OnlineMapsRWTConnector)target; connector.mode = (OnlineMapsRWTConnectorMode)EditorGUILayout.EnumPopup("Mode: ", connector.mode); if (connector.mode == OnlineMapsRWTConnectorMode.markerOnPosition) { connector.markerTexture = (Texture2D)EditorGUILayout.ObjectField("Marker Texture", connector.markerTexture, typeof(Texture2D), false); connector.markerLabel = EditorGUILayout.TextField("Marker Tooltip:", connector.markerLabel); } connector.positionMode = (OnlineMapsRWTConnectorPositionMode)EditorGUILayout.EnumPopup("Position mode: ", connector.positionMode); if (connector.positionMode == OnlineMapsRWTConnectorPositionMode.transform) { connector.targetTransform = (Transform)EditorGUILayout.ObjectField("Target Transform", connector.targetTransform, typeof(Transform), true); } else if (connector.positionMode == OnlineMapsRWTConnectorPositionMode.scenePosition) { connector.scenePosition = EditorGUILayout.Vector3Field("Position: ", connector.scenePosition); } else if (connector.positionMode == OnlineMapsRWTConnectorPositionMode.coordinates) { connector.coordinates = EditorGUILayout.Vector2Field("Coordinates: ", connector.coordinates); } #endif }
private void DrawAvailableTokens() { EditorGUILayout.BeginVertical(GUI.skin.box); showPathTokens = OnlineMapsEditor.Foldout(showPathTokens, "Available Tokens"); if (showPathTokens) { GUILayout.Label("{pid} - Provider ID"); GUILayout.Label("{mid} - MapType ID"); GUILayout.Label("{zoom}, {z} - Tile Zoom"); GUILayout.Label("{x} - Tile X"); GUILayout.Label("{y} - Tile Y"); GUILayout.Label("{quad} - Tile Quad Key"); GUILayout.Label("{lng} - Language code"); GUILayout.Label("{lbs} - Labels"); GUILayout.Space(10); } EditorGUILayout.EndVertical(); }
private void OnMaterialsGUI(ref bool dirty) { bool showMaterialGroup = showMaterials; if (showMaterialGroup) { EditorGUILayout.BeginVertical(GUI.skin.box); } showMaterials = OnlineMapsEditor.Foldout(showMaterials, "Materials"); if (showMaterials) { int removedIndex = -1; for (int i = 0; i < pMaterials.arraySize; i++) { EditorGUILayout.BeginVertical(GUI.skin.box); OnlineMapsBuildingMaterialPropertyDrawer.isRemoved = false; EditorGUILayout.PropertyField(pMaterials.GetArrayElementAtIndex(i), new GUIContent("Material " + (i + 1))); if (OnlineMapsBuildingMaterialPropertyDrawer.isRemoved) { removedIndex = i; } EditorGUILayout.EndHorizontal(); } if (removedIndex != -1) { ArrayUtility.RemoveAt(ref buildings.materials, removedIndex); dirty = true; } if (GUILayout.Button("Add Material")) { ArrayUtility.Add(ref buildings.materials, new OnlineMapsBuildingMaterial()); dirty = true; } } if (showMaterialGroup) { EditorGUILayout.EndVertical(); } }
public override void OnInspectorGUI() { bool dirty = false; OnlineMapsControlBase control = target as OnlineMapsControlBase; OnlineMapsControlBaseEditor.CheckMultipleInstances(control, ref dirty); OnlineMaps map = OnlineMapsControlBaseEditor.GetOnlineMaps(control); OnlineMapsControlBaseEditor.CheckTarget(map, OnlineMapsTarget.texture, ref dirty); #if !DFGUI if (GUILayout.Button("Enable DFGUI")) { if (EditorUtility.DisplayDialog("Enable DFGUI", "You have DFGUI in your project?", "Yes, I have DFGUI", "Cancel")) { OnlineMapsEditor.AddCompilerDirective("DFGUI"); } } #else base.OnInspectorGUI(); #endif if (dirty) { EditorUtility.SetDirty(map); EditorUtility.SetDirty(control); if (!Application.isPlaying) { #if UNITY_5_3P EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); #endif } else { map.Redraw(); } } }
public override void OnInspectorGUI() { #if !EASYTOUCH if (GUILayout.Button("Enable EasyTouch")) { if (EditorUtility.DisplayDialog("Enable EasyTouch", "You have EasyTouch in your project?", "Yes, I have EasyTouch", "Cancel")) { OnlineMapsEditor.AddCompilerDirective("EASYTOUCH"); } } #else EditorGUILayout.HelpBox("This component does not require configuration.", MessageType.Info); if (cameraOrbit == null) { EditorGUILayout.HelpBox("To use twist and tilt gestures, add Online Maps Camera Orbit component.", MessageType.Warning); if (GUILayout.Button("Add Camera Orbit")) { connector.gameObject.AddComponent <OnlineMapsCameraOrbit>(); } } #endif }
public override void OnInspectorGUI() { #if !TOUCHSCRIPT if (GUILayout.Button("Enable TouchScript")) { if (EditorUtility.DisplayDialog("Enable TouchScript", "You have TouchScript in your project?", "Yes, I have TouchScript", "Cancel")) { OnlineMapsEditor.AddCompilerDirective("TOUCHSCRIPT"); } } #else base.OnInspectorGUI(); if (cameraOrbit == null) { EditorGUILayout.HelpBox("To use twist and tilt gestures, add Online Maps Camera Orbit component.", MessageType.Warning); if (GUILayout.Button("Add Camera Orbit")) { connector.gameObject.AddComponent <OnlineMapsCameraOrbit>(); } } #endif }
public override void OnInspectorGUI() { #if !RWT if (GUILayout.Button("Enable Real World Terrain")) { OnlineMapsEditor.AddCompilerDirective("RWT"); } #else OnlineMapsRWTConnector connector = (OnlineMapsRWTConnector)target; connector.mode = (OnlineMapsRWTConnectorMode)EditorGUILayout.EnumPopup("Mode: ", connector.mode); if (connector.mode == OnlineMapsRWTConnectorMode.markerOnPosition) { connector.markerTexture = (Texture2D)EditorGUILayout.ObjectField("Marker Texture", connector.markerTexture, typeof(Texture2D), false); connector.markerLabel = EditorGUILayout.TextField("Marker Tooltip:", connector.markerLabel); } connector.positionMode = (OnlineMapsRWTConnectorPositionMode)EditorGUILayout.EnumPopup("Position mode: ", connector.positionMode); if (connector.positionMode == OnlineMapsRWTConnectorPositionMode.transform) { connector.targetTransform = (Transform) EditorGUILayout.ObjectField("Target Transform", connector.targetTransform, typeof(Transform), true); } else if (connector.positionMode == OnlineMapsRWTConnectorPositionMode.scenePosition) { connector.scenePosition = EditorGUILayout.Vector3Field("Position: ", connector.scenePosition); } else if (connector.positionMode == OnlineMapsRWTConnectorPositionMode.coordinates) { connector.coordinates = EditorGUILayout.Vector2Field("Coordinates: ", connector.coordinates); } #endif }
public override void OnInspectorGUI() { #if !UNITY_2017_2_OR_NEWER || ONLINEMAPS_GUITEXTURE bool dirty = false; OnlineMapsControlBase control = target as OnlineMapsControlBase; OnlineMapsControlBaseEditor.CheckMultipleInstances(control, ref dirty); OnlineMaps map = OnlineMapsControlBaseEditor.GetOnlineMaps(control); OnlineMapsControlBaseEditor.CheckTarget(map, OnlineMapsTarget.texture, ref dirty); base.OnInspectorGUI(); if (dirty) { EditorUtility.SetDirty(map); EditorUtility.SetDirty(control); if (!Application.isPlaying) { #if UNITY_5_3P EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); #endif } else { map.Redraw(); } } #else EditorGUILayout.HelpBox("GUITexture is part of the legacy GUI, and will be removed in future versions of Unity Editor.", MessageType.Warning); if (GUILayout.Button("Enable GUITexture")) { OnlineMapsEditor.AddCompilerDirective("ONLINEMAPS_GUITEXTURE"); } #endif }
private void OnFileCacheGUI() { bool fileCache = pUseFileCache.boolValue; if (fileCache) { EditorGUILayout.BeginVertical(GUI.skin.box); } EditorGUILayout.PropertyField(pUseFileCache, new GUIContent("File Cache")); if (pUseFileCache.boolValue) { #if UNITY_WEBPLAYER || UNITY_WEBGL EditorGUILayout.HelpBox("File Cache is not supported for Webplayer and WebGL.", MessageType.Warning); #endif CheckFileCacheSize(); EditorGUILayout.PropertyField(pMaxFileCacheSize, new GUIContent("Size (mb)")); pFileCacheUnloadRate.floatValue = EditorGUILayout.Slider("Unload (%)", Mathf.RoundToInt(pFileCacheUnloadRate.floatValue * 100), 1, 50) / 100; EditorGUILayout.PropertyField(pFileCacheLocation, new GUIContent("Cache Location")); if (pFileCacheLocation.enumValueIndex == (int)OnlineMapsCache.CacheLocation.custom) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(pFileCacheCustomPath, new GUIContent("Cache Folder")); if (GUILayout.Button("...", GUILayout.ExpandWidth(false))) { string folder = EditorUtility.OpenFolderPanel("Cache folder", pFileCacheCustomPath.stringValue, ""); if (!string.IsNullOrEmpty(folder)) { pFileCacheCustomPath.stringValue = folder; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(pFileCacheTilePath, new GUIContent("Tile Path")); if (GUILayout.Button("Open", GUILayout.ExpandWidth(false))) { Process.Start(cache.GetFileCacheFolder().ToString()); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(GUI.skin.box); showPathTokens = OnlineMapsEditor.Foldout(showPathTokens, "Available Tokens"); if (showPathTokens) { GUILayout.Label("{pid} - Provider ID"); GUILayout.Label("{mid} - MapType ID"); GUILayout.Label("{zoom}, {z} - Tile Zoom"); GUILayout.Label("{x} - Tile X"); GUILayout.Label("{y} - Tile Y"); GUILayout.Label("{quad} - Tile Quad Key"); GUILayout.Label("{lng} - Language code"); GUILayout.Label("{lbs} - Labels"); GUILayout.Space(10); } EditorGUILayout.EndVertical(); if (Application.isPlaying || !fileCacheSize.HasValue) { fileCacheSize = cache.GetFileCacheSizeFast(); } float fileCacheSizeMb = fileCacheSize.Value / 1000000f; string fileCacheSizeStr = fileCacheSizeMb.ToString("F2"); EditorGUILayout.LabelField("Current Size (mb)", fileCacheSizeStr); if (GUILayout.Button("Clear")) { cache.ClearFileCache(); fileCacheSize = null; } } if (fileCache) { EditorGUILayout.EndVertical(); } }
protected void DrawMarkersGUI(ref bool dirty) { EditorGUILayout.BeginVertical(GUI.skin.box); showMarkers = OnlineMapsEditor.Foldout(showMarkers, string.Format("3D markers (Count: {0})", pMarkers3D.arraySize)); if (showMarkers) { EditorGUILayout.PropertyField(pDefault3DMarker); EditorGUILayout.PropertyField(pMarker3DScale); EditorGUILayout.PropertyField(pAllowDefaultMarkerEvents); int removedIndex = -1; EditorGUI.BeginChangeCheck(); for (int i = 0; i < pMarkers3D.arraySize; i++) { EditorGUILayout.BeginVertical(GUI.skin.box); OnlineMapsMarker3DPropertyDrawer.isRemoved = false; OnlineMapsMarker3DPropertyDrawer.isEnabledChanged = null; EditorGUILayout.PropertyField(pMarkers3D.GetArrayElementAtIndex(i), new GUIContent("Marker " + (i + 1))); if (OnlineMapsMarker3DPropertyDrawer.isRemoved) { removedIndex = i; } if (OnlineMapsMarker3DPropertyDrawer.isEnabledChanged.HasValue) { control.markers3D[i].enabled = OnlineMapsMarker3DPropertyDrawer.isEnabledChanged.Value; } EditorGUILayout.EndHorizontal(); } if (EditorGUI.EndChangeCheck()) { dirty = true; } if (removedIndex != -1) { ArrayUtility.RemoveAt(ref control.markers3D, removedIndex); dirty = true; } EditorGUILayout.Space(); if (GUILayout.Button("Add Marker")) { if (!Application.isPlaying) { OnlineMapsMarker3D marker = new OnlineMapsMarker3D { position = control.GetComponent <OnlineMaps>().position, scale = pMarker3DScale.floatValue }; ArrayUtility.Add(ref control.markers3D, marker); } else { GameObject prefab = GameObject.CreatePrimitive(PrimitiveType.Cube); control.AddMarker3D(OnlineMaps.instance.position, prefab); OnlineMapsUtils.DestroyImmediate(prefab); } dirty = true; } } EditorGUILayout.EndVertical(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); EditorGUI.LabelField(position, label); try { Rect rect = new Rect(position.x, position.y, position.width, 16); EditorGUI.BeginChangeCheck(); SerializedProperty pLat = DrawProperty(property, "latitude", ref rect); if (EditorGUI.EndChangeCheck()) { #if UNITY_5_0P if (pLat.doubleValue < -90) { pLat.doubleValue = -90; } else if (pLat.doubleValue > 90) { pLat.doubleValue = 90; } #else if (pLat.floatValue < -90) { pLat.floatValue = -90; } else if (pLat.floatValue > 90) { pLat.floatValue = 90; } #endif } EditorGUI.BeginChangeCheck(); SerializedProperty pLng = DrawProperty(property, "longitude", ref rect); if (EditorGUI.EndChangeCheck()) { #if UNITY_5_0P if (pLng.doubleValue < -180) { pLng.doubleValue += 360; } else if (pLng.doubleValue > 180) { pLng.doubleValue -= 360; } #else if (pLng.floatValue < -180) { pLng.floatValue += 360; } else if (pLng.floatValue > 180) { pLng.floatValue -= 360; } #endif } DrawProperty(property, "range", ref rect, new GUIContent("Zooms")); EditorGUI.BeginChangeCheck(); SerializedProperty pRot = DrawProperty(property, "_rotation", ref rect, new GUIContent("Rotation (0-1)")); if (EditorGUI.EndChangeCheck()) { if (pRot.floatValue < 0 || pRot.floatValue > 1) { pRot.floatValue = Mathf.Repeat(pRot.floatValue, 1); } } DrawProperty(property, "_scale", ref rect); DrawProperty(property, "label", ref rect); DrawProperty(property, "align", ref rect); EditorGUI.BeginChangeCheck(); SerializedProperty pTexture = DrawProperty(property, "texture", ref rect); if (EditorGUI.EndChangeCheck()) { OnlineMapsEditor.CheckMarkerTextureImporter(pTexture); } rect.y += 18; if (GUI.Button(rect, "Remove")) { isRemoved = true; } } catch { } EditorGUI.EndProperty(); }
protected void DrawMarkersGUI(ref bool dirty) { if (control.markers3D == null) { control.markers3D = new OnlineMapsMarker3D[0]; dirty = true; } EditorGUILayout.BeginVertical(GUI.skin.box); showMarkers = OnlineMapsEditor.Foldout(showMarkers, "3D markers"); if (showMarkers) { EditorGUI.BeginChangeCheck(); control.marker3DScale = EditorGUILayout.FloatField("Marker3D Scale: ", control.marker3DScale); control.allowDefaultMarkerEvents = EditorGUILayout.Toggle("Allow Default Marker Events: ", control.allowDefaultMarkerEvents); if (EditorGUI.EndChangeCheck()) { dirty = true; } int index = 1; bool hasDeleted = false; OnlineMaps map = control.GetComponent <OnlineMaps>(); for (int i = 0; i < control.markers3D.Length; i++) { DrawMarkerGUI(i, ref index, ref hasDeleted, map, ref dirty); } if (hasDeleted) { List <OnlineMapsMarker3D> markers = control.markers3D.ToList(); markers.RemoveAll(m => m == null); control.markers3D = markers.ToArray(); if (Application.isPlaying) { OnlineMaps.instance.Redraw(); } dirty = true; } EditorGUILayout.Space(); if (GUILayout.Button("Add marker")) { if (!Application.isPlaying) { OnlineMapsMarker3D marker = new OnlineMapsMarker3D { position = control.GetComponent <OnlineMaps>().position, scale = control.marker3DScale }; List <OnlineMapsMarker3D> markers = new List <OnlineMapsMarker3D>(control.markers3D) { marker }; control.markers3D = markers.ToArray(); } else { GameObject prefab = GameObject.CreatePrimitive(PrimitiveType.Cube); control.AddMarker3D(OnlineMaps.instance.position, prefab); DestroyImmediate(prefab); } EditorUtility.SetDirty(control); } } EditorGUILayout.EndVertical(); }