リポジトリ
使用例
AssetEditingScope
AssetDatabase.StartAssetEditing();
AssetDatabase.StopAssetEditing();
using ( new AssetEditingScope() )
{
}
HandlesColorScope
var oldColor = Handles.color;
Handles.color = Color.white;
Handles.color = oldColor;
using ( new HandlesColorScope( Color.white ) )
{
}
LoadPrefabContentsScope
var prefab = PrefabUtility.LoadPrefabContents( "Assets/Cube.prefab" );
prefab.AddComponent<BoxCollider>();
PrefabUtility.SaveAsPrefabAsset( prefab, "Assets/Cube.prefab" );
PrefabUtility.UnloadPrefabContents( prefab );
using ( var scope = new LoadPrefabContentsScope( "Assets/Cube.prefab" ) )
{
scope.Prefab.AddComponent<BoxCollider>();
scope.IsSave = true;
}
LogScope
#if ENABLE_RELEASE
LogScope.OnStart = null;
LogScope.OnComplete = null;
#else
LogScope.OnStart = message => Debug.Log( $"{message} 開始" );
LogScope.OnComplete = message => Debug.Log( $"{message} 終了" );
#endif
using ( new LogScope( "ピカチュウ" ) )
{
Debug.Log( "カイリュー" );
Debug.Log( "ヤドラン" );
Debug.Log( "ピジョン" );
}
LockReloadAssembliesScope
EditorApplication.LockReloadAssemblies();
EditorApplication.UnlockReloadAssemblies();
using ( new LockReloadAssembliesScope() )
{
}
SceneSetupScope
var oldSetup = EditorSceneManager.GetSceneManagerSetup();
EditorSceneManager.RestoreSceneManagerSetup( oldSetup );
using ( new SceneSetupScope() )
{
}
CustomSamplerScope
var sampler = CustomSampler.Create( "タグ" );
sampler.Begin();
sampler.End();
using ( new CustomSamplerScope( "タグ" ) )
{
}
GUIColorScope
var oldColor = GUI.color;
GUI.color = Color.white;
GUI.color = oldColor;
using ( new GUIColorScope( Color.white ) )
{
}
LabelWidthScope
var oldLabelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 32;
EditorGUILayout.TextField( "Name", "ピカチュウ" );
EditorGUIUtility.labelWidth = oldLabelWidth;
using ( new LabelWidthScope( 32 ) )
{
EditorGUILayout.TextField( "Name", "ピカチュウ" );
}