private bool isMatch(TextureInfo texInfo) { switch (_mode) { case TextureViewerMode.ReadWrite: return(ReadWriteEnable == texInfo.ReadWriteEnable); case TextureViewerMode.MipMap: return(MipmapEnable == texInfo.MipmapEnable); case TextureViewerMode.Type: return(ImportType == texInfo.ImportType); case TextureViewerMode.Resolution: return(SizeIndex == ViewerConst.GetTextureSizeIndex(texInfo.Width, texInfo.Height)); case TextureViewerMode.WidthVSHeight: return(WidthAndHeight == (texInfo.Width == texInfo.Height)); case TextureViewerMode.StandaloneFormat: return(StandaloneFormat == texInfo.StandaloneFormat); case TextureViewerMode.AndroidFormat: return(AndroidFormat == texInfo.AndroidFormat); case TextureViewerMode.iOSFormat: return(IosFormat == texInfo.IosFormat); case TextureViewerMode.FilterMode: return(FilterMode == texInfo.FilterMode); } return(false); }
public static ParticleInfo[] CreateParticleInfo(string assetPath) { if (!EditorPath.IsPrefab(assetPath)) { return(null); } GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(assetPath); ParticleSystem[] particleSystem = prefab.GetComponentsInChildren <ParticleSystem>(); ParticleInfo[] particleInfo = new ParticleInfo[particleSystem.Length]; for (int i = 0; i < particleSystem.Length; i++) { particleInfo[i] = new ParticleInfo(); particleInfo[i].Path = assetPath; particleInfo[i].RealPath = assetPath + "/" + ViewerConst.GetPath(particleSystem[i].transform); particleInfo[i].MaxParticles = particleSystem[i].main.maxParticles; particleInfo[i].Duration = particleSystem[i].main.duration; particleInfo[i].PlayOnAwake = particleSystem[i].main.playOnAwake; particleInfo[i].Looping = particleSystem[i].main.loop; } return(particleInfo); }
public Viewer(EditorWindow hostWindow) { Assert.IsNotNull(hostWindow); _viewerModeManager = ViewerConst.GetSingletonInstance <V>(); _healthInfoManager = ViewerConst.GetSingletonInstance <H>(); _modeInit = new Dictionary <string, bool>(); _modeData = new Dictionary <string, List <object> >(); _modeHealth = new Dictionary <string, Health>(); _mode = _viewerModeManager.GetMode()[0]; foreach (var key in _viewerModeManager.GetMode()) { _modeInit[key] = false; _modeData[key] = new List <object>(); } _dataTable = new TableView(hostWindow, typeof(T)); _showTable = new TableView(hostWindow, typeof(U)); _dataTable.OnSelected += OnDataSelected; _showTable.OnSelected += OnInfoSelected; UpdateDataTableTitle(); UpdateShowTableTitle(); }
private bool isMatch(ShaderInfo shaderInfo) { switch (_mode) { case ShaderViewerMode.MaxLOD: return(MaxLOD == ViewerConst.GetLodIndex(shaderInfo.MaxLOD)); case ShaderViewerMode.RenderQueue: return(RenderQueue == ViewerConst.GetRenderQueueIndex(shaderInfo.RenderQueue)); case ShaderViewerMode.Pass: return(Pass == shaderInfo.Pass); case ShaderViewerMode.Instruction: return(Instruction == ViewerConst.GetInstructionIndex(shaderInfo.Instruction)); case ShaderViewerMode.Variant: return(Variant == shaderInfo.Variant); case ShaderViewerMode.Property: return(Property == shaderInfo.Property); case ShaderViewerMode.SubShader: return(SubShader == shaderInfo.SubShader); case ShaderViewerMode.Sample: return(Sample == shaderInfo.Sample); case ShaderViewerMode.RenderType: return(RenderType == shaderInfo.RenderType); } return(false); }
public ParticleViewerData(string mode, ParticleInfo particleInfo) { _mode = (ParticleViewerMode)Enum.Parse(typeof(ParticleViewerMode), mode); MaxParticle = particleInfo.MaxParticles; SizeIndex = ViewerConst.GetParticleSizeIndex(particleInfo.MaxParticles); SizeStr = ViewerConst.ParticleSizeStr[SizeIndex]; Duration = particleInfo.Duration; DurationIndex = ViewerConst.GetDurationIndex(particleInfo.Duration); DurtationStr = ViewerConst.DurationSizeStr[DurationIndex]; PlayOnAwake = particleInfo.PlayOnAwake; Looping = particleInfo.Looping; }
public TextureViewerData(string mode, TextureInfo texInfo) { _mode = (TextureViewerMode)Enum.Parse(typeof(TextureViewerMode), mode); ReadWriteEnable = texInfo.ReadWriteEnable; MipmapEnable = texInfo.MipmapEnable; ImportType = texInfo.ImportType; StandaloneFormat = texInfo.StandaloneFormat; AndroidFormat = texInfo.AndroidFormat; IosFormat = texInfo.IosFormat; WidthAndHeight = texInfo.Width == texInfo.Height; SizeIndex = ViewerConst.GetTextureSizeIndex(texInfo.Width, texInfo.Height); SizeStr = ViewerConst.TextureSizeStr[SizeIndex]; Width = texInfo.Width; Height = texInfo.Height; FilterMode = texInfo.FilterMode; }
public ShaderViewerData(string mode, ShaderInfo shaderInfo) { _mode = (ShaderViewerMode)Enum.Parse(typeof(ShaderViewerMode), mode); MaxLOD = ViewerConst.GetLodIndex(shaderInfo.MaxLOD); MaxLODStr = ViewerConst.LoadSizeStr[MaxLOD]; RenderQueue = ViewerConst.GetRenderQueueIndex(shaderInfo.RenderQueue); RenderQueueStr = ViewerConst.RenderQueueStr[RenderQueue]; Pass = shaderInfo.Pass; Instruction = ViewerConst.GetInstructionIndex(shaderInfo.Instruction); InstructionStr = ViewerConst.InstructionSizeStr[Instruction]; Variant = shaderInfo.Variant; Property = shaderInfo.Property; SubShader = shaderInfo.SubShader; Sample = shaderInfo.Sample; RenderType = shaderInfo.RenderType; }
public static AudioInfo CreateAudioInfo(string assetPath) { if (!EditorPath.IsAudio(assetPath)) { return(null); } AudioInfo audioInfo = null; if (!_dictAudioInfo.TryGetValue(assetPath, out audioInfo)) { audioInfo = new AudioInfo(); _dictAudioInfo.Add(assetPath, audioInfo); } AudioImporter audioImporter = AssetImporter.GetAtPath(assetPath) as AudioImporter; AudioClip audioClip = AssetDatabase.LoadAssetAtPath <AudioClip>(assetPath); if (audioImporter == null || audioClip == null) { Debug.LogError("audioImporter is empty"); return(null); } audioInfo.Path = assetPath; audioInfo.ForceToMono = audioImporter.forceToMono; audioInfo.LoadInBackground = audioImporter.loadInBackground; audioInfo.Ambisonic = audioImporter.ambisonic; audioInfo.MemSize = EditorTool.GetRuntimeMemorySize(audioClip); audioInfo.ImportedSize = EditorTool.GetRuntimeMemorySize(audioClip); audioInfo.StandAloneAudioClipLoadType = audioImporter.GetOverrideSampleSettings("Standalone").loadType; audioInfo.AndroidAudioClipLoadType = audioImporter.GetOverrideSampleSettings("Android").loadType; audioInfo.iOSAudioClipLoadType = audioImporter.GetOverrideSampleSettings("iOS").loadType; audioInfo.StandAloneAudioCompressionFormat = audioImporter.GetOverrideSampleSettings("Standalone").compressionFormat; audioInfo.AndroidAudioCompressionFormat = audioImporter.GetOverrideSampleSettings("Android").compressionFormat; audioInfo.iOSAudioCompressionFormat = audioImporter.GetOverrideSampleSettings("iOS").compressionFormat; audioInfo.OriginSize = ViewerConst.GetInternalValue <int>(audioImporter, "get_origSize", null); audioInfo.CompressedSize = ViewerConst.GetInternalValue <int>(audioImporter, "get_compSize", null); if (++_loadCount % 256 == 0) { Resources.UnloadUnusedAssets(); } return(audioInfo); }
private bool isMatch(ParticleInfo particleInfo) { switch (_mode) { case ParticleViewerMode.MaxParticle: return(SizeIndex == ViewerConst.GetParticleSizeIndex(particleInfo.MaxParticles)); case ParticleViewerMode.Duration: return(DurationIndex == ViewerConst.GetDurationIndex(particleInfo.Duration)); case ParticleViewerMode.PlayOnAwake: return(PlayOnAwake == particleInfo.PlayOnAwake); case ParticleViewerMode.Looping: return(Looping == particleInfo.Looping); } return(false); }
private void LoadHealthConfig() { string configName = HealthConfigPopup.s_healthConfigs[HealthConfigPopup.s_currentMode]; HealthConfig.ConfigJson configJson = HealthConfig.Instance().GetConfig(configName); // ------------------------------------------------Texture------------------------------------------------ ViewerConst.GetSingletonInstance <TextureHealthInfoManager>().Clear(); foreach (string mode in ViewerConst.GetSingletonInstance <TextureViewerModeManager>().GetMode()) { HealthConfig.ModeConfig modeConfig = configJson.GetModeConfig("Texture", mode); if (modeConfig != null) { ViewerConst.GetSingletonInstance <TextureHealthInfoManager>().AddHealthInfo(mode, modeConfig.Enable, modeConfig.Tip, modeConfig.ConfigValue, modeConfig.Condition); } } // ------------------------------------------------Model------------------------------------------------ ViewerConst.GetSingletonInstance <ModelHealthInfoManager>().Clear(); foreach (string mode in ViewerConst.GetSingletonInstance <ModelViewerModeManager>().GetMode()) { HealthConfig.ModeConfig modeConfig = configJson.GetModeConfig("Model", mode); if (modeConfig != null) { ViewerConst.GetSingletonInstance <ModelHealthInfoManager>().AddHealthInfo(mode, modeConfig.Enable, modeConfig.Tip, modeConfig.ConfigValue, modeConfig.Condition); } } // ------------------------------------------------Particle------------------------------------------------ ViewerConst.GetSingletonInstance <ParticleHealthInfoManager>().Clear(); foreach (string mode in ViewerConst.GetSingletonInstance <ParticleViewerModeManager>().GetMode()) { HealthConfig.ModeConfig modeConfig = configJson.GetModeConfig("Particle", mode); if (modeConfig != null) { ViewerConst.GetSingletonInstance <ParticleHealthInfoManager>().AddHealthInfo(mode, modeConfig.Enable, modeConfig.Tip, modeConfig.ConfigValue, modeConfig.Condition); } } // ------------------------------------------------Shader------------------------------------------------ ViewerConst.GetSingletonInstance <ShaderHealthInfoManager>().Clear(); foreach (string mode in ViewerConst.GetSingletonInstance <ShaderViewerModeManager>().GetMode()) { HealthConfig.ModeConfig modeConfig = configJson.GetModeConfig("Shader", mode); if (modeConfig != null) { ViewerConst.GetSingletonInstance <ShaderHealthInfoManager>().AddHealthInfo(mode, modeConfig.Enable, modeConfig.Tip, modeConfig.ConfigValue, modeConfig.Condition); } } // ------------------------------------------------Audio------------------------------------------------ ViewerConst.GetSingletonInstance <AudioHealthInfoManager>().Clear(); foreach (string mode in ViewerConst.GetSingletonInstance <AudioViewerModeManager>().GetMode()) { HealthConfig.ModeConfig modeConfig = configJson.GetModeConfig("Audio", mode); if (modeConfig != null) { ViewerConst.GetSingletonInstance <AudioHealthInfoManager>().AddHealthInfo(mode, modeConfig.Enable, modeConfig.Tip, modeConfig.ConfigValue, modeConfig.Condition); } } }
public bool SwitchMode(string mode, bool forceRefresh = false) { if (_mode == mode && !forceRefresh) { return(false); } _mode = mode; if (!_modeInit[mode] && _infoList != null) { _modeInit[mode] = true; for (int i = 0; i < _infoList.Count; ++i) { // 1. show progress bar EditorUtility.DisplayProgressBar("刷新数据", System.IO.Path.GetFileName(_infoList[i].Path), (i * 1.0f) / _infoList.Count); // 2. find data bool find = false; for (int j = 0; j < _modeData[mode].Count; j++) { T viewerData = _modeData[mode][j] as T; if (viewerData.IsMatch(_infoList[i])) { find = true; viewerData.AddObject(_infoList[i]); break; } } if (!find) { T viewerData = (T)Activator.CreateInstance(typeof(T), _mode, _infoList[i]); viewerData.AddObject(_infoList[i]); _modeData[mode].Add(viewerData); } } if (_healthInfoManager.GetEnableCondition(mode)) { int validCount = 0; // config foreach (T viewerData in _modeData[mode]) { foreach (object condition in _healthInfoManager.GetConditionList(mode)) { validCount += viewerData.GetMatchHealthCount(condition); } } _modeHealth[mode] = new Health(ViewerConst.GetHealthState(_healthInfoManager.GetThreshold(mode), validCount), _healthInfoManager.GetTip(mode), _healthInfoManager.GetThreshold(mode), validCount); } else { _modeHealth[mode] = new Health(Health.HealthEnum.NONE, _healthInfoManager.GetTip(mode), 0, 0); } EditorUtility.ClearProgressBar(); } UpdateDataTableTitle(); UpdateShowTableTitle(); _dataTable.RefreshData(_modeData[mode]); return(true); }
public void Draw(Rect rect, KeyCode keyCode) { bool rebuild = false; GUILayout.BeginVertical(); { // 1. root path GUILayout.BeginHorizontal(TableStyles.Toolbar); { GUILayout.Label("RootPath: ", GUILayout.Width(100)); _rootPath = EditorGUILayout.TextField(_rootPath, TableStyles.TextField, GUILayout.Width(360)); Color origColor = GUI.backgroundColor; GUI.backgroundColor = Color.green; if (GUILayout.Button("Refresh Data", TableStyles.ToolbarButton, GUILayout.MaxWidth(120)) || keyCode == KeyCode.F5) { rebuild = true; RefreshData(forceRefresh: true); } GUI.backgroundColor = origColor; // drop down //GUILayout.FlexibleSpace(); EditorGUILayout.PrefixLabel("Threshod Selector", EditorStyles.miniButton); var modeContent = new GUIContent("Selector \u007C \u25BE"); var modeRect = GUILayoutUtility.GetRect(modeContent, EditorStyles.miniButton, GUILayout.ExpandWidth(false)); var modeDropRect = new Rect(modeRect.xMax - 16, modeRect.y, 16, modeRect.height); if (EditorGUI.DropdownButton(modeDropRect, GUIContent.none, FocusType.Passive, GUIStyle.none) || GUI.Button(modeRect, modeContent, EditorStyles.miniButton)) { PopupWindow.Show(modeRect, new HealthConfigPopup()); } } GUILayout.EndHorizontal(); // 2. mode GUILayout.BeginHorizontal(TableStyles.Toolbar); { GUILayout.Label("Mode: ", GUILayout.Width(100)); string[] mode = _viewerModeManager.GetMode(); rebuild = SwitchMode(mode[GUILayout.SelectionGrid(Array.IndexOf(mode, _mode), mode, mode.Length, TableStyles.ToolbarButton)]) || rebuild; } GUILayout.EndHorizontal(); // 3. health int healthHeight = 38; { if (_modeHealth.ContainsKey(_mode)) { StringBuilder sb = new StringBuilder(100); sb.Append(ViewerConst.GetHealthStateDesc(_modeHealth[_mode].State)); sb.Append(_modeHealth[_mode].Desc); if (_modeHealth[_mode].State != Health.HealthEnum.NONE) { if (_modeHealth[_mode].Threshold > 0) { sb.Append(string.Format(ViewerTableString.Recommand, _modeHealth[_mode].Threshold, _modeHealth[_mode].Value)); } else { sb.Append(string.Format(ViewerTableString.RecommandCurrent, _modeHealth[_mode].Value)); } } else { healthHeight = 17; } if (sb.Length != 0) { EditorGUILayout.HelpBox(sb.ToString(), (MessageType)Enum.ToObject(typeof(MessageType), (int)_modeHealth[_mode].State)); } else { healthHeight = 0; } } else { EditorGUILayout.HelpBox(ViewerTableString.NotInitTip, MessageType.Warning); } } // 4. select area { if (_modeInit[_mode]) { float startY = TableConst.RootPathHeight + TableConst.ModeHeight + TableConst.TableBorder + healthHeight; float height = rect.height - startY - 5; _dataTable.Draw(new Rect(TableConst.TableBorder, startY, rect.width * TableConst.SplitterRatio - 1.5f * TableConst.TableBorder, height), rebuild); _showTable.Draw(new Rect(rect.width * TableConst.SplitterRatio + 0.5f * TableConst.TableBorder, startY, rect.width * (1.0f - TableConst.SplitterRatio) - 1.5f * TableConst.TableBorder, height)); } } } GUILayout.EndVertical(); }