This commit is contained in:
SoulliesOfficial
2025-10-23 00:49:44 -04:00
parent 9b1b5ca93f
commit 61a397dd4c
9846 changed files with 2618439 additions and 793547 deletions

View File

@@ -0,0 +1,23 @@
using Assets.PixelFantasy.PixelHeroes.Common.Scripts.CharacterScripts;
using UnityEditor;
using UnityEngine;
namespace Assets.PixelFantasy.PixelHeroes.Common.Scripts.Editor
{
/// <summary>
/// Adds "Rebuild" button to CharacterBuilder script.
/// </summary>
[CustomEditor(typeof(CharacterBuilder))]
public class CharacterBuilderEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if (GUILayout.Button("Rebuild"))
{
((CharacterBuilder) target).Rebuild();
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4c4d7d43333f483f82c426514c8e010d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 250116
packageName: Pixel Hero Maker
packageVersion: 3.4
assetPath: Assets/OtherPlugins/PixelFantasy/PixelHeroes/Common/Scripts/Editor/CharacterBuilderEditor.cs
uploadId: 777185

View File

@@ -0,0 +1,23 @@
using Assets.PixelFantasy.Common.Scripts.EditorScripts;
using UnityEditor;
using UnityEngine;
namespace Assets.PixelFantasy.PixelHeroes.Common.Scripts.Editor
{
/// <summary>
/// Adds "Refresh" button to CharacterEditor script.
/// </summary>
[CustomEditor(typeof(CharacterEditor))]
public class CharacterEditorEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if (GUILayout.Button("Refresh"))
{
((CharacterEditor) target).SpriteCollection.Refresh();
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b9c4de282dd0409aa170f6094ae34d33
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 250116
packageName: Pixel Hero Maker
packageVersion: 3.4
assetPath: Assets/OtherPlugins/PixelFantasy/PixelHeroes/Common/Scripts/Editor/CharacterEditorEditor.cs
uploadId: 777185

View File

@@ -0,0 +1,30 @@
using Assets.PixelFantasy.Common.Scripts.CollectionScripts;
using UnityEditor;
using UnityEngine;
namespace Assets.PixelFantasy.PixelHeroes.Common.Scripts.Editor
{
/// <summary>
/// Adds "Refresh" button to SpriteCollection script.
/// </summary>
[CustomEditor(typeof(SpriteCollection))]
public class SpriteCollectionEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
var collection = (SpriteCollection) target;
if (GUILayout.Button("Refresh"))
{
collection.Refresh();
}
if (GUILayout.Button("Apply Palette"))
{
collection.ApplyPalette();
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: c0099f34b13a4a39aa46a2da2b58ac9d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 250116
packageName: Pixel Hero Maker
packageVersion: 3.4
assetPath: Assets/OtherPlugins/PixelFantasy/PixelHeroes/Common/Scripts/Editor/SpriteCollectionEditor.cs
uploadId: 777185

View File

@@ -0,0 +1,105 @@
using System.Linq;
using Assets.PixelFantasy.Common.Scripts.EditorScripts;
using UnityEditor;
using UnityEngine;
// Remove.
#if UNITY_2021_1_OR_NEWER
using UnityEngine.U2D.Animation;
#else
using UnityEngine.Experimental.U2D.Animation;
#endif
namespace Assets.PixelFantasy.PixelHeroes.Common.Scripts.Editor
{
public class SpriteLibraryBuilder : EditorWindow
{
public Texture2D Texture;
public SpriteLibraryAsset SpriteLibraryAsset;
[InitializeOnLoadMethod]
private static void InitializeOnLoad()
{
CharacterEditor.CreateSpriteLibraryRequest += CreateSpriteLibrary;
}
[MenuItem("Window/◆ Pixel Heroes/Sprite Library Builder")]
public static void Open()
{
var window = GetWindow<SpriteLibraryBuilder>(false, "Sprite Library Builder");
window.minSize = window.maxSize = new Vector2(300, 150);
window.Show();
}
public void OnGUI()
{
EditorGUILayout.LabelField("Fill Sprite Library based on Sprite Sheet", new GUIStyle(EditorStyles.label) { normal = { textColor = Color.yellow } });
Texture = (Texture2D) EditorGUILayout.ObjectField(new GUIContent("Sprite Sheet (Texture)"), Texture, typeof(Texture2D), false);
SpriteLibraryAsset = (SpriteLibraryAsset) EditorGUILayout.ObjectField(new GUIContent("Sprite Library Asset"), SpriteLibraryAsset, typeof(SpriteLibraryAsset), false);
if (GUILayout.Button("Build"))
{
if (Configure(Texture, SpriteLibraryAsset))
{
EditorUtility.DisplayDialog("Success", $"Sprite Library Asset configured:\n{AssetDatabase.GetAssetPath(SpriteLibraryAsset)}", "OK");
}
}
}
private static bool Configure(Texture2D texture, SpriteLibraryAsset spriteLibrary)
{
if (texture == null)
{
EditorUtility.DisplayDialog("Error", "Sprite Sheet is empty.", "OK");
}
else if (spriteLibrary == null)
{
EditorUtility.DisplayDialog("Error", "Sprite Library Asset is empty.", "OK");
}
else
{
var path = AssetDatabase.GetAssetPath(texture);
var sprites = AssetDatabase.LoadAllAssetsAtPath(path).OfType<Sprite>().ToList();
foreach (var category in spriteLibrary.GetCategoryNames().ToList())
{
foreach (var label in spriteLibrary.GetCategoryLabelNames(category).ToList())
{
spriteLibrary.RemoveCategoryLabel(category, label, true);
}
}
foreach (var sprite in sprites)
{
if (!sprite.name.Contains("_")) continue;
var split = sprite.name.Split('_');
spriteLibrary.AddCategoryLabel(sprite, split[0], split[1]);
}
return true;
}
return false;
}
private static void CreateSpriteLibrary(string texturePath)
{
var spriteLibraryPath = texturePath.Replace(".png", ".asset");
var spriteLibrary = CreateInstance<SpriteLibraryAsset>();
Configure(AssetDatabase.LoadAssetAtPath<Texture2D>(texturePath), spriteLibrary);
AssetDatabase.CreateAsset(spriteLibrary, spriteLibraryPath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 06bfa3b3a222480297034423a0f2f433
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 250116
packageName: Pixel Hero Maker
packageVersion: 3.4
assetPath: Assets/OtherPlugins/PixelFantasy/PixelHeroes/Common/Scripts/Editor/SpriteLibraryBuilder.cs
uploadId: 777185

View File

@@ -0,0 +1,102 @@
using Assets.PixelFantasy.Common.Scripts.EditorScripts;
using UnityEditor;
using UnityEditor.U2D.Sprites;
using UnityEngine;
namespace Assets.PixelFantasy.PixelHeroes.Common.Scripts.Editor
{
public class SpriteSheetSlicer : EditorWindow
{
public Texture2D Texture;
[InitializeOnLoadMethod]
private static void InitializeOnLoad()
{
CharacterEditor.SliceTextureRequest += Slice;
}
[MenuItem("Window/◆ Pixel Heroes/Sprite Sheet Slicer")]
public static void Open()
{
var window = GetWindow<SpriteSheetSlicer>(false, "Sprite Sheet Slicer");
window.minSize = window.maxSize = new Vector2(300, 150);
window.Show();
}
public void OnGUI()
{
EditorGUILayout.LabelField("Slice Texture to build Sprite Sheet", new GUIStyle(EditorStyles.label) { normal = { textColor = Color.yellow } });
Texture = (Texture2D) EditorGUILayout.ObjectField(new GUIContent("Sprite Sheet (Texture)"), Texture, typeof(Texture2D), false);
if (GUILayout.Button("Slice"))
{
if (Slice(Texture))
{
EditorUtility.DisplayDialog("Success", $"Texture sliced:\n{AssetDatabase.GetAssetPath(Texture)}", "OK");
}
}
}
private static void Slice(string path)
{
Slice(AssetDatabase.LoadAssetAtPath<Texture2D>(path));
}
private static bool Slice(Texture2D texture)
{
if (texture == null)
{
EditorUtility.DisplayDialog("Error", "Sprite Sheet is empty.", "OK");
return false;
}
var examplePath = texture.width == 576
? "Assets/PixelFantasy/PixelHeroes/Common/Sprites/Example.png"
: "Assets/PixelFantasy/PixelHeroes4D/Common/Sprites/Example.png";
var exampleTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(examplePath);
if (exampleTexture == null)
{
EditorUtility.DisplayDialog("Error", $"Example texture not found: {examplePath}", "OK");
}
else if (texture.width != exampleTexture.width || texture.height != exampleTexture.height)
{
EditorUtility.DisplayDialog("Error", $"Target texture is {texture.width}x{texture.height} px but should be {exampleTexture.width}x{exampleTexture.height} px.", "OK");
}
else
{
var path = AssetDatabase.GetAssetPath(texture);
var target = (TextureImporter) AssetImporter.GetAtPath(path);
var example = (TextureImporter) AssetImporter.GetAtPath(examplePath);
var settings = new TextureImporterSettings();
target.textureType = TextureImporterType.Sprite;
target.spriteImportMode = SpriteImportMode.Multiple;
target.textureCompression = TextureImporterCompression.Uncompressed;
example.ReadTextureSettings(settings);
target.SetTextureSettings(settings);
var factory = new SpriteDataProviderFactories();
factory.Init();
var exampleData = factory.GetSpriteEditorDataProviderFromObject(example);
var targetData = factory.GetSpriteEditorDataProviderFromObject(target);
exampleData.InitSpriteEditorDataProvider();
targetData.InitSpriteEditorDataProvider();
var spriteRects = exampleData.GetSpriteRects();
targetData.SetSpriteRects(spriteRects);
targetData.Apply();
target.SaveAndReimport();
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: d683029faf0c4fbe8f98843cd06dcd42
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 250116
packageName: Pixel Hero Maker
packageVersion: 3.4
assetPath: Assets/OtherPlugins/PixelFantasy/PixelHeroes/Common/Scripts/Editor/SpriteSheetSlicer.cs
uploadId: 777185