유니티 셋팅

This commit is contained in:
2026-03-27 16:34:08 +09:00
parent 474bda26cd
commit d76f078a89
1400 changed files with 116263 additions and 0 deletions

View File

@@ -0,0 +1,141 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
/// <summary>
/// Editor utility to clear _GrayscaleTex from materials.
/// Useful for cleaning up material previews after runtime testing.
/// </summary>
public class ClearGrayscaleTextures : EditorWindow
{
private bool showWarning = true;
[MenuItem("Tools/MesshingAround/Clear GrayscaleTex from Materials")]
static void ShowWindow()
{
GetWindow<ClearGrayscaleTextures>("Clear GrayscaleTex");
}
void OnGUI()
{
EditorGUILayout.Space(10);
EditorGUILayout.LabelField("Clear GrayscaleTex from Materials", EditorStyles.boldLabel);
EditorGUILayout.Space(5);
EditorGUILayout.HelpBox(
"This tool clears the _GrayscaleTex property from all materials.\n\n" +
"This is useful for cleaning up material previews in the Project window. " +
"The grayscale texture will be re-applied automatically at runtime by PotionTextureSetup.",
MessageType.Info
);
EditorGUILayout.Space(10);
// Warning box
if (showWarning)
{
EditorGUILayout.HelpBox(
"⚠️ IMPORTANT WARNINGS:\n\n" +
"• Material Instances: If you have material instances in your scene (created via 'Prepare for Timeline'), " +
"you may need to reset them after running this tool.\n\n" +
"• White Materials: After clearing, materials in the scene may appear white or without the grayscale texture " +
"until you enter Play mode or force a repaint (Play/Stop).\n\n" +
"• This operation affects ALL materials in the project with _GrayscaleTex property.",
MessageType.Warning
);
}
EditorGUILayout.Space(10);
showWarning = EditorGUILayout.ToggleLeft("Show warnings", showWarning);
EditorGUILayout.Space(10);
GUI.backgroundColor = new Color(0.8f, 0.4f, 0.4f);
if (GUILayout.Button("Clear _GrayscaleTex from All Materials", GUILayout.Height(40)))
{
if (EditorUtility.DisplayDialog(
"Clear GrayscaleTex",
"Are you sure you want to clear _GrayscaleTex from all materials?\n\n" +
"This will affect all materials in the project.\n" +
"Material instances may need to be recreated.",
"Yes, Clear",
"Cancel"))
{
ClearAllGrayscaleTextures();
}
}
GUI.backgroundColor = Color.white;
EditorGUILayout.Space(10);
EditorGUILayout.HelpBox(
"💡 TIP: After running this tool:\n" +
"1. Enter Play mode and Stop to refresh materials in the scene\n" +
"2. If materials are still white, re-assign the material to the Renderer\n" +
"3. If using Timeline, you may need to re-run 'Prepare for Timeline' on affected objects",
MessageType.Info
);
}
void ClearAllGrayscaleTextures()
{
string[] guids = AssetDatabase.FindAssets("t:Material");
int clearedCount = 0;
int totalChecked = 0;
EditorUtility.DisplayProgressBar("Clearing GrayscaleTex", "Processing materials...", 0f);
try
{
for (int i = 0; i < guids.Length; i++)
{
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
Material mat = AssetDatabase.LoadAssetAtPath<Material>(path);
if (mat != null)
{
totalChecked++;
if (mat.HasProperty("_GrayscaleTex"))
{
Texture currentTex = mat.GetTexture("_GrayscaleTex");
if (currentTex != null)
{
mat.SetTexture("_GrayscaleTex", null);
EditorUtility.SetDirty(mat);
clearedCount++;
Debug.Log($"✓ Cleared _GrayscaleTex from: {mat.name} (was: {currentTex.name})");
}
}
}
float progress = (float)i / guids.Length;
EditorUtility.DisplayProgressBar("Clearing GrayscaleTex", $"Processing {i + 1}/{guids.Length}", progress);
}
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
finally
{
EditorUtility.ClearProgressBar();
}
// Show results dialog
string message = $"Operation completed!\n\n" +
$"• Materials checked: {totalChecked}\n" +
$"• Materials cleared: {clearedCount}\n\n" +
$"Remember to:\n" +
$"1. Enter Play mode to refresh scene materials\n" +
$"2. Re-run 'Prepare for Timeline' if needed";
EditorUtility.DisplayDialog("Clear GrayscaleTex - Complete", message, "OK");
Debug.Log($"===== CLEAR GRAYSCALETEX COMPLETE =====");
Debug.Log($"✅ Cleared _GrayscaleTex from {clearedCount}/{totalChecked} material(s)");
}
}
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: afd91aa4c7bfc4d4cb9593b665e1adc8
AssetOrigin:
serializedVersion: 1
productId: 341020
packageName: Stylized Potions Pack - 110 Colors | Liquid Physics | URP + Built-in
packageVersion: 1.0
assetPath: Assets/MesshingAround/StylizedPotionsPack/Scripts/Editor/ClearGrayscaleTextures.cs
uploadId: 811526

View File

@@ -0,0 +1,146 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(MaterialIndexController))]
public class MaterialIndexControllerEditor : Editor
{
public override void OnInspectorGUI()
{
MaterialIndexController controller = (MaterialIndexController)target;
Renderer rend = controller.GetComponent<Renderer>();
if (rend == null)
{
EditorGUILayout.HelpBox("No Renderer found!", MessageType.Error);
return;
}
Material[] materials = rend.sharedMaterials;
int materialsWithIndex = 0;
// Count materials with _GradientIndex
for (int i = 0; i < materials.Length; i++)
{
if (materials[i] != null && materials[i].HasProperty("_GradientIndex"))
{
materialsWithIndex++;
}
}
EditorGUILayout.Space(5);
EditorGUILayout.LabelField("Material Index Controller", EditorStyles.boldLabel);
string infoMessage = "";
if (materialsWithIndex == 1)
{
infoMessage = "This component is OPTIONAL for single material.\n\n" +
"Provides a convenient slider for _GradientIndex.\n" +
"You can also animate directly: Renderer > Material > _GradientIndex";
}
else if (materialsWithIndex >= 2)
{
infoMessage = "This component is REQUIRED for multiple materials.\n\n" +
"Without it, animating _GradientIndex will affect all materials together.\n" +
"This controller allows independent animation per material slot.";
}
else
{
infoMessage = "No materials with _GradientIndex detected.";
}
EditorGUILayout.HelpBox(infoMessage, materialsWithIndex >= 2 ? MessageType.Warning : MessageType.Info);
EditorGUILayout.Space(5);
// Check if using instances
bool usingInstances = false;
for (int i = 0; i < materials.Length; i++)
{
if (materials[i] != null && materials[i].name.Contains("(Instance)"))
{
usingInstances = true;
break;
}
}
if (!usingInstances && materialsWithIndex > 0)
{
EditorGUILayout.HelpBox(
"⚠️ Material instances not detected!\n\n" +
"For Timeline animation to work:\n" +
"1. Find 'PotionTextureSetup' component\n" +
"2. Click 'Prepare for Timeline'",
MessageType.Warning
);
EditorGUILayout.Space(5);
}
EditorGUILayout.LabelField($"Detected: {materialsWithIndex} material(s) with _GradientIndex", EditorStyles.miniLabel);
EditorGUILayout.Space(10);
EditorGUILayout.LabelField("Individual Material Indices", EditorStyles.boldLabel);
// Show only the sliders for materials that exist and have _GradientIndex
SerializedProperty indexProp0 = serializedObject.FindProperty("indexMaterial0");
SerializedProperty indexProp1 = serializedObject.FindProperty("indexMaterial1");
SerializedProperty indexProp2 = serializedObject.FindProperty("indexMaterial2");
SerializedProperty indexProp3 = serializedObject.FindProperty("indexMaterial3");
for (int i = 0; i < materials.Length && i < 4; i++)
{
if (materials[i] == null) continue;
if (!materials[i].HasProperty("_GradientIndex")) continue;
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField($"Material {i}: {materials[i].name}", EditorStyles.miniLabel);
SerializedProperty prop = null;
switch (i)
{
case 0: prop = indexProp0; break;
case 1: prop = indexProp1; break;
case 2: prop = indexProp2; break;
case 3: prop = indexProp3; break;
}
if (prop != null)
{
EditorGUILayout.PropertyField(prop, new GUIContent($"Index Material {i}"));
}
EditorGUILayout.EndVertical();
EditorGUILayout.Space(3);
}
serializedObject.ApplyModifiedProperties();
EditorGUILayout.Space(10);
// Timeline instructions
if (materialsWithIndex >= 2)
{
EditorGUILayout.HelpBox(
"Timeline Animation (Multiple Materials):\n" +
"1. Add Animation Track\n" +
"2. Drag this GameObject to track\n" +
"3. Add properties: 'Index Material 0', 'Index Material 1', etc.\n" +
"4. Each material animates independently!",
MessageType.None
);
}
else if (materialsWithIndex == 1)
{
EditorGUILayout.HelpBox(
"Timeline Animation (Single Material):\n" +
"1. Add Animation Track\n" +
"2. Drag this GameObject to track\n" +
"3. Add property: 'Index Material 0'\n" +
" (Or animate directly via Renderer > Material > _GradientIndex)",
MessageType.None
);
}
}
}
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 222b2dfbd04a57449a8d0c9ccd5ef54a
AssetOrigin:
serializedVersion: 1
productId: 341020
packageName: Stylized Potions Pack - 110 Colors | Liquid Physics | URP + Built-in
packageVersion: 1.0
assetPath: Assets/MesshingAround/StylizedPotionsPack/Scripts/Editor/MaterialIndexControllerEditor.cs
uploadId: 811526

View File

@@ -0,0 +1,103 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(PotionTextureSetup))]
public class PotionTextureSetupEditor : Editor
{
public override void OnInspectorGUI()
{
PotionTextureSetup script = (PotionTextureSetup)target;
DrawDefaultInspector();
EditorGUILayout.Space(15);
Renderer rend = script.GetComponent<Renderer>();
int materialCount = rend != null ? rend.sharedMaterials.Length : 0;
if (materialCount > 0)
{
bool isPrepared = false;
if (rend != null)
{
Material[] sharedMats = rend.sharedMaterials;
if (sharedMats != null && sharedMats.Length > 0)
{
foreach (var mat in sharedMats)
{
if (mat != null && mat.name.Contains("(Instance)"))
{
isPrepared = true;
break;
}
}
}
}
EditorGUILayout.LabelField("Timeline Animation Setup", EditorStyles.boldLabel);
if (!isPrepared)
{
EditorGUILayout.HelpBox(
"To animate material properties in Timeline, you need to prepare this object first.\n\n" +
"This creates material instances that allow:\n" +
"• Timeline animations to work properly\n" +
"• Each object to have independent grayscale textures\n" +
"• Properties to animate without affecting other objects",
MessageType.Info
);
GUI.backgroundColor = new Color(0.3f, 0.8f, 0.3f);
if (GUILayout.Button("🎬 Prepare for Timeline", GUILayout.Height(40)))
{
script.PrepareForTimeline();
}
GUI.backgroundColor = Color.white;
}
else
{
string helpText = "✓ Timeline-ready! Material instances created.\n\n";
helpText += "Animate in Timeline:\n";
helpText += "• All properties via: Renderer > Material > [Property]\n";
helpText += "• Colors, emission, smoothness, etc.\n\n";
if (materialCount >= 2)
{
helpText += "⚠️ For _GradientIndex:\n";
helpText += "ADD MaterialIndexController component (REQUIRED)\n";
helpText += "Without it, all materials will animate together.\n\n";
}
else if (materialCount == 1)
{
helpText += "For _GradientIndex:\n";
helpText += "• Animate directly via Renderer > Material, OR\n";
helpText += "• Add MaterialIndexController for a cleaner slider (optional)\n\n";
}
helpText += "💡 Tip: Timeline preview in Edit Mode can be unreliable.\n";
helpText += "Always test in Play Mode for accurate animation results.";
EditorGUILayout.HelpBox(helpText, MessageType.None);
EditorGUILayout.Space(5);
// Undo button
GUI.backgroundColor = new Color(0.9f, 0.5f, 0.3f);
if (GUILayout.Button("↩ Remove Instances (Restore Originals)", GUILayout.Height(30)))
{
if (EditorUtility.DisplayDialog(
"Remove Material Instances?",
"This will restore the original shared materials.\n\nTimeline animations will no longer work until you prepare again.",
"Remove",
"Cancel"))
{
script.RemoveInstances();
}
}
GUI.backgroundColor = Color.white;
}
}
}
}
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0d77c97b0aa656e4eba50acfa5350868
AssetOrigin:
serializedVersion: 1
productId: 341020
packageName: Stylized Potions Pack - 110 Colors | Liquid Physics | URP + Built-in
packageVersion: 1.0
assetPath: Assets/MesshingAround/StylizedPotionsPack/Scripts/Editor/PotionTextureSetupEditor.cs
uploadId: 811526