Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private MyObject target;
- private SerializedObject so;
- private int viewType = 0;
- private Action[] views;
- private string[] names;
- void OnEnable() { // или тут Awake
- views = new Action[] { ShowView1, ShowView2 };
- names = new string[] { " View #1", "View #2" };
- viewType = 0;
- }
- private void OnGUI() {
- GUILayout.BeginHorizontal();
- {
- for (int i=0; i<names.Length; i++)
- if (GUILayout.Button(names[i]))
- viewType = i;
- }
- GUILayout.EndHorizontal();
- var o = (MyObject) EditorGUILayout.ObjectField("rootObject", target, typeof(MyObject), true);
- if (o!= target) Init(o);
- if (target != null)
- views[viewType].Invoke();
- }
- private void Init(MyObject obj) {
- target = obj;
- so = new SerializedObject(target);
- }
- private void ShowView1() {
- Property1View1();
- Property2View1();
- Property3View1();
- }
- private void ShowView2() {
- Property1View2();
- Property2View2();
- Property3View2();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement