public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(useWebcamOnEditorSP); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Recognition Options", EditorStyles.boldLabel); EditorGUILayout.PropertyField(recognitionStorageOptionSP); EditorGUILayout.PropertyField(recognitionModeOptionSP); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Databases", EditorStyles.boldLabel); for (int i = 0; i < databasesSP.arraySize; i++) { GUILayout.BeginHorizontal(); string selection = EditorGUILayout.TextField(databasesSP.GetArrayElementAtIndex(i).stringValue); databasesSP.GetArrayElementAtIndex(i).stringValue = selection; if (GUILayout.Button("X", GUILayout.Width(20f))) { databasesSP.DeleteArrayElementAtIndex(i); } GUILayout.EndHorizontal(); } if (GUILayout.Button("Add a database")) { databasesSP.InsertArrayElementAtIndex(databasesSP.arraySize); databasesSP.GetArrayElementAtIndex(databasesSP.arraySize - 1).stringValue = ""; } EditorGUILayout.Separator(); EditorGUILayout.LabelField("Markers", EditorStyles.boldLabel); EditorGUILayout.LabelField("Imported markers:"); foreach (string marker in mainScript.GetMarkerList()) { EditorGUILayout.LabelField(marker); } EditorGUILayout.LabelField("Discover Models", EditorStyles.boldLabel); EditorGUILayout.LabelField("Imported discover models:"); foreach (string discover in mainScript.GetDiscoverList()) { EditorGUILayout.LabelField(discover); } if (GUILayout.Button("Import Local Markers")) { mainScript.Check(); EditorUtility.SetDirty(target); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } markerListSP = serializedObject.FindProperty("markerList"); discoverListSP = serializedObject.FindProperty("discoverList"); EditorGUILayout.PropertyField(isSeeThroughDeviceSP); EditorGUILayout.PropertyField(seeThroughFramePredictionSP); serializedObject.ApplyModifiedProperties(); }
public void myOnInspectorGUI() { serializedObject.Update(); if (GUILayout.Button("Import Markers")) { mainScript.Check(); EditorUtility.SetDirty(mainScript); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } // se non ci sono marker importati esco (mostro solo il pulsante) //if (mainScript.GetMarkerList().Length < 2) { // return; //} // popolo la lista di marker string[] choices = new string[mainScript.GetMarkerList().Length]; int index = 0; foreach (string marker in mainScript.GetMarkerList()) { if (marker == "") { choices[index] = "---"; } else { choices[index] = marker; } index++; } // mostro il selettore EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Marker id:"); // verifico match tra marker e index if (markerIndexSP.intValue > 0 || markerIdSP.stringValue != "") { int i = IndexOf(markerIdSP.stringValue, mainScript.GetMarkerList()); if (i != -1 && markerIndexSP.intValue != i) { // marker e' in lista ma con index sbagliato markerIndexSP.intValue = i; } else if (i == -1) { // marker non in lista ResetIndex(); } //marker e' in lista con id giusto non faccio nulla } int currentChoice = -1; if (mainScript.GetMarkerList().Length < 2 || (markerIndexSP.intValue == 0 && markerIdSP.stringValue == "")) { currentChoice = EditorGUILayout.Popup(0, choices); SetNewMarker(currentChoice); } else { currentChoice = EditorGUILayout.Popup(markerIndexSP.intValue, choices); if (currentChoice != markerIndexSP.intValue) { SetNewMarker(currentChoice); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(markerARLogoPatternSP); //Events Listeners EditorGUILayout.Separator(); EditorGUILayout.PropertyField(OnMarkerFoundEventsSP); EditorGUILayout.PropertyField(OnMarkerLostEventsSP); EditorGUILayout.PropertyField(OnMarkerPatternCodeFoundEventsSP); serializedObject.ApplyModifiedProperties(); }