コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】【Odin - Inspector and Serializer】Project ビューのプレハブの値を編集不可にする「DisableInPrefabAssets」属性

目次

「DisableInPrefabAssets」属性

「DisableInPrefabAssets」属性を使用すると
Project ビューのプレハブの値を編集不可にすることができます

Project ビューのプレハブ

f:id:baba_s:20170803102346p:plain

Hierarchy ビューのプレハブ

f:id:baba_s:20170803103443p:plain

プレハブではないオブジェクト

f:id:baba_s:20170803103443p:plain

ソースコード

using Sirenix.OdinInspector;
using UnityEngine;

public class Example : MonoBehaviour
{
    [DisableInPrefabAssets] public int a;
}

使い方

下記のように記述するだけで使用できます

[DisableInPrefabAssets] public int a;