public override void OnInspectorGUI() { // Update the serializedProperty - always do this in the beginning of OnInspectorGUI. serializedObject.Update(); PeaksProfile source = (PeaksProfile)target; EditorGUILayout.Foldout(true, "FFT", GlobalStyles.heading); EditorGUILayout.PropertyField(windowProp, new GUIContent("Window", "The quality of the spectrum data. List is in desceneding order, lowest to highest.")); EditorGUILayout.IntPopup(samplesProp, sampleOptionStrings, sampleOptions, new GUIContent("Samples", "The number of samples. Low quality results in better performance, and high quality result in lower performance.")); EditorGUILayout.Space(); EditorGUILayout.PropertyField(amplitudeProp, new GUIContent("Amplitude", "Scales a level's magnitude. Linear is popular for processing, i.e. handling triggers, and Decible is good for visualizing.")); EditorGUILayout.Space(); if (GUILayout.Button("Reset")) { if (EditorUtility.DisplayDialog("Warning", "This will clear saved peaks and mark the asset as dirty. This operation cannot be undone. Continue?", "Yes", "No")) { source.ResetPeaks(); EditorUtility.SetDirty(source); } } // Apply changes to the serializedProperty - always do this at the end of OnInspectorGUI. serializedObject.ApplyModifiedProperties(); if (source.isDirty) { EditorGUILayout.HelpBox("Peak data is dirty. Attach this asset to a SpectrumSource and hit Record Peaks in play mode.", MessageType.Warning); } }
static void PeaksProfileCreate() { PeaksProfile peaksProfile = ScriptableObject.CreateInstance <PeaksProfile>(); string assetPath = AssetDatabase.GetAssetPath(Selection.activeObject); FileAttributes attr = File.GetAttributes(assetPath); if (attr == FileAttributes.Directory) { ProjectWindowUtil.CreateAsset(peaksProfile, assetPath + "/New Peaks Profile.peaks.asset"); } else { string path = Path.GetDirectoryName(assetPath); string fileName = Path.GetFileNameWithoutExtension(assetPath); ProjectWindowUtil.CreateAsset(peaksProfile, path + "/" + fileName + ".peaks.asset"); } }