static void CheckSecondRootView_Config(string[] splitString, string root, EditorSoundConfigData data) { //如果长度是2,表明,只在这个跟节点里而已,直接添加进去就行 if (splitString.Length == 1) { data.ParentTreeViewName = string.Empty; data.HostTreeViewName = root; ConfigRootTreeView[root].configList.Add(data); } else//如果不是,则看看次级节点 { //第二根节点 string secondRoot = splitString[1]; //第二根节点已经存在,直接添加进去就行 if (ConfigSecondRootTreeView.ContainsKey(secondRoot)) { data.HostTreeViewName = secondRoot; data.ParentTreeViewName = root; ConfigSecondRootTreeView[secondRoot].configList.Add(data); } else //不存在,新建一个,再添加进去 { ConfigRootTreeView[root].ChildViewList.Add(secondRoot); TreeViewNode nod = new TreeViewNode(); nod.TreeViewName = secondRoot; nod.ParentTreeViewName = root; nod.configList.Add(data); data.HostTreeViewName = secondRoot; data.ParentTreeViewName = root; ConfigSecondRootTreeView.Add(secondRoot, nod); } } }
private static void DeleteCurrentConfig() { CurrentSoundConfigTable.Remove(currentSelectedConfig.data.nID); DeleteTreeView_Config(currentSelectedConfig); SoundIDAllocator.Instance.PushUnUsedId(currentSelectedConfig.data.nID); currentSelectedConfig = null; }
static void DeleteTreeView_Config(EditorSoundConfigData s) { //是在根节点 if (ConfigRootTreeView.ContainsKey(s.HostTreeViewName)) { ConfigRootTreeView[s.HostTreeViewName].configList.Remove(s); } else { if (ConfigSecondRootTreeView.ContainsKey(s.HostTreeViewName)) { ConfigSecondRootTreeView[s.HostTreeViewName].configList.Remove(s); } } }
static void GenerateHostTreeView_Config(EditorSoundConfigData s) { //如果assetbundlename是空的,直接扔到NewConfig里去 if (string.IsNullOrEmpty(s.data.AssetBundleName)) { s.ParentTreeViewName = string.Empty; s.HostTreeViewName = NewConfigRoot; ConfigRootTreeView[NewConfigRoot].configList.Add(s); return; } //用于判断的节点不能有后缀 string treepatch = s.data.AssetBundleName.Replace(".soundpkg", ""); //去掉sound头 treepatch = treepatch.Replace("sound/", ""); string[] splitString = treepatch.Split('/'); string root = splitString[0]; //如果根节点表里有这个节点 if (ConfigRootTreeView.ContainsKey(root)) { s.ParentTreeViewName = string.Empty; //再去检查第二根节点 CheckSecondRootView_Config(splitString, root, s); } else { //新建跟节点 TreeViewNode no = new TreeViewNode(); no.ParentTreeViewName = string.Empty; no.TreeViewName = root; ConfigRootTreeView.Add(root, no); //再去检查第二根节点 CheckSecondRootView_Config(splitString, root, s); } }
private static void CreateNewConfig() { EditorSoundConfigData newdata = new EditorSoundConfigData(); newdata.data = new SoundConfigData(); newdata.data.nID = SoundIDAllocator.Instance.AllocId(); newdata.data.soundType = EMSoundType.Skill; newdata.data.mixerGroupType = AudioMixerGroupType.Actor; newdata.data.nMixerGroupIndex = 0; newdata.data.bBypassEffect = false; newdata.data.bBypassReverbZone = false; newdata.data.bPlayOnAwake = true; newdata.data.nPriority = 128; newdata.data.fPitch = 1; newdata.data.fStereoPan = 0; newdata.data.fReverZoneMix = 1; newdata.data.b3DSound = true; newdata.data.fDopplerLv = 1; newdata.data.nSpread = 0; newdata.data.audioRoffType = AudioRolloffMode.Logarithmic; newdata.data.fMinDistance = 1; newdata.data.fMaxDistance = 15; newdata.data.nPlayTimes = 1; newdata.data.fDuartion = 0; newdata.data.fDelayPlayTime = 0; newdata.data.fIntervalBetweenPlayTimes = 0; newdata.data.AssetBundleName = string.Empty; newdata.data.AssetName = string.Empty; newdata.data.AssetGUID = string.Empty; newdata.data.szDependAssetGUID = string.Empty; newdata.HostTreeViewName = DefaultRoot; SoundIDAllocator.Instance.AcceptAlloc(); CurrentSoundConfigTable.Add(newdata.data.nID, newdata); currentSelectedConfig = newdata; ConfigRootTreeView[NewConfigRoot].configList.Add(newdata); GenerateHostTreeView_Config(currentSelectedConfig); CloseAllTreeView(); OpenTreeView(currentSelectedConfig.HostTreeViewName); }
private static void LoadSoundConfig() { string patch = GetConfigPatch(); //if (!File.Exists(patch)) //{ // return; //} //string stSchemeAllText = System.IO.File.ReadAllText(patch); ////去掉\n,因为ScpReader以"\r"分割 //stSchemeAllText = stSchemeAllText.Replace("\n", ""); ////再干掉最后的"\r" //stSchemeAllText = stSchemeAllText.Remove(stSchemeAllText.Length - 1, 1); //ScpReader SoundReader = new ScpReader(stSchemeAllText, "SoundConfig", 2); ScpReader SoundReader = new ScpReader(patch, true, 2); // 遍歷整個表并存儲起來 for (int i = 0; i < SoundReader.GetRecordCount(); ++i) { EditorSoundConfigData cfgData = new EditorSoundConfigData(); cfgData.data = new SoundConfigData(); cfgData.data.nID = SoundReader.GetInt(i, (int)SoundConfigCol.COL_ID, 0); cfgData.data.soundType = (EMSoundType)SoundReader.GetInt(i, (int)SoundConfigCol.COL_Type, 2); cfgData.data.mixerGroupType = (AudioMixerGroupType)SoundReader.GetInt(i, (int)SoundConfigCol.COL_MixerGroupType, 1); cfgData.data.nMixerGroupIndex = SoundReader.GetInt(i, (int)SoundConfigCol.COL_MixerGroupIndex, 0); cfgData.data.bBypassEffect = SoundReader.GetInt(i, (int)SoundConfigCol.COL_BypassEffect, 0) > 0; cfgData.data.bBypassReverbZone = SoundReader.GetInt(i, (int)SoundConfigCol.COL_BypassReverbZone, 0) > 0; cfgData.data.bPlayOnAwake = SoundReader.GetInt(i, (int)SoundConfigCol.COL_PlayOnAwake, 1) > 0; cfgData.data.nPriority = Mathf.Clamp(SoundReader.GetInt(i, (int)SoundConfigCol.COL_Priority, 128), 0, 256); cfgData.data.fPitch = Mathf.Clamp(SoundReader.GetFloat(i, (int)SoundConfigCol.COL_Pitch, 1), -3.0f, 3.0f); cfgData.data.fStereoPan = Mathf.Clamp(SoundReader.GetFloat(i, (int)SoundConfigCol.COL_StereoPan, 0), -1.0f, 1.0f); cfgData.data.fReverZoneMix = Mathf.Clamp(SoundReader.GetFloat(i, (int)SoundConfigCol.COL_ReverZoneMix, 1), 0, 1.1f); cfgData.data.b3DSound = SoundReader.GetInt(i, (int)SoundConfigCol.COL_3DSound, 1) > 0; cfgData.data.fDopplerLv = Mathf.Clamp(SoundReader.GetFloat(i, (int)SoundConfigCol.COL_DopplerLv, 1), 0, 5.0f); cfgData.data.nSpread = Mathf.Clamp(SoundReader.GetInt(i, (int)SoundConfigCol.COL_Spread, 0), 0, 360);; cfgData.data.audioRoffType = (AudioRolloffMode)SoundReader.GetInt(i, (int)SoundConfigCol.COL_RolloffMode, 0); cfgData.data.fMinDistance = SoundReader.GetFloat(i, (int)SoundConfigCol.COL_MinDistance, 1); cfgData.data.fMaxDistance = SoundReader.GetFloat(i, (int)SoundConfigCol.COL_MaxDistance, 15); cfgData.data.nPlayTimes = SoundReader.GetInt(i, (int)SoundConfigCol.COL_PlayTimes, 1); cfgData.data.fDuartion = SoundReader.GetFloat(i, (int)SoundConfigCol.COL_Duartion, 0); cfgData.data.fDelayPlayTime = SoundReader.GetFloat(i, (int)SoundConfigCol.COL_DelayTime, 0); cfgData.data.fIntervalBetweenPlayTimes = SoundReader.GetFloat(i, (int)SoundConfigCol.COL_IntervalBetweenPlayTimes, 0); cfgData.data.AssetBundleName = SoundReader.GetString(i, (int)SoundConfigCol.COL_AssetBundleName, ""); cfgData.data.AssetName = SoundReader.GetString(i, (int)SoundConfigCol.COL_AssetName, ""); cfgData.data.AssetGUID = SoundReader.GetString(i, (int)SoundConfigCol.COL_AssetGUID, ""); cfgData.data.AssetSize_X = SoundReader.GetFloat(i, (int)SoundConfigCol.COL_AssetSize_X, -1); cfgData.data.AssetSize_Y = SoundReader.GetFloat(i, (int)SoundConfigCol.COL_AssetSize_Y, -1); cfgData.data.szDependAssetGUID = SoundReader.GetString(i, (int)SoundConfigCol.COL_DependAssetGUID, ""); cfgData.HostTreeViewName = string.Empty; CurrentSoundConfigTable.Add(cfgData.data.nID, cfgData); SoundIDAllocator.Instance.PushUsedId(cfgData.data.nID); } SoundIDAllocator.Instance.CalculateUnUsedID(); SoundReader.Dispose(); SoundReader = null; currentSelectedConfig = null; GenrateConfigTreeView(); }