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(); }
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(); }