This commit is contained in:
정영민
2025-02-20 09:59:37 +09:00
parent 4dfe902e02
commit 2dd5d814a7
6244 changed files with 4671685 additions and 5 deletions

View File

@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(GIS))]
public class GISEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
GIS myScript = (GIS)target;
if (GUILayout.Button("SetHeight"))
{
myScript.SetBoxHeight();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e66f905b76e6cf49bf138574d487bcd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,135 @@
using UnityEngine;
using UnityEditor;
public class ReplacePrefabMaterials : EditorWindow
{
private GameObject targetGameObject;
private Material materialToFind;
private Material materialToReplace;
[MenuItem("Tools/Replace Prefab Materials")]
public static void ShowWindow()
{
GetWindow<ReplacePrefabMaterials>("Replace Prefab Materials");
}
private void OnGUI()
{
GUILayout.Label("Replace Materials in Prefabs", EditorStyles.boldLabel);
targetGameObject = (GameObject)EditorGUILayout.ObjectField("Target Game Object", targetGameObject, typeof(GameObject), true);
materialToFind = (Material)EditorGUILayout.ObjectField("Material to Find", materialToFind, typeof(Material), false);
materialToReplace = (Material)EditorGUILayout.ObjectField("Material to Replace", materialToReplace, typeof(Material), false);
if (GUILayout.Button("Replace Selected Prefabs"))
{
ReplaceTargetObjectMaterials();
}
if (GUILayout.Button("Replace in All Prefabs"))
{
ReplaceAllPrefabMaterials();
}
}
private void ReplaceTargetObjectMaterials()
{
if (materialToFind == null || materialToReplace == null)
{
Debug.LogError("Please assign both materials.");
return;
}
if (targetGameObject == null)
{
Debug.LogError("Please assign the target GameObject.");
return;
}
Renderer[] renderers = targetGameObject.GetComponentsInChildren<Renderer>(true);
bool isDirty = false;
int count = 0;
foreach (Renderer renderer in renderers)
{
Material[] materials = renderer.sharedMaterials;
for (int i = 0; i < materials.Length; i++)
{
if (materials[i] == materialToFind)
{
materials[i] = materialToReplace;
isDirty = true;
count++;
}
}
if (isDirty)
{
renderer.sharedMaterials = materials;
}
}
if (isDirty)
{
EditorUtility.SetDirty(targetGameObject);
Debug.Log(count + "Complete");
}
else
{
Debug.Log($"No instances of {materialToFind.name} found in the target GameObject.");
}
}
private void ReplaceAllPrefabMaterials()
{
if (materialToFind == null || materialToReplace == null)
{
Debug.LogError("Please assign both materials.");
return;
}
int count = 0;
string[] prefabGuids = AssetDatabase.FindAssets("t:Prefab");
foreach (string prefabGuid in prefabGuids)
{
string prefabPath = AssetDatabase.GUIDToAssetPath(prefabGuid);
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
if (prefab != null)
{
Renderer[] renderers = prefab.GetComponentsInChildren<Renderer>(true);
bool isDirty = false;
foreach (Renderer renderer in renderers)
{
Material[] materials = renderer.sharedMaterials;
for (int i = 0; i < materials.Length; i++)
{
if (materials[i] == materialToFind)
{
materials[i] = materialToReplace;
isDirty = true;
count++;
}
}
if (isDirty)
{
renderer.sharedMaterials = materials;
}
}
if (isDirty)
{
EditorUtility.SetDirty(prefab);
PrefabUtility.SavePrefabAsset(prefab);
}
}
else
{
Debug.Log("Null");
}
}
Debug.Log($"Replaced {count} instances of {materialToFind.name} with {materialToReplace.name} in prefabs.");
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2caba0b43f506974ab8ffbf29b62014e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(TransformBundleCopy))]
public class TransformBundleCopyEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
TransformBundleCopy copy = target as TransformBundleCopy;
if (GUILayout.Button("Copy"))
{
copy.Copy();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a2642217b8ca6934e93d4366d8b29a69
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: