リポジトリ
使用例
using Kogane;
using UnityEditor;
using UnityEngine;
public static class Example
{
<summary>
</summary>
[MenuItem( "Tools/Add BoxCollider to Scene" )]
private static void AddBoxColliderToScene()
{
bool PathFilter( string scenePath )
{
return scenePath.StartsWith( "Assets/@Project/" );
}
GameObjectProcessResult OnProcess( GameObject gameObject )
{
if ( PrefabUtility.GetPrefabAssetType( gameObject ) != PrefabAssetType.NotAPrefab )
{
return GameObjectProcessResult.NOT_CHANGE;
}
if ( gameObject.GetComponent<BoxCollider>() != null )
{
return GameObjectProcessResult.NOT_CHANGE;
}
gameObject.AddComponent<BoxCollider>();
return GameObjectProcessResult.CHANGE;
}
GameObjectProcessor.ProcessAllScenes
(
scenePathFilter: PathFilter,
onProcess: OnProcess
);
}
<summary>
</summary>
[MenuItem( "Tools/Add BoxCollider to Prefab" )]
private static void AddBoxColliderToPrefab()
{
bool PathFilter( string scenePath )
{
return scenePath.StartsWith( "Assets/@Project/" );
}
GameObjectProcessResult OnProcess( GameObject gameObject )
{
if ( gameObject.GetComponent<BoxCollider>() != null )
{
return GameObjectProcessResult.NOT_CHANGE;
}
gameObject.AddComponent<BoxCollider>();
return GameObjectProcessResult.CHANGE;
}
GameObjectProcessor.ProcessAllPrefabs
(
prefabPathFilter: PathFilter,
onProcess: OnProcess
);
}
}