LoginSignup
1
0

Unityデフォルトのコンポーネントを触れなくする方法

Posted at

はじめに

特に規模が大きいプロジェクトだと、Unityのコンポーネントを直接使わずに、プロジェクトごとでラップすることがあると思います。

しかしUnityのコンポーネントをラップするだけでは、そのラップしたコンポーネントを使ってくれるとは限りません。
その解決案として今回は、Unityデフォルトのコンポーネントを触れなくしてみようと思います。

Imageコンポーネントの場合

[CustomEditor(typeof(Image), true)]
[CanEditMultipleObjects]
public class HideImageComponent : ImageEditor
{
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginDisabledGroup(true);
        DrawDefaultInspector();
        EditorGUI.EndDisabledGroup();
    }
}

グレーアウトしている部分が触れなくなっています。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0