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 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; }
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"); }
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"); }
private void CreateMasterAudio() { var ma = Resources.LoadAssetAtPath(MasterAudioFolderPath + "/Prefabs/MasterAudio.prefab", typeof(GameObject)); if (ma == null) { Debug.LogError("Could not find MasterAudio prefab. Please drag it into the scene yourself. It is located under MasterAudio/Prefabs."); return; } var go = GameObject.Instantiate(ma) as GameObject; UndoHelper.CreateObjectForUndo(go, "Create Master Audio prefab"); go.name = "MasterAudio"; }
private void CreateNewVariable(string varName, WorldVariableTracker.VariableType varType) { varName = varName.Trim(); var match = _holder.transform.GetChildTransform(varName); if (match != null) { DTInspectorUtility.ShowAlert("You already have a World Variable named '" + varName + "'. Please choose a unique name."); return; } var newStat = (GameObject)Instantiate(_holder.statPrefab.gameObject, _holder.transform.position, Quaternion.identity); UndoHelper.CreateObjectForUndo(newStat, "create World Variable"); newStat.name = varName; var variable = newStat.GetComponent <WorldVariable>(); variable.varType = varType; newStat.transform.parent = _holder.transform; }