ãã®è¨äºã§ã®ãã¼ã¸ã§ã³
Unity 2017.2.0f3
ã¯ããã«
ä»åã¯Inspectorãå§åçã«ä½¿ããããããOdinã¨ããã¢ã»ããã®ç´¹ä»ã§ãï¼
Odinã¯å°å ¥ããã ãInspectorã®è¦æ ããè¯ãããæ´ã«80以ä¸ã®å±æ§ã追å ããäºã§
Inspectorãå§åçã«ä½¿ãããããã¾ãã
Odin - Inspector and Serializer | Utilities Tools | Unity Asset Store |
使ãã¨ã©ããªæãã«ãªãã®ããã¯ãå
¬å¼ãµã¤ããè¦ãã¨åãããããã§ãã
ä¾ãã¢ãã¡ã¼ã·ã§ã³ãã·ã³ãã«ãªã³ã¼ãä»ããªã®ã§ããªãã¨ãªãé°å²æ°æ´ããã¨æãã¾ãã
ç®æ¬¡
- ã¯ããã«
- ç®æ¬¡
- å°å ¥
- 使ãæ¹
- List (å°å ¥ããã ãã§ããæãã«)
- SerializedMonoBehaviour (DictionaryãInspectorã«è¡¨ç¤º)
- ReadOnly (ç·¨éåºæ¥ãªãããã«)
- ShowInInspector (ããããã£ã¾ã§è¡¨ç¤º)
- HideLabel (ã©ãã«ãé表示)
- LabelText (ã©ãã«ãèªç±ã«è¨å®)
- Indent (ã¤ã³ãã³ãã®è¨å®)
- Button (ã¡ã½ãããå®è¡ãããã¿ã³)
- BoxGroup, FoldoutGroup, TabGroup (ã°ã«ã¼ãå)
- Editor Only Mode
- å®è¡ãã¡ã¤ã«ã®å®¹é
- ãããã«
- åè
å°å ¥
å°å ¥ã®ä»æ¹ã¯ä»ã®ã¢ã»ããã¨åãããAsset Storeããã¤ã³ãã¼ãããã ãã
ãªãããµã³ãã«ã大éã«ããã®ã§ã使ãæ¹ã§å°ãã¨ããäºããªãã¨æãã¾ãã
使ãæ¹
æ©è½ãå¤ããæµç³ã«å ¨é¨ã¯ç´¹ä»ããããªãã®ã§ã
å人çã«è¯ãããã ã¨æã£ãæ©è½ãå±æ§ãæç²ãã¦ç´¹ä»ãã¾ãã
ãªããããã¥ã¡ã³ãã¯ä»¥ä¸ã®ãã¼ã¸ã§ãã
AssetListAttribute | API Documentation | Odin Inspector for Unity
List (å°å ¥ããã ãã§ããæãã«)
Odinãå°å
¥ããã¨ä½ãããã¨ãListã®è¡¨ç¤ºãããæãã«å¤ããã¾ãã
[SerializeField] private List<string> _list = new List<string>(){"test", "TEST", "Test"};
ãªããVector3ãQuaternionãªã©ãå°å
¥ããã ãã§Inspectorä¸ã®è¦ãç®ãå¤ããã¾ãã
SerializedMonoBehaviour (DictionaryãInspectorã«è¡¨ç¤º)
MonoBehaviourã§ã¯ãªããSerializedMonoBehaviourãç¶æ¿ãããã¨
DictionaryãInspectorã«è¡¨ç¤ºããã(ã·ãªã¢ã©ã¤ãºãã)äºãåºæ¥ãããã«ãªãã¾ãã
using System.Collections.Generic; using UnityEngine; using Sirenix.OdinInspector;//SerializedMonoBehaviourã使ãã®ã«å¿ è¦ //MonoBehaviourã§ã¯ãªããSerializedMonoBehaviourãç¶æ¿ public class NewBehaviourScript : SerializedMonoBehaviour { //Dictionaryãã·ãªã¢ã©ã¤ãºåºæ¥ãããã« [SerializeField] private Dictionary<string, int> _dict = new Dictionary<string, int>(){ {"Key1", 1}, {"Key2", 2}, {"Key3", 3} }; }
ReadOnly (ç·¨éåºæ¥ãªãããã«)
ReadOnlyã使ãã¨Inspectorä¸ã§ç·¨éä¸å¯ã«åºæ¥ã¾ãã
[ReadOnly] public int ReadOnlyNum = 100;
ShowInInspector (ããããã£ã¾ã§è¡¨ç¤º)
ShowInInspectorã使ãã¨privateå¤æ°ãããããã£ãInspectorã«è¡¨ç¤ºã§ããããã«ãªãã¾ãã
ãã ããå¤æ´ãã¦ãå¤ã¯ä¿åã§ããªãã®ã§ç¢ºèªå°ç¨ã§ãã
[ShowInInspector]
public Vector3 ShowInInspectorVector3{get;set;}
å¤ãå¤æ´åºæ¥ãã¨ç´ããããã®ã§ãReadOnlyã¨ä½µç¨ããã®ããªã¹ã¹ã¡ã
[ShowInInspector, ReadOnly]
public Vector3 ShowInInspectorVector3{get;set;}
HideLabel (ã©ãã«ãé表示)
HideLabelã使ãã¨å¤æ°ã®æ¨ªã«è¡¨ç¤ºãããã©ãã«ãé表示ã§ãã¾ãã
[HideLabel] public string HideLabelTest = "HideLabel";
LabelText (ã©ãã«ãèªç±ã«è¨å®)
LabelTextã使ãã¨å¤æ°ã®æ¨ªã«è¡¨ç¤ºãããã©ãã«ãèªç±ã«è¨å®ã§ãã¾ãã
[LabelText("èªç±ãªååã«")] public string LabelTextTest = "LabelTextTest";
Indent (ã¤ã³ãã³ãã®è¨å®)
Indentã使ãã¨ã¤ã³ãã³ããèªç±ã«è¨å®ã§ãã¾ãã
[Indent(1)] public bool Indent1 = false; [Indent(2)] public bool Indent2 = false; [Indent(3)] public bool Indent3 = false; public bool NoIndet;
Button (ã¡ã½ãããå®è¡ãããã¿ã³)
Buttonã使ãã¨ã¡ã½ãããå®è¡ã§ãããã¿ã³ãçæã§ãã¾ãã
[Button("æ¼ãã¦ï¼")] private void OnClick() { Debug.Log("æ¼ããï¼"); }
ãªããå¼æ°ãè¨å®ããäºãå¯è½ã§ãã
[Button("ç¶æ å¤æ´")] private void ChangeActive(bool isActive) { }
BoxGroup, FoldoutGroup, TabGroup (ã°ã«ã¼ãå)
BoxGroup, FoldoutGroup, TabGroupã®ããããã使ãã¨
å¤æ°ãã°ã«ã¼ãåãã¦è¡¨ç¤ºããäºãã§ãã¾ãã
[BoxGroup("ã°ã«ã¼ã1")] public int A, B, C; [BoxGroup("ã°ã«ã¼ã2")] public int D, E, F;
[FoldoutGroup("ã°ã«ã¼ã1")] public int A, B, C; [FoldoutGroup("ã°ã«ã¼ã2")] public int D, E, F;
[TabGroup("ã°ã«ã¼ã1")] public int A, B, C; [TabGroup("ã°ã«ã¼ã2")] public int D, E, F;
Editor Only Mode
ã¤ã³ãã¼ãå¾ãTools -> Odin Inspector -> Preferencesã§åè¨å®ãããäºãåºæ¥ã¾ãã
ãã®ä¸ã«ãEditor Only Modeã¨ããæ©è½ãããã
ãããæå¹ã«ããäºã§ã¨ãã£ã¿ä¸ã ãã§æ©è½ããããã«åºæ¥ã¾ãã
è²ã ãªãã©ãããã©ã¼ã ã«å¯¾å¿ãã¦ããã¨ã¯è¨ããä¸å ·åãåºãå¯è½æ§ããªãããã§ã¯ãªãã®ã§ã
å¿é ãªäººã¯æå¹ã«ãã¦ããã¨è¯ãããããã¾ããã
ãã ããæå¹ã«ããã¨ä½¿ããªãæ©è½(SerializedMonoBehaviourã¨ã)ãåºã¦ããã®ã§ã注æãå¿ è¦ã§ãã
ãªããEditor Only Modeã§ä½¿ããªãæ©è½ã使ã£ã¦ããå ´åã¯è¦åæãåºã¾ããã
ãªã«ãããã«ãæã«ã¨ã©ã¼ãåºã¦éããªããªãã®ã§ãæ°ä»ããªãäºã¯ç¡ãã¨æãã¾ãã
å®è¡ãã¡ã¤ã«ã®å®¹é
Odinã¯å°å ¥ããã¨å®è¡ãã¡ã¤ã«ã®å®¹éãå¢ãã(Macã§ç´0.5MB)ã®ã§ã注æãå¿ è¦ã§ãã
ãªããä¸è¨ã®Editor Only Modeãæå¹ã«ãã¦ããã°å¢ãã¾ããã
ãããã«
Odinã¯å±æ§ã ãã§80ãããã®ã§ãã¾ã ã¾ã ææ¡ãããã¦ãã¾ããã
ãã¤ããOdinã®å ¨å±æ§ä¸è¦§ãã¨ããOdinã®å ¨æ©è½ä¸è¦§ãã¨ãã®
è¨äºãæ¸ããã°è¯ããªã¼ã¨æã£ã¦ããä»æ¥ãã®ããã§ã(:ï¼ã£)âã