public void ProcessRequest(IOrganizationService service, Operation operation, Func <IOrganizationService, OrganizationRequest, OrganizationRequest> undoFunction = null) { if (!IsTransactionInEffect()) { throw new Exception("No transaction in effect!"); } try { // get request from operation var request = operation.Request; // get the undo request corresponding to the given request operation.UndoRequest = undoFunction == null ? UndoHelper.GenerateReverseRequest(service, request) : undoFunction(service, request); // register this response as the starting point of the latest transaction transactionsStack.Peek().StartingPoint ??= operation; operationsStack.Push(operation); } catch (Exception ex) { throw new Exception("Failed to create undo request for the given request! => " + ex.Message, ex); } }
private void CreateCategory() { if (string.IsNullOrEmpty(_pool.newCategoryName)) { DTPoolBossInspectorUtility.ShowAlert(PoolBossLang.ErrorBlankCategoryName); return; } // ReSharper disable once ForCanBeConvertedToForeach for (var c = 0; c < _pool._categories.Count; c++) { var cat = _pool._categories[c]; // ReSharper disable once InvertIf if (cat.CatName == _pool.newCategoryName) { DTPoolBossInspectorUtility.ShowAlert(string.Format(PoolBossLang.ErrorDuplicateCategoryName, _pool.newCategoryName)); return; } } UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _pool, PoolBossLang.CreateNewCategory); var newCat = new PoolBossCategory { CatName = _pool.newCategoryName, ProspectiveName = _pool.newCategoryName, }; _pool._categories.Add(newCat); }
public void CreateVariation(DynamicSoundGroup group, AudioClip clip) { var resourceFileName = string.Empty; if (group.bulkVariationMode == MasterAudio.AudioLocation.ResourceFile) { resourceFileName = DTGUIHelper.GetResourcePath(clip); if (string.IsNullOrEmpty(resourceFileName)) { resourceFileName = clip.name; } } var clipName = clip.name; if (group.transform.FindChild(clipName) != null) { DTGUIHelper.ShowAlert("You already have a Variation for this Group named '" + clipName + "'. \n\nPlease rename these Variations when finished to be unique, or you may not be able to play them by name if you have a need to."); } var newVar = (GameObject) GameObject.Instantiate(_group.variationTemplate, _group.transform.position, Quaternion.identity); UndoHelper.CreateObjectForUndo(newVar, "create Variation"); newVar.transform.name = clipName; newVar.transform.parent = group.transform; var variation = newVar.GetComponent<DynamicGroupVariation>(); if (group.bulkVariationMode == MasterAudio.AudioLocation.ResourceFile) { variation.audLocation = MasterAudio.AudioLocation.ResourceFile; variation.resourceFileName = resourceFileName; } else { newVar.audio.clip = clip; } }
private Transform CreateGroup(AudioClip aClip) { if (_creator.groupTemplate == null) { DTGUIHelper.ShowAlert("Your 'Group Template' field is empty, please assign it in debug mode. Drag the 'DynamicSoundGroup' prefab from MasterAudio/Sources/Prefabs into that field, then switch back to normal mode."); return(null); } var groupName = UtilStrings.TrimSpace(aClip.name); var matchingGroup = _groups.Find(delegate(DynamicSoundGroup obj) { return(obj.transform.name == groupName); }); if (matchingGroup != null) { DTGUIHelper.ShowAlert("You already have a Group named '" + groupName + "'. \n\nPlease rename this Group when finished to be unique."); } var spawnedGroup = (GameObject)GameObject.Instantiate(_creator.groupTemplate, _creator.transform.position, Quaternion.identity); spawnedGroup.name = groupName; UndoHelper.CreateObjectForUndo(spawnedGroup, "create Dynamic Group"); spawnedGroup.transform.parent = _creator.transform; CreateVariation(spawnedGroup.transform, aClip); return(spawnedGroup.transform); }
private void AddPoolItem(Object o) { // ReSharper disable once PossibleNullReferenceException var go = (o as GameObject); if (go == null) { DTPoolBossInspectorUtility.ShowAlert(PoolBossLang.DraggedNotGameObject); return; } var newItem = new PoolBossItem { categoryName = _pool.addToCategoryName, prefabSource = _pool.newItemPrefabSource }; switch (_pool.newItemPrefabSource) { case PoolBoss.PrefabSource.Prefab: newItem.prefabTransform = go.transform; break; #if ADDRESSABLES_ENABLED case PoolBoss.PrefabSource.Addressable: newItem.prefabAddressable = PoolBossAddressableEditorHelper.CreateAssetReferenceFromObject(go.transform); break; #endif } UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _pool, PoolBossLang.AddPoolIem); _pool.poolItems.Add(newItem); }
public static void Draw(InAudioNode node) { UndoHelper.GUIUndo(node, "Name Change", () => EditorGUILayout.TextField("Name", node.Name), s => node.Name = s); NodeTypeDataDrawer.Draw(node); }
private static int Cleanup <T>(T audioRoot, Action <T, HashSet <MonoBehaviour> > traverse) where T : MonoBehaviour { if (audioRoot == null) { return(0); } HashSet <MonoBehaviour> objects = new HashSet <MonoBehaviour>(); var allNodes = audioRoot.GetComponents <MonoBehaviour>(); for (int i = 0; i < allNodes.Length; ++i) { objects.Add(allNodes[i]); } HashSet <MonoBehaviour> inUse = new HashSet <MonoBehaviour>(); traverse(audioRoot, inUse); int deleted = 0; //Delete all objects not in use foreach (MonoBehaviour node in objects) { if (!inUse.Contains(node)) { deleted += 1; UndoHelper.PureDestroy(node); } } return(deleted); }
private void CreatePrefabPool() { var newPrefabPoolName = _settings.newPrefabPoolName; if (string.IsNullOrEmpty(newPrefabPoolName)) { DTInspectorUtility.ShowAlert("You must enter a name for your new Prefab Pool."); return; } var spawnPos = _settings.transform.position; var newPool = Instantiate(LevelSettings.Instance.PrefabPoolTrans.gameObject, spawnPos, Quaternion.identity) as GameObject; // ReSharper disable once PossibleNullReferenceException newPool.name = newPrefabPoolName; var poolsHolder = _settings.transform; var dupe = poolsHolder.GetChildTransform(newPrefabPoolName); if (dupe != null) { DTInspectorUtility.ShowAlert("You already have a Prefab Pool named '" + newPrefabPoolName + "', please choose another name."); DestroyImmediate(newPool); return; } UndoHelper.CreateObjectForUndo(newPool.gameObject, "create Prefab Pool"); newPool.transform.parent = poolsHolder.transform; }
protected override void OnDrop(InAudioBankLink node, Object[] objects) { UndoHelper.DragNDropUndo(node, "Bank Drag N Drop"); InAudioBankLink target = objects[0] as InAudioBankLink; NodeWorker.ReasignNodeParent(target, node); }
public override void OnInspectorGUI() { EditorGUIUtility.LookLikeControls(); EditorGUI.indentLevel = 0; var kill = (KillableChildVisibility)target; var isDirty = false; WorldVariableTracker.ClearInGamePlayerStats(); LevelSettings.Instance = null; // clear cached version DTInspectorUtility.DrawTexture(CoreGameKitInspectorResources.LogoTexture); var newKillableToAlert = (Killable)EditorGUILayout.ObjectField("Killable To Alert", kill.killableWithRenderer, typeof(Killable), true); if (newKillableToAlert != kill.killableWithRenderer) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, kill, "change Killable To Alert"); kill.killableWithRenderer = newKillableToAlert; } if (GUI.changed || isDirty) { EditorUtility.SetDirty(target); // or it won't save the data!! } //DrawDefaultInspector(); }
private void CreateCategory() { if (string.IsNullOrEmpty(_pool.newCategoryName)) { DTInspectorUtility.ShowAlert("You cannot have a blank Category name."); return; } // ReSharper disable once ForCanBeConvertedToForeach for (var c = 0; c < _pool._categories.Count; c++) { var cat = _pool._categories[c]; // ReSharper disable once InvertIf if (cat.CatName == _pool.newCategoryName) { DTInspectorUtility.ShowAlert("You already have a Category named '" + _pool.newCategoryName + "'. Category names must be unique."); return; } } UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _pool, "Create New Category"); var newCat = new PoolBossCategory { CatName = _pool.newCategoryName, ProspectiveName = _pool.newCategoryName, }; _pool._categories.Add(newCat); }
public override void OnInspectorGUI() { _settings = (TriggeredDespawner)target; LevelSettings.Instance = null; // clear cached version DTInspectorUtility.DrawTexture(CoreGameKitInspectorResources.LogoTexture); _isDirty = false; EditorGUI.indentLevel = 0; var hadNoListener = _settings.listener == null; var newListener = (TriggeredDespawnerListener)EditorGUILayout.ObjectField("Listener", _settings.listener, typeof(TriggeredDespawnerListener), true); if (newListener != _settings.listener) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "assign Listener"); _settings.listener = newListener; if (hadNoListener && _settings.listener != null) { _settings.listener.sourceDespawnerName = _settings.transform.name; } } var changedList = new List <bool> { RenderEventTypeControls(_settings.invisibleSpec, "Invisible Event", TriggeredSpawner.EventType.Invisible), RenderEventTypeControls(_settings.mouseOverSpec, "Mouse Over (Legacy) Event", TriggeredSpawner.EventType.MouseOver_Legacy), RenderEventTypeControls(_settings.mouseClickSpec, "Mouse Click (Legacy) Event", TriggeredSpawner.EventType.MouseClick_Legacy), RenderEventTypeControls(_settings.collisionSpec, "Collision Enter Event", TriggeredSpawner.EventType.OnCollision), RenderEventTypeControls(_settings.triggerEnterSpec, "Trigger Enter Event", TriggeredSpawner.EventType.OnTriggerEnter), RenderEventTypeControls(_settings.triggerExitSpec, "Trigger Exit Event", TriggeredSpawner.EventType.OnTriggerExit), RenderEventTypeControls(_settings.onClickSpec, "NGUI OnClick Event", TriggeredSpawner.EventType.OnClick_NGUI), RenderEventTypeControls(_settings.collision2dSpec, "2D Collision Enter Event", TriggeredSpawner.EventType.OnCollision2D), RenderEventTypeControls(_settings.triggerEnter2dSpec, "2D Trigger Enter Event", TriggeredSpawner.EventType.OnTriggerEnter2D), RenderEventTypeControls(_settings.triggerExit2dSpec, "2D Trigger Exit Event", TriggeredSpawner.EventType.OnTriggerExit2D) }; #if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 // not supported #else #endif if (GUI.changed || _isDirty || changedList.Contains(true)) { EditorUtility.SetDirty(target); // or it won't save the data!! } //DrawDefaultInspector(); }
protected override void OnDrop(InAudioBus dropOn, Object[] objects) { var beingDragged = objects[0] as InAudioBus; UndoHelper.RecordObject(new Object[] { dropOn, beingDragged, beingDragged.Parent }, "Bus drag n drop"); NodeWorker.ReasignNodeParent(beingDragged, dropOn); }
public static void DrawBus(InAudioNode node) { if (!node.IsRoot) { bool overrideParent = EditorGUILayout.Toggle("Override Parent Bus", node.OverrideParentBus); if (overrideParent != node.OverrideParentBus) { UndoHelper.RecordObjectFull(new Object[] { node.NodeData, node }, "Override parent bus"); node.OverrideParentBus = overrideParent; } if (!node.OverrideParentBus) { GUI.enabled = false; } } EditorGUILayout.BeginHorizontal(); // if (node.GetBus() != null) { var usedBus = node.GetBus(); if (usedBus != null) { EditorGUILayout.TextField("Used Bus", usedBus.Name); } else { EditorGUILayout.TextField("Used Bus", "Missing bus"); } } else { GUILayout.Label("Missing node"); } if (GUILayout.Button("Find")) { SearchHelper.SearchFor(node.Bus); } GUI.enabled = true; GUILayout.Button("Drag bus here to assign"); var buttonArea = GUILayoutUtility.GetLastRect(); var bus = HandleBusDrag(buttonArea); if (bus != null) { UndoHelper.RecordObjectFull(node, "Assign bus"); node.Bus = bus; node.OverrideParentBus = true; Event.current.Use(); } EditorGUILayout.EndHorizontal(); }
private void ExpandCollapseAll(bool isExpand) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _holder, "toggle expand / collapse all World Variables"); foreach (var variable in _stats) { variable.isExpanded = isExpand; } }
private void ExpandCollapseAll(WavePrefabPool pool, bool isExpand) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle expand / collapse all"); foreach (var poolItem in pool.poolItems) { poolItem.isExpanded = isExpand; } }
private void CreateChildBus(object userData) { InAudioBus bus = userData as InAudioBus; UndoHelper.DoInGroup(() => { UndoHelper.RecordObjectFull(bus, "Bus Creation"); AudioBusWorker.CreateChild(bus); }); }
private void CreateChild(InAudioEventNode node, EventNodeType type) { UndoHelper.DoInGroup(() => { UndoHelper.RegisterUndo(node, "Event Creation"); AudioEventWorker.CreateNode(node, type); }); node.FoldedOut = true; }
private void CreateChild(InAudioNode parent, AudioNodeType type) { UndoHelper.RecordObjectFull(new UnityEngine.Object[] { parent, parent.GetBank().LazyBankFetch }, "Create Audio Node"); var newNode = AudioNodeWorker.CreateChild(parent, type); if (type == AudioNodeType.Audio) { AudioBankWorker.AddNodeToBank(newNode, null); } }
public override void OnInspectorGUI() { EditorGUIUtility.LookLikeControls(); EditorGUI.indentLevel = 0; var settings = (TimedDespawner)target; LevelSettings.Instance = null; // clear cached version DTInspectorUtility.DrawTexture(CoreGameKitInspectorResources.LogoTexture); var isDirty = false; EditorGUILayout.Separator(); var newStartTimer = EditorGUILayout.Toggle("Start Timer On Awake", settings.StartTimerOnSpawn); if (newStartTimer != settings.StartTimerOnSpawn) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, settings, "toggle Start Timer On Awake"); settings.StartTimerOnSpawn = newStartTimer; } var newLifeSeconds = EditorGUILayout.Slider("Despawn Timer (sec)", settings.LifeSeconds, .1f, 50f); if (newLifeSeconds != settings.LifeSeconds) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, settings, "change Despawn Timer"); settings.LifeSeconds = newLifeSeconds; } var hadNoListener = settings.listener == null; var newListener = (TimedDespawnerListener)EditorGUILayout.ObjectField("Listener", settings.listener, typeof(TimedDespawnerListener), true); if (newListener != settings.listener) { UndoHelper.RecordObjectPropertyForUndo(ref isDirty, settings, "assign Listener"); settings.listener = newListener; if (hadNoListener && settings.listener != null) { settings.listener.sourceDespawnerName = settings.transform.name; } } if (GUI.changed || isDirty) { EditorUtility.SetDirty(target); // or it won't save the data!! } //DrawDefaultInspector(); }
private void DeleteBus(int busIndex) { DynamicSoundGroup aGroup = null; var groupsWithBus = new List <DynamicSoundGroup>(); var groupsWithHigherBus = new List <DynamicSoundGroup>(); for (var i = 0; i < this._groups.Count; i++) { aGroup = this._groups[i]; if (aGroup.busIndex == -1) { continue; } if (aGroup.busIndex == busIndex + DynamicSoundGroupCreator.HardCodedBusOptions) { groupsWithBus.Add(aGroup); } else if (aGroup.busIndex > busIndex + DynamicSoundGroupCreator.HardCodedBusOptions) { groupsWithHigherBus.Add(aGroup); } } var allObjects = new List <UnityEngine.Object>(); allObjects.Add(_creator); foreach (var g in groupsWithBus) { allObjects.Add(g as UnityEngine.Object); } foreach (var g in groupsWithHigherBus) { allObjects.Add(g as UnityEngine.Object); } UndoHelper.RecordObjectsForUndo(allObjects.ToArray(), "delete Bus"); // change all _creator.groupBuses.RemoveAt(busIndex); foreach (var group in groupsWithBus) { group.busIndex = -1; } foreach (var group in groupsWithHigherBus) { group.busIndex--; } }
private void CreateBank(InAudioBankLink parent, AudioBankTypes type) { //TODO make real undo UndoHelper.RecordObjectFull(parent, "Bank " + (type == AudioBankTypes.Folder ? "Folder " : "") + "Creation"); if (type == AudioBankTypes.Folder) { AudioBankWorker.CreateFolder(parent.gameObject, parent, GUIDCreator.Create()); } else { AudioBankWorker.CreateBank(parent.gameObject, parent, GUIDCreator.Create()); } }
public override void OnInspectorGUI() { EditorGUIUtility.LookLikeControls(); EditorGUI.indentLevel = 0; var ma = MasterAudio.Instance; if (ma != null) { DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.logoTexture); } ButtonClicker sounds = (ButtonClicker)target; maInScene = ma != null; if (maInScene) { groupNames = ma.GroupNames; } var resizeOnClick = EditorGUILayout.Toggle("Resize On Click", sounds.resizeOnClick); if (resizeOnClick != sounds.resizeOnClick) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Resize On Click"); sounds.resizeOnClick = resizeOnClick; } var resizeOnHover = EditorGUILayout.Toggle("Resize On Hover", sounds.resizeOnHover); if (resizeOnHover != sounds.resizeOnHover) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Resize On Hover"); sounds.resizeOnHover = resizeOnHover; } EditSoundGroup(sounds, ref sounds.mouseDownSound, "Mouse Down Sound"); EditSoundGroup(sounds, ref sounds.mouseUpSound, "Mouse Up Sound"); EditSoundGroup(sounds, ref sounds.mouseClickSound, "Mouse Click Sound"); EditSoundGroup(sounds, ref sounds.mouseOverSound, "Mouse Over Sound"); EditSoundGroup(sounds, ref sounds.mouseOutSound, "Mouse Out Sound"); if (GUI.changed) { EditorUtility.SetDirty(target); } this.Repaint(); //DrawDefaultInspector(); }
private void AddActiveLimit(string modifierName, WavePrefabPoolItem spec) { if (spec.activeItemCriteria.HasKey(modifierName)) { DTInspectorUtility.ShowAlert("This item already has a Active Limit for World Variable: " + modifierName + ". Please modify the existing one instead."); return; } UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "add Active Limit"); var myVar = WorldVariableTracker.GetWorldVariableScript(modifierName); spec.activeItemCriteria.statMods.Add(new WorldVariableRange(modifierName, myVar.varType)); }
private void ExpandCollapseAll(bool isExpand) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _pool, "toggle expand / collapse all Pool Boss Items"); if (isExpand) { _pool.poolItemsExpanded = true; } foreach (var item in _pool.poolItems) { item.isExpanded = isExpand; } }
private void ExpandCollapseAll(bool isExpand) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _pool, PoolBossLang.ToggleItems); foreach (var cat in _pool._categories) { cat.IsExpanded = isExpand; } foreach (var item in _pool.poolItems) { item.isExpanded = isExpand; } }
private void ExpandCollapseCategory(string category, bool isExpand) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _pool, "toggle expand / collapse all items in Category"); foreach (var item in _pool.poolItems) { if (item.categoryName != category) { continue; } item.isExpanded = isExpand; } }
private void CreateDynamicSoundGroupCreator() { var pc = Resources.LoadAssetAtPath(MasterAudioFolderPath + "/Prefabs/DynamicSoundGroupCreator.prefab", typeof(GameObject)); if (pc == null) { Debug.LogError("Could not find DynamicSoundGroupCreator prefab. Please drag it into the scene yourself. It is located under MasterAudio/Prefabs."); return; } var go = GameObject.Instantiate(pc) as GameObject; go.name = "DynamicSoundGroupCreator"; UndoHelper.CreateObjectForUndo(go, "Create Dynamic Sound Group Creator prefab"); }
public void EqualizeWeights(DynamicSoundGroup _group) { var variations = new DynamicGroupVariation[_group.groupVariations.Count]; DynamicGroupVariation variation = null; for (var i = 0; i < _group.groupVariations.Count; i++) { variation = _group.groupVariations[i]; variations[i] = variation; } UndoHelper.RecordObjectsForUndo(variations, "Equalize Weights"); foreach (var vari in variations) { vari.weight = 1; } }
private void CreatePlaylistController() { var pc = Resources.LoadAssetAtPath(MasterAudioFolderPath + "/Prefabs/PlaylistController.prefab", typeof(GameObject)); if (pc == null) { Debug.LogError("Could not find PlaylistController prefab. Please drag it into the scene yourself. It is located under MasterAudio/Prefabs."); return; } var go = PrefabUtility.InstantiatePrefab(pc) as GameObject; go.name = "PlaylistController"; UndoHelper.CreateObjectForUndo(go, "Create Playlist Controller prefab"); }