void InspectImpactPhaseTemplate() { var spell = (Spell)target; spell.ImpactPhase = ScriptableObjectEditorUtil.ToggleAddRemoveScriptableObject("Impact Phase", target, spell.ImpactPhase); if (spell.ImpactPhase != null) { InspectSpellPhaseTemplate(spell.ImpactPhase); } }
void InspectSpellEffects(string label, ref SpellEffectCollection spellEffects) { spellEffects = ScriptableObjectEditorUtil.ToggleAddRemoveScriptableObject(label, target, spellEffects); if (spellEffects != null) { ++EditorGUI.indentLevel; InspectSpellEffects(spellEffects); --EditorGUI.indentLevel; } }
void InspectAuraTemplate(string label, ref AuraTemplate template) { template = ScriptableObjectEditorUtil.ToggleAddRemoveScriptableObject(label, target, template); if (template != null) { ++EditorGUI.indentLevel; // TODO //InspectSpellEffects(spellEffects); --EditorGUI.indentLevel; } }
void OnRemove(ReorderableList list) { var index = list.index; var element = list.serializedProperty.GetArrayElementAtIndex(index); var obj = (A)element.objectReferenceValue; ReorderableList.defaultBehaviours.DoRemoveButton(list); ArrayUtility.Remove(ref arr, obj); ScriptableObjectEditorUtil.DeleteObjectFromAsset(obj); serializedObject.ApplyModifiedProperties(); }
void InspectRepeatSpellEffects(string label, ref RepeatSpellEffectCollection spellEffects) { spellEffects = ScriptableObjectEditorUtil.ToggleAddRemoveScriptableObject(label, target, spellEffects); if (spellEffects != null) { ++EditorGUI.indentLevel; spellEffects.RepeatDelay = EditorGUILayout.FloatField("Repeat Delay", spellEffects.RepeatDelay); spellEffects.MaxRepetitions = EditorGUILayout.FloatField("MaxRepetitions", spellEffects.MaxRepetitions); InspectSpellEffects(spellEffects); --EditorGUI.indentLevel; } }
void OnDropdownClick(object source) { var entry = (CustomScriptableObjectEntry)source; // create and add enw object var obj = (A)ScriptableObjectEditorUtil.AddNewObjectToAsset(owner, entry.Type); var index = list.serializedProperty.arraySize; list.serializedProperty.arraySize++; var element = list.serializedProperty.GetArrayElementAtIndex(index); element.objectReferenceValue = obj; serializedObject.ApplyModifiedProperties(); }
void InspectArrayWithInheritanceMutuallyExclusiveTypes <A>(ref A[] arr) where A : ScriptableObject { var allEntries = ScriptableObjectEditorUtil.Scripts.GetEntries <A>(); // remove empty entries for (var i = arr.Length - 1; i >= 0; --i) { if (arr[i] == null) { ArrayUtility.RemoveAt(ref arr, i); } } // render all possible entries as "toggle" element foreach (var entry in allEntries) { var matchingObjectIndex = ArrayUtility.FindIndex(arr, collector => collector.GetType() == entry.Type); var wasAdded = matchingObjectIndex >= 0; var originalObj = wasAdded ? arr[matchingObjectIndex] : null; var obj = ScriptableObjectEditorUtil.ToggleAddRemoveScriptableObject(entry.Name, target, originalObj, entry.Type); var isAdded = obj != null; if (isAdded != wasAdded) { if (!isAdded) { // remove ArrayUtility.Remove(ref arr, originalObj); } else { // add ArrayUtility.Add(ref arr, obj); } } if (obj != null) { // render object inspector InspectUnityObject(obj); } } }
private void CreateVideoFromCurrentSequence() { if (string.IsNullOrEmpty(currentRecordingName_)) { Debug.LogWarning("Cannot create video because no current recording name!"); return; } string ffmpegDirectoryPath = ""; #if UNITY_EDITOR string binPath = ScriptableObjectEditorUtil.PathForScriptableObjectType <BinMarker>(); string pathToProject = Application.dataPath.Replace("Assets", ""); string binFullPath = Path.Combine(pathToProject, binPath); ffmpegDirectoryPath = Path.Combine(binFullPath, "ffmpeg"); #else ffmpegDirectoryPath = SavePathUtil.PopulateDesktopVariable(nonEditorFfmpegPath_); #endif string ffmpegPath = ""; #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX ffmpegPath = Path.Combine(ffmpegDirectoryPath, "ffmpeg_mac"); #else ffmpegPath = Path.Combine(ffmpegDirectoryPath, "ffmpeg_win.exe"); #endif string arguments = string.Format("-f image2 -r {0} -i ./{1}/Frame%06d.png -c:v libx264 -r {0} -b:v 30M -pix_fmt yuv420p {1}.mp4 -loglevel debug", frameRate_, currentRecordingName_); var process = new System.Diagnostics.Process(); process.StartInfo.FileName = ffmpegPath; process.StartInfo.Arguments = arguments; process.StartInfo.WorkingDirectory = populatedRecordingPath_; process.Start(); process.WaitForExit(5 * 60 * 1000); // 5 minutes max Directory.Delete(Path.Combine(populatedRecordingPath_, currentRecordingName_), recursive: true); }