private void OnAtlasChangeComplete() { foreach (object o in targets) { TPHelper h = o as TPHelper; h.OnAtlasChangeComplete(); } }
private void OnAtlasChange(string atlasName) { foreach (object o in targets) { TPHelper h = o as TPHelper; h.OnAtlasChange(atlasName); } }
private void OnTextureChange(string textureName) { foreach (object o in targets) { TPHelper h = o as TPHelper; h.OnTextureChange(textureName); } }
//-------------------------------------- // PUBLIC METHODS //-------------------------------------- public override void OnInspectorGUI() { if (TPAssetPostprocessor.atlasesNames.Length == 0) { setMessage("No Atlas Found", MessageType.Error); } if (msgType != MessageType.Info) { EditorGUILayout.HelpBox(msg, msgType); } if (msgType != MessageType.Error) { string[] atlasesNames = TPAssetPostprocessor.atlasesNames; EditorGUI.BeginChangeCheck(); helper.atlasID = EditorGUILayout.Popup("Atlas: ", helper.atlasID, atlasesNames); foreach (object o in targets) { TPHelper h = o as TPHelper; h.atlasID = helper.atlasID; } if (EditorGUI.EndChangeCheck()) { OnAtlasChange(atlasesNames[helper.atlasID]); if (helper.meshTexture.TextureAtlas == null) { TPAssetPostprocessor.UpdateAtlasesInfromation(); return; } string[] textures = helper.meshTexture.TextureAtlas.frameNames; helper.textureID = 0; foreach (object o in targets) { TPHelper h = o as TPHelper; h.textureID = 0; } OnTextureChange(textures[helper.textureID]); OnAtlasChangeComplete(); } if (helper.meshTexture != null) { TPAtlas atlas = helper.meshTexture.TextureAtlas; if (atlas != null) { string[] textures = atlas.frameNames; EditorGUI.BeginChangeCheck(); helper.textureID = EditorGUILayout.Popup("Texture: ", helper.textureID, textures); foreach (object o in targets) { TPHelper h = o as TPHelper; h.textureID = helper.textureID; } if (EditorGUI.EndChangeCheck()) { OnTextureChange(textures[helper.textureID]); } } } helper.replaceMaterial = EditorGUILayout.Toggle("Replace Material", helper.replaceMaterial); foreach (object o in targets) { TPHelper h = o as TPHelper; h.replaceMaterial = helper.replaceMaterial; } helper.cloneMaterial = EditorGUILayout.Toggle("Clone Material", helper.cloneMaterial); foreach (object o in targets) { TPHelper h = o as TPHelper; h.cloneMaterial = helper.cloneMaterial; if (h.cloneMaterial) { h.replaceMaterial = false; } } } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Update"), GUILayout.Width(100))) { TPAssetPostprocessor.UpdateAtlasesInfromation(); if (helper.meshTexture != null) { TPAtlas atlas = helper.meshTexture.TextureAtlas; if (atlas != null) { string[] atlasesNames = TPAssetPostprocessor.atlasesNames; OnAtlasChange(atlasesNames[helper.atlasID]); string[] textures = helper.meshTexture.TextureAtlas.frameNames; OnTextureChange(textures[helper.textureID]); } } } EditorGUILayout.EndHorizontal(); updateStatus(); }