// Fins the first texture atlas public static Uni2DTextureAtlas FindFirstTextureAtlas(string a_rTextureGUID) { Uni2DEditorAssetTable rAssetTable = Uni2DEditorAssetTable.Instance; Uni2DTextureAtlas rAtlas = null; bool bSaveTable = false; string[] rAtlasGUIDs = rAssetTable.GetAtlasGUIDsUsingThisTexture(a_rTextureGUID); foreach (string rAtlasGUID in rAtlasGUIDs) { rAtlas = Uni2DEditorUtils.GetAssetFromUnityGUID <Uni2DTextureAtlas>(rAtlasGUID); if (rAtlas != null && rAtlas.Contains(a_rTextureGUID)) { //rAtlas = null; break; } else { rAssetTable.RemoveAtlasUsingTexture(rAtlasGUID, a_rTextureGUID); bSaveTable = true; } } if (bSaveTable) { rAssetTable.Save( ); } return(rAtlas); }
// Copy clips private void CopyFrames(List <Uni2DAnimationFrame> a_rFramesSource, List <Uni2DAnimationFrame> a_rFramesDestination) { // Update asset table Uni2DEditorAssetTable rAssetTable = Uni2DEditorAssetTable.Instance; string rClipGUID = Uni2DEditorUtils.GetUnityAssetGUID(this); foreach (Uni2DAnimationFrame rOldFrame in a_rFramesDestination) { string oTextureGUID = rOldFrame.textureContainer != null ? rOldFrame.textureContainer.GUID : null; if (!string.IsNullOrEmpty(oTextureGUID)) { rAssetTable.RemoveClipUsingTexture(rClipGUID, oTextureGUID); } } a_rFramesDestination.Clear( ); foreach (Uni2DAnimationFrame rFrameSource in a_rFramesSource) { a_rFramesDestination.Add(new Uni2DAnimationFrame(rFrameSource)); string oTextureGUID = rFrameSource.textureContainer != null ? rFrameSource.textureContainer.GUID : null; if (!string.IsNullOrEmpty(oTextureGUID)) { rAssetTable.AddClipUsingTexture(rClipGUID, oTextureGUID); } } rAssetTable.Save( ); }
public static bool AddClipPopup(string a_rLabel, out Uni2DAnimationClip a_rAnimationClip, params GUILayoutOption[] a_rGUILayoutOptions) { bool bHasChanged; // Get button control ID int iControlID = GUIUtility.GetControlID(FocusType.Passive); EditorGUI.BeginChangeCheck( ); { // Get selected value for our control // If no PopupCallbackInfo instance exists, the returned value is a_rClip a_rAnimationClip = PopupCallbackInfo <Uni2DAnimationClip> .GetSelectedValueForControl(iControlID, null); } bHasChanged = EditorGUI.EndChangeCheck( ); // Create a new generic menu // Each item menu will use AtlasPopupCallback as callback // AtlasPopupCallback will perform the logic and save the selected atlas to // the PopupCallbackInfo instance. if (GUILayout.Button(a_rLabel, a_rGUILayoutOptions)) { // Create a new popup callback info (control ID) and save it as current instance PopupCallbackInfo <Uni2DAnimationClip> .instance = new PopupCallbackInfo <Uni2DAnimationClip>(iControlID, null); // Create our generic menu GenericMenu oPopupMenu = new GenericMenu( ); // "Create" special item menu oPopupMenu.AddItem(new GUIContent("Create a new animation clip...", "Creates a new Uni2D animation clip"), false, ClipPopupCallback, "NEW"); Uni2DEditorAssetTable rAssetTable = Uni2DEditorAssetTable.Instance; // List all available atlases Dictionary <string, string> oAvailableAnimationClips = rAssetTable.GetAllClipNames( ); if (oAvailableAnimationClips.Count != 0) { oPopupMenu.AddSeparator(""); // Add an item menu for each ready to use atlas foreach (KeyValuePair <string, string> rAnimationClipNameGUIDPair in oAvailableAnimationClips) { oPopupMenu.AddItem(new GUIContent(rAnimationClipNameGUIDPair.Value), false, ClipPopupCallback, rAnimationClipNameGUIDPair.Key); } } // Finally show up the menu oPopupMenu.ShowAsContext( ); } return(bHasChanged); }
// Apply settings public bool ApplySettings(bool a_bUpdateSprites = true) { bool bSuccess; Uni2DAssetPostprocessor.Enabled = false; { int iContainerCount = textures.Length; Texture2D[] oTexturesToPack = new Texture2D[iContainerCount]; for (int iContainerIndex = 0; iContainerIndex < iContainerCount; ++iContainerIndex) { oTexturesToPack[iContainerIndex] = textures[iContainerIndex].Texture; } List <Uni2DTextureImporterSettingsPair> rTextureImporterSettings = Uni2DEditorSpriteBuilderUtils.TexturesProcessingBegin(oTexturesToPack); oTexturesToPack = null; // Look if the atlas is set properly regarding to texture sizes int iOversizedTextures = this.LookForOversizedTextures(textures, padding, maximumAtlasSize); if (iOversizedTextures == 0) { textures = this.SanitizeInputTextures(textures); iContainerCount = textures.Length; string rAtlasGUID = Uni2DEditorUtils.GetUnityAssetGUID(this); Uni2DEditorAssetTable rAssetTable = Uni2DEditorAssetTable.Instance; for (int iTextureIndex = 0, iTextureCount = m_rTextureContainers.Length; iTextureIndex < iTextureCount; ++iTextureIndex) { rAssetTable.RemoveAtlasUsingTexture(rAtlasGUID, m_rTextureContainers[iTextureIndex].GUID); } m_rTextureContainers = new Texture2DContainer[iContainerCount]; // Deep copy for (int iContainerIndex = 0; iContainerIndex < iContainerCount; ++iContainerIndex) { Texture2DContainer oTextureContainer = new Texture2DContainer(textures[iContainerIndex]); m_rTextureContainers[iContainerIndex] = oTextureContainer; rAssetTable.AddAtlasUsingTexture(rAtlasGUID, oTextureContainer.GUID); } rAssetTable.Save( ); m_iPadding = padding; m_eMaximumAtlasSize = maximumAtlasSize; bSuccess = Generate( ); if (a_bUpdateSprites) { Uni2DEditorSpriteBuilderUtils.UpdateSpriteInCurrentSceneAndResourcesAccordinglyToAtlasChange(this); } } else // Some textures can't fit { bSuccess = false; Debug.LogWarning("Uni2D could not regenerate atlas '" + (this.gameObject.name) + "' properly: " + iOversizedTextures + " texture" + (iOversizedTextures > 1 ? "s are" : " is") + " too large to fit in the atlas.", this.gameObject); } Uni2DEditorSpriteBuilderUtils.TexturesProcessingEnd(rTextureImporterSettings); } Uni2DAssetPostprocessor.Enabled = true; EditorUtility.UnloadUnusedAssets( ); return(bSuccess); }
private static void OnPostprocessAllAssets(string[] a_rImportedAssets, string[] a_rDeletedAssets, string[] a_rMovedAssets, string[] a_rMovedFromPath) { if (ms_bEnabled) { bool bUpdateAssets = false; bool bPostprocessPrefabs = false; bool bSaveTable = false; Uni2DEditorAssetTable rAssetTable = Uni2DEditorAssetTable.Instance; foreach (string rImportedAssetPath in a_rImportedAssets) { // Check if the asset isn't re-processed due to a call to GenerateTextureImportGUID if (ms_oImportedTexturesWithUpdatedUni2DGUIDs.Contains(rImportedAssetPath) == false) { Texture2D rImportedTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(rImportedAssetPath, typeof(Texture2D)); if (rImportedTexture != null) { //Debug.Log ( "Imported " + rImportedAssetPath ); string rImportedTextureGUID = AssetDatabase.AssetPathToGUID(rImportedAssetPath); ms_oImportedTextureGUIDs.Add(rImportedTextureGUID); if (Uni2DEditorUtils.ItIsTheFirstTimeWeUseTheTexture(rImportedTexture)) { Uni2DEditorSpriteBuilderUtils.SetDefaultTextureImporterSettings(rImportedTexture, false); } // This call will produce an unvoidable import of the texture (didn't find out how to prevent it) Uni2DEditorUtils.GenerateTextureImportGUID(rImportedTexture); // ... so, save the path reference to avoid to re-process it again ms_oImportedTexturesWithUpdatedUni2DGUIDs.Add(rImportedAssetPath); bUpdateAssets = true; rImportedTexture = null; EditorUtility.UnloadUnusedAssets( ); continue; } Uni2DTextureAtlas rImportedAtlas = (Uni2DTextureAtlas)AssetDatabase.LoadAssetAtPath(rImportedAssetPath, typeof(Uni2DTextureAtlas)); if (rImportedAtlas != null) { //Debug.Log ( "Imported atlas " + rImportedAssetPath ); bSaveTable = true; rAssetTable.AddAtlasPath(rImportedAssetPath, AssetDatabase.AssetPathToGUID(rImportedAssetPath)); rImportedAtlas = null; EditorUtility.UnloadUnusedAssets( ); continue; } Uni2DAnimationClip rImportedClip = (Uni2DAnimationClip)AssetDatabase.LoadAssetAtPath(rImportedAssetPath, typeof(Uni2DAnimationClip)); if (rImportedClip != null) { //Debug.Log ( "Imported clip " + rImportedClip ); bSaveTable = true; rAssetTable.AddClipPath(rImportedAssetPath, AssetDatabase.AssetPathToGUID(rImportedAssetPath)); rImportedClip = null; EditorUtility.UnloadUnusedAssets( ); continue; } GameObject rImportedGameObject = (GameObject)AssetDatabase.LoadAssetAtPath(rImportedAssetPath, typeof(GameObject)); if (rImportedGameObject != null) { //Debug.Log ( "Imported game object " + rImportedAssetPath ); ms_oGameObjectGUIDsToPostProcess.Add(AssetDatabase.AssetPathToGUID(rImportedAssetPath)); bPostprocessPrefabs = true; rImportedGameObject = null; EditorUtility.UnloadUnusedAssets( ); } } else { // ... remove the asset path from our list if it was already processed ms_oImportedTexturesWithUpdatedUni2DGUIDs.Remove(rImportedAssetPath); } } // Moved assets for (int iIndex = 0, iCount = a_rMovedAssets.Length; iIndex < iCount; ++iIndex) { //Debug.Log ( "Importing moved asset" ); Uni2DTextureAtlas rMovedAtlas = (Uni2DTextureAtlas)AssetDatabase.LoadAssetAtPath(a_rMovedAssets[iIndex], typeof(Uni2DTextureAtlas)); if (rMovedAtlas != null) { rAssetTable.RemoveAtlasFromPath(a_rMovedFromPath[iIndex], false); rAssetTable.AddAtlasPath(a_rMovedAssets[iIndex], AssetDatabase.AssetPathToGUID(a_rMovedAssets[iIndex])); bSaveTable = true; rMovedAtlas = null; EditorUtility.UnloadUnusedAssets( ); continue; } Uni2DAnimationClip rMovedClip = (Uni2DAnimationClip)AssetDatabase.LoadAssetAtPath(a_rMovedAssets[iIndex], typeof(Uni2DAnimationClip)); if (rMovedClip != null) { rAssetTable.RemoveClipFromPath(a_rMovedFromPath[iIndex], false); rAssetTable.AddClipPath(a_rMovedAssets[iIndex], AssetDatabase.AssetPathToGUID(a_rMovedAssets[iIndex])); bSaveTable = true; rMovedClip = null; EditorUtility.UnloadUnusedAssets( ); } } // Deleted assets foreach (string rDeletedAsset in a_rDeletedAssets) { string[] rSpritePrefabGUIDs = rAssetTable.GetSpritePrefabGUIDsUsingThisAtlasPath(rDeletedAsset); if (rSpritePrefabGUIDs.Length > 0) { bUpdateAssets = true; ms_oSpritePrefabGUIDsToUpdate.UnionWith(rSpritePrefabGUIDs); } /* * // TODO: mettre des paths au lieu d'IDs * string[ ] rClipGUIDs = rAssetTable.GetClipGUIDsUsingThisTexturePath( rDeletedAsset ); * if( rClipGUIDs.Length > 0 ) * { * bUpdateAssets = true; * ms_oAnimationClipGUIDsToUpdate.UnionWith( rClipGUIDs ); * } */ bSaveTable = rAssetTable.RemoveAtlasFromPath(rDeletedAsset, true) || bSaveTable; bSaveTable = rAssetTable.RemoveClipFromPath(rDeletedAsset, true) || bSaveTable; } if (bSaveTable) { rAssetTable.Save( ); } if (bUpdateAssets) { ms_oAtlasGUIDsToUpdate.UnionWith(rAssetTable.GetAtlasGUIDsUsingTheseTextures(ms_oImportedTextureGUIDs)); ms_oAnimationClipGUIDsToUpdate.UnionWith(rAssetTable.GetClipGUIDsUsingTheseTextures(ms_oImportedTextureGUIDs)); ms_oSpritePrefabGUIDsToUpdate.UnionWith(rAssetTable.GetSpritePrefabGUIDsUsingTheseTextures(ms_oImportedTextureGUIDs)); ms_oSpritePrefabGUIDsToUpdate.UnionWith(rAssetTable.GetSpritePrefabGUIDsUsingTheseAtlases(ms_oAtlasGUIDsToUpdate)); EditorApplication.delayCall += UpdateUni2DAssets; } if (bPostprocessPrefabs) { EditorApplication.delayCall += OnSpritePrefabPostprocess; } } }
private static void UpdateUni2DAssets( ) { EditorApplication.delayCall -= UpdateUni2DAssets; Uni2DEditorAssetTable rAssetTable = Uni2DEditorAssetTable.Instance; try { Uni2DAssetPostprocessor.LockTo(false); // Update animation clips first, because they can change the atlases foreach (string rAnimationClipGUID in ms_oAnimationClipGUIDsToUpdate) { Uni2DAnimationClip rAnimationClip = Uni2DEditorUtils.GetAssetFromUnityGUID <Uni2DAnimationClip>(rAnimationClipGUID); if (rAnimationClip != null) { //Debug.Log ( "Updating clip " + rAnimationClipGUID ); rAnimationClip.OnTexturesChange(ms_oImportedTextureGUIDs); rAnimationClip = null; EditorUtility.UnloadUnusedAssets( ); } else { // Clean asset table foreach (string rTextureGUID in ms_oImportedTextureGUIDs) { rAssetTable.RemoveClipUsingTexture(rAnimationClipGUID, rTextureGUID); } } } foreach (string rAtlasGUID in ms_oAtlasGUIDsToUpdate) { Uni2DTextureAtlas rAtlas = Uni2DEditorUtils.GetAssetFromUnityGUID <Uni2DTextureAtlas>(rAtlasGUID); if (rAtlas != null) { //Debug.Log( "Updating atlas " + rAtlasGUID ); rAtlas.OnTextureChange( ); rAtlas = null; EditorUtility.UnloadUnusedAssets( ); } else { // Clean foreach (string rTextureGUID in ms_oImportedTextureGUIDs) { rAssetTable.RemoveAtlasUsingTexture(rAtlasGUID, rTextureGUID); } } } foreach (string rSpritePrefabGUID in ms_oSpritePrefabGUIDsToUpdate) { GameObject rSpritePrefab = Uni2DEditorUtils.GetAssetFromUnityGUID <GameObject>(rSpritePrefabGUID); if (rSpritePrefab != null) { //Debug.Log( "Updating sprite prefab " + rSpritePrefabGUID ); foreach (Uni2DSprite rSpritePrefabComponent in rSpritePrefab.GetComponentsInChildren <Uni2DSprite>(true)) { Uni2DEditorSpriteSettings rSpriteSettings = rSpritePrefabComponent.SpriteSettings; string rSpriteTextureGUID = rSpriteSettings.textureContainer.GUID; string rSpriteAtlasGUID = rSpriteSettings.atlas != null?Uni2DEditorUtils.GetUnityAssetGUID(rSpriteSettings.atlas) : null; if (ms_oImportedTextureGUIDs.Contains(rSpriteTextureGUID) || (!string.IsNullOrEmpty(rSpriteAtlasGUID) && ms_oAtlasGUIDsToUpdate.Contains(rSpriteAtlasGUID))) { rSpritePrefabComponent.Regenerate(true); } EditorUtility.UnloadUnusedAssets( ); } rSpritePrefab = null; EditorUtility.UnloadUnusedAssets( ); } else { // Clean foreach (string rTextureGUID in ms_oImportedTextureGUIDs) { rAssetTable.RemoveSpritePrefabUsingTexture(rSpritePrefabGUID, rTextureGUID); } foreach (string rAtlasGUID in ms_oAtlasGUIDsToUpdate) { rAssetTable.RemoveSpritePrefabUsingAtlas(rSpritePrefabGUID, rAtlasGUID); } } } } finally { ms_oImportedTextureGUIDs.Clear( ); ms_oAtlasGUIDsToUpdate.Clear( ); ms_oAnimationClipGUIDsToUpdate.Clear( ); ms_oSpritePrefabGUIDsToUpdate.Clear( ); rAssetTable.Save( ); Uni2DAssetPostprocessor.Unlock( ); Uni2DAssetPostprocessor.Enabled = true; } }
public static Uni2DTextureAtlas AtlasPopup(Uni2DTextureAtlas a_rTextureAtlas, IEnumerable <string> a_rTextureGUIDs, params GUILayoutOption[] a_rGUILayoutOptions) { // Get button control ID int iControlID = GUIUtility.GetControlID(FocusType.Passive); // Get selected value for our control // If no PopupCallbackInfo instance exists, the returned value is a_rTextureAtlas a_rTextureAtlas = PopupCallbackInfo <Uni2DTextureAtlas> .GetSelectedValueForControl(iControlID, a_rTextureAtlas); // Create a new generic menu // Each item menu will use AtlasPopupCallback as callback // AtlasPopupCallback will perform the logic and save the selected atlas to // the PopupCallbackInfo instance. string oPopupSelected = EditorGUI.showMixedValue ? "-" : (a_rTextureAtlas != null ? a_rTextureAtlas.name : "(None)"); if (GUILayout.Button(oPopupSelected, EditorStyles.popup, a_rGUILayoutOptions)) { string rAtlasGUID = Uni2DEditorUtils.GetUnityAssetGUID(a_rTextureAtlas); // Create a new popup callback info (control ID) and save it as current instance PopupCallbackInfo <Uni2DTextureAtlas> .instance = new PopupCallbackInfo <Uni2DTextureAtlas>(iControlID, a_rTextureAtlas); // Create our generic menu GenericMenu oPopupMenu = new GenericMenu( ); if (a_rTextureAtlas != null) { oPopupMenu.AddItem(new GUIContent(a_rTextureAtlas.name), true, AtlasPopupCallback, rAtlasGUID); oPopupMenu.AddSeparator(""); } // "None" special item menu oPopupMenu.AddItem(new GUIContent("(None)", "No atlasing"), a_rTextureAtlas == null, AtlasPopupCallback, ""); oPopupMenu.AddSeparator(""); // "Create" special item menu oPopupMenu.AddItem(new GUIContent("Create a new atlas...", "Creates a new Uni2D atlas and add the texture(s) right away"), false, AtlasPopupCallback, "NEW"); Uni2DEditorAssetTable rAssetTable = Uni2DEditorAssetTable.Instance; // List atlases containing the texture(s) Dictionary <string, string> oAtlasesReadyToUse = rAssetTable.GetAtlasNamesUsingTheseTextures(a_rTextureGUIDs); if (!string.IsNullOrEmpty(rAtlasGUID)) { oAtlasesReadyToUse.Remove(rAtlasGUID); } if (oAtlasesReadyToUse.Count > 0) { oPopupMenu.AddSeparator(""); // Add an item menu for each ready to use atlas foreach (KeyValuePair <string, string> rAtlasNameGUIDPair in oAtlasesReadyToUse) { oPopupMenu.AddItem(new GUIContent(rAtlasNameGUIDPair.Value), rAtlasNameGUIDPair.Key == rAtlasGUID, AtlasPopupCallback, rAtlasNameGUIDPair.Key); } } // List all available atlases Dictionary <string, string> oAvailableAtlases = rAssetTable.GetAllAtlasNames( ); if (oAvailableAtlases.Count > 0) { oPopupMenu.AddSeparator(""); // Add an item menu for each available atlas, in a submenu foreach (KeyValuePair <string, string> rAtlasNameGUIDPair in oAvailableAtlases) { oPopupMenu.AddItem(new GUIContent("All atlases/" + rAtlasNameGUIDPair.Value), rAtlasNameGUIDPair.Key == rAtlasGUID, AtlasPopupCallback, rAtlasNameGUIDPair.Key); } } // Finally show up the menu oPopupMenu.ShowAsContext( ); } return(a_rTextureAtlas); }
private static void OnPostprocessAllAssets(string[] a_rImportedAssets, string[] a_rDeletedAssets, string[] a_rMovedAssets, string[] a_rMovedFromPath) { if (ms_bEnabled) { bool bUpdateAssets = false; bool bPostprocessPrefabs = false; bool bSaveTable = false; Uni2DEditorAssetTable rAssetTable = Uni2DEditorAssetTable.Instance; foreach (string rImportedAssetPath in a_rImportedAssets) { Texture2D rImportedTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(rImportedAssetPath, typeof(Texture2D)); if (rImportedTexture != null) { if (Uni2DEditorUtils.IsMarkedAsSourceTexture(rImportedTexture)) { //Debug.Log ( "Imported " + rImportedAssetPath ); string rImportedTextureGUID = AssetDatabase.AssetPathToGUID(rImportedAssetPath); ms_oImportedTextureGUIDs.Add(rImportedTextureGUID); Uni2DEditorUtils.GenerateTextureImportGUID(rImportedTexture); bUpdateAssets = true; rImportedTexture = null; MultiUnityVersionSupportUtility.UnloadUnusedAssets( ); continue; } } Uni2DTextureAtlas rImportedAtlas = (Uni2DTextureAtlas)AssetDatabase.LoadAssetAtPath(rImportedAssetPath, typeof(Uni2DTextureAtlas)); if (rImportedAtlas != null) { //Debug.Log ( "Imported atlas " + rImportedAssetPath ); bSaveTable = true; rAssetTable.AddAtlasPath(rImportedAssetPath, AssetDatabase.AssetPathToGUID(rImportedAssetPath)); rImportedAtlas = null; MultiUnityVersionSupportUtility.UnloadUnusedAssets( ); continue; } Uni2DAnimationClip rImportedClip = (Uni2DAnimationClip)AssetDatabase.LoadAssetAtPath(rImportedAssetPath, typeof(Uni2DAnimationClip)); if (rImportedClip != null) { //Debug.Log ( "Imported clip " + rImportedClip ); bSaveTable = true; rAssetTable.AddClipPath(rImportedAssetPath, AssetDatabase.AssetPathToGUID(rImportedAssetPath)); rImportedClip = null; MultiUnityVersionSupportUtility.UnloadUnusedAssets( ); continue; } GameObject rImportedGameObject = (GameObject)AssetDatabase.LoadAssetAtPath(rImportedAssetPath, typeof(GameObject)); if (rImportedGameObject != null) { //Debug.Log ( "Imported game object " + rImportedAssetPath ); ms_oGameObjectGUIDsToPostProcess.Add(AssetDatabase.AssetPathToGUID(rImportedAssetPath)); bPostprocessPrefabs = true; rImportedGameObject = null; MultiUnityVersionSupportUtility.UnloadUnusedAssets( ); } } // Moved assets for (int iIndex = 0, iCount = a_rMovedAssets.Length; iIndex < iCount; ++iIndex) { //Debug.Log ( "Importing moved asset" ); Uni2DTextureAtlas rMovedAtlas = (Uni2DTextureAtlas)AssetDatabase.LoadAssetAtPath(a_rMovedAssets[iIndex], typeof(Uni2DTextureAtlas)); if (rMovedAtlas != null) { rAssetTable.RemoveAtlasFromPath(a_rMovedFromPath[iIndex], false); rAssetTable.AddAtlasPath(a_rMovedAssets[iIndex], AssetDatabase.AssetPathToGUID(a_rMovedAssets[iIndex])); bSaveTable = true; rMovedAtlas = null; MultiUnityVersionSupportUtility.UnloadUnusedAssets( ); continue; } Uni2DAnimationClip rMovedClip = (Uni2DAnimationClip)AssetDatabase.LoadAssetAtPath(a_rMovedAssets[iIndex], typeof(Uni2DAnimationClip)); if (rMovedClip != null) { rAssetTable.RemoveClipFromPath(a_rMovedFromPath[iIndex], false); rAssetTable.AddClipPath(a_rMovedAssets[iIndex], AssetDatabase.AssetPathToGUID(a_rMovedAssets[iIndex])); bSaveTable = true; rMovedClip = null; MultiUnityVersionSupportUtility.UnloadUnusedAssets( ); } } // Deleted assets foreach (string rDeletedAsset in a_rDeletedAssets) { string[] rSpritePrefabGUIDs = rAssetTable.GetSpritePrefabGUIDsUsingThisAtlasPath(rDeletedAsset); if (rSpritePrefabGUIDs.Length > 0) { bUpdateAssets = true; ms_oSpritePrefabGUIDsToUpdate.UnionWith(rSpritePrefabGUIDs); } /* * // TODO: mettre des paths au lieu d'IDs * string[ ] rClipGUIDs = rAssetTable.GetClipGUIDsUsingThisTexturePath( rDeletedAsset ); * if( rClipGUIDs.Length > 0 ) * { * bUpdateAssets = true; * ms_oAnimationClipGUIDsToUpdate.UnionWith( rClipGUIDs ); * } */ bSaveTable = rAssetTable.RemoveAtlasFromPath(rDeletedAsset, true) || bSaveTable; bSaveTable = rAssetTable.RemoveClipFromPath(rDeletedAsset, true) || bSaveTable; } if (bSaveTable) { rAssetTable.Save( ); } if (bUpdateAssets) { ms_oAtlasGUIDsToUpdate.UnionWith(rAssetTable.GetAtlasGUIDsUsingTheseTextures(ms_oImportedTextureGUIDs)); ms_oAnimationClipGUIDsToUpdate.UnionWith(rAssetTable.GetClipGUIDsUsingTheseTextures(ms_oImportedTextureGUIDs)); ms_oSpritePrefabGUIDsToUpdate.UnionWith(rAssetTable.GetSpritePrefabGUIDsUsingTheseTextures(ms_oImportedTextureGUIDs)); ms_oSpritePrefabGUIDsToUpdate.UnionWith(rAssetTable.GetSpritePrefabGUIDsUsingTheseAtlases(ms_oAtlasGUIDsToUpdate)); EditorApplication.delayCall += UpdateUni2DAssets; } if (bPostprocessPrefabs) { EditorApplication.delayCall += OnSpritePrefabPostprocess; } } }
public static void ShowUni2DPreferences( ) { GUILayoutOption oMaxWidthOption = GUILayout.MaxWidth( 135.0f ); GUILayoutOption oMaxColorPickedWidthOption = GUILayout.MaxWidth( 100.0f ); //EditorGUILayout.HelpBox( "Uni2D Beta", MessageType.Warning, true ); EditorGUILayout.BeginVertical( ); { // Header EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Bone Gizmo State", EditorStyles.boldLabel, oMaxWidthOption ); EditorGUILayout.LabelField( "Bone", EditorStyles.boldLabel, oMaxColorPickedWidthOption ); EditorGUILayout.LabelField( "Root Bone", EditorStyles.boldLabel, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Unselected EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Unselected", oMaxWidthOption ); Uni2DEditorPreferences.UnselectedBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.UnselectedBoneGizmoColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.UnselectedRootBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.UnselectedRootBoneGizmoColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Selected EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Selected", oMaxWidthOption ); Uni2DEditorPreferences.SelectedBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.SelectedBoneGizmoColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.SelectedRootBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.SelectedRootBoneGizmoColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Editable EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Editable", oMaxWidthOption ); Uni2DEditorPreferences.EditableBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.EditableBoneGizmoColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.EditableRootBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.EditableRootBoneGizmoColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Active EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Active", oMaxWidthOption ); Uni2DEditorPreferences.ActiveBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.ActiveBoneGizmoColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.ActiveRootBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.ActiveRootBoneGizmoColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); EditorGUILayout.Space( ); // Header EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Disc Handle", EditorStyles.boldLabel, oMaxWidthOption ); EditorGUILayout.LabelField( "Bone", EditorStyles.boldLabel, oMaxColorPickedWidthOption ); EditorGUILayout.LabelField( "Root Bone", EditorStyles.boldLabel, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Inner disc handle EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Inner", oMaxWidthOption ); Uni2DEditorPreferences.InnerBoneDiscHandleColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.InnerBoneDiscHandleColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.InnerRootBoneDiscHandleColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.InnerRootBoneDiscHandleColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Outer disc handle EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Outer", oMaxWidthOption ); Uni2DEditorPreferences.OuterBoneDiscHandleColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.OuterBoneDiscHandleColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.OuterRootBoneDiscHandleColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.OuterRootBoneDiscHandleColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Selected disc handle outline EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Outline (when selected)", oMaxWidthOption ); Uni2DEditorPreferences.SelectedBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.SelectedBoneDiscHandleOutlineColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.SelectedRootBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.SelectedRootBoneDiscHandleOutlineColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); EditorGUILayout.Space( ); } EditorGUILayout.EndVertical( ); Uni2DEditorPreferences.SmoothBindingDefaultSkinQuality = (SkinQuality) EditorGUILayout.EnumPopup( "Default Skin Quality", Uni2DEditorPreferences.SmoothBindingDefaultSkinQuality ); EditorGUILayout.Space( ); EditorGUILayout.BeginHorizontal( ); { if( GUILayout.Button( "Use Default" ) ) { Uni2DEditorPreferences.RestoreDefaults( ); } GUILayout.FlexibleSpace( ); } EditorGUILayout.EndHorizontal( ); EditorGUILayout.Space( ); // Asset table rebuild EditorGUILayout.BeginVertical( ); { EditorGUILayout.LabelField( "Rebuild the Uni2D asset table if you think Uni2D is not handling your assets properly.", EditorStyles.wordWrappedLabel ); if( GUILayout.Button( "Rebuild Uni2D Asset Table" ) ) { Uni2DEditorAssetTable rAssetTable = Uni2DEditorAssetTable.Instance; rAssetTable.Rebuild( ); } } EditorGUILayout.EndVertical( ); }