/// <sumary> /// Import ase file at aPath to aObject /// </sumary> /// <param name="aPath">Path</param> /// <param name="aObject">Aseprite object</param> public static bool Import(string aPath, CAsepriteObject aObject) { bool tExported = CAsepriteExporter.Export(aPath, aObject); if (tExported) { TextureImporter tTexture = AssetImporter.GetAtPath( AssetDatabase.GetAssetPath(aObject.targetTexture)) as TextureImporter; // TODO: See if I can put the texture as an embeded object /* * Texture2D tNewTex = new Texture2D(1, 1); * tNewTex.SetPixel(0, 0, Color.cyan); * tNewTex.Apply(); * AssetDatabase.AddObjectToAsset(tNewTex, aObject); */ CAsepriteImporter.ImportSheet(tTexture, aObject); CAsepriteImporter.ImportAnimation(tTexture, aObject); CAsepriteWindow.CreateAnimator(aObject); } return(tExported); }
public static void ShowWindow() { CAsepriteWindow tWindow = GetWindow <CAsepriteWindow>(); // Create the instance of GUIContent to assign to the window. Gives the title "RBSettings" and the icon GUIContent titleContent = new GUIContent("AsepriteImp", tWindow.Icon); tWindow.titleContent = titleContent; }
public override void OnInspectorGUI() { int assetLost = 0; for (int i = 0; i < m_AssetTargets.Length; i++) { if (m_AssetTargets[i].asepriteAsset == null) { var asset = CAsepritePostProcesor.FindAsepriteAsset( m_AssetTargets[i]); if (asset != null) { m_AssetTargets[i].asepriteAsset = asset; EditorUtility.SetDirty(m_AssetTargets[i]); } else { assetLost++; } } } if (assetLost > 0) { GUILayout.Label((assetLost > 1 ? "These objects" : "This object") + " lost connection to " + (assetLost > 1 ? "their assets" : "its asset")); if (m_AssetTargets.Length > 1) { GUILayout.Label("Select " + (assetLost > 1 ? "one" : "it") + " to fix it"); for (int i = 0; i < m_AssetTargets.Length; i++) { if (m_AssetTargets[i].asepriteAsset == null) { if (GUILayout.Button(m_AssetTargets[i].name)) { Selection.activeObject = m_AssetTargets[i]; } } } } else { GUILayout.Label("Select the correct asset to fix it"); var obj = EditorGUILayout.ObjectField(null, typeof(Object), false); if (obj != null) { string path = AssetDatabase.GetAssetPath(obj); if (path.ToLower().EndsWith(".ase")) { m_AssetTargets[0].asepriteAsset = obj; } } } return; } GUILayout.Label("Assets", EditorStyles.boldLabel); GUILayout.BeginVertical(CAsepriteGUIData.Box); ShowProperty(m_TargetTexture, CAsepriteGUIData.TargetTexture); ShowProperty(m_TargetAtlas, CAsepriteGUIData.TargetAtlas); GUILayout.EndVertical(); // Configuration GUILayout.Label("Configuration", EditorStyles.boldLabel); GUILayout.BeginVertical(CAsepriteGUIData.Box); ShowProperty(m_UseTags, CAsepriteGUIData.UseTags); ShowProperty(m_LoopAnim, CAsepriteGUIData.LoopAnim); ShowProperty(m_UseConfig, CAsepriteGUIData.UseConfig); ShowProperty(m_Border, CAsepriteGUIData.Border); ShowProperty(m_UseChild, CAsepriteGUIData.UseChild); // Alignment EditorGUI.showMixedValue = m_Alignment.mixed; EditorGUI.BeginChangeCheck(); m_Alignment.value = (SpriteAlignment)EditorGUILayout.EnumPopup( CAsepriteGUIData.Alignment, m_Alignment.value); if (EditorGUI.EndChangeCheck()) { m_Alignment.dirty = true; m_Alignment.mixed = false; } // Pivot EditorGUI.BeginDisabledGroup(m_Alignment.value != SpriteAlignment.Custom || m_Alignment.mixed); EditorGUI.showMixedValue = m_Pivot.mixed; EditorGUI.BeginChangeCheck(); m_Pivot.value = EditorGUILayout.Vector2Field( CAsepriteGUIData.Pivot, m_Pivot.value); if (EditorGUI.EndChangeCheck()) { m_Pivot.dirty = true; m_Pivot.mixed = false; } EditorGUI.EndDisabledGroup(); // Anim type EditorGUI.showMixedValue = m_AnimType.mixed; EditorGUI.BeginChangeCheck(); m_AnimType.value = (AnimationType)EditorGUILayout.EnumPopup( CAsepriteGUIData.AnimType, m_AnimType.value); if (EditorGUI.EndChangeCheck()) { m_AnimType.dirty = true; m_AnimType.mixed = false; } EditorGUI.showMixedValue = false; GUILayout.EndVertical(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(ButtonContentPrefab, GUILayout.MaxHeight(64))) { foreach (CAsepriteObject tObj in m_AssetTargets) { CAsepriteWindow.CreatePrefab(tObj); } } if (GUILayout.Button(ButtonContentSettings, GUILayout.MaxHeight(64))) { CAsepriteWindow.ShowWindow(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUI.BeginDisabledGroup(!IsDirty); if (GUILayout.Button("Revert")) { RevertChanges(); } if (GUILayout.Button("Apply")) { ApplyChanges(); } EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); }