Advertisement
KpoKec

Untitled

Jul 31st, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. private MyObject target;
  2. private SerializedObject so;
  3.  
  4. private int viewType = 0;
  5. private Action[] views;
  6. private string[] names;
  7.  
  8. void OnEnable() { // или тут Awake
  9.  views = new Action[] { ShowView1, ShowView2 };
  10.  names = new string[] { " View #1", "View #2" };
  11.  viewType = 0;
  12. }
  13.  
  14. private void OnGUI() {
  15.  GUILayout.BeginHorizontal();
  16.  {
  17.   for (int i=0; i<names.Length; i++)
  18.    if (GUILayout.Button(names[i]))
  19.     viewType = i;
  20.  }
  21.  GUILayout.EndHorizontal();
  22.  var o = (MyObject) EditorGUILayout.ObjectField("rootObject", target, typeof(MyObject), true);
  23.  if (o!= target) Init(o);
  24.  if (target != null)
  25.   views[viewType].Invoke();
  26. }
  27.  
  28. private void Init(MyObject obj) {
  29.  target = obj;
  30.  so = new SerializedObject(target);
  31. }
  32.  
  33. private void ShowView1() {
  34.  Property1View1();
  35.  Property2View1();
  36.  Property3View1();
  37. }
  38.  
  39. private void ShowView2() {
  40.  Property1View2();
  41.  Property2View2();
  42.  Property3View2();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement