8 using System.Reflection;
10 namespace AVR.UEditor.Core {
11 public class AVR_Component_NetworkWizard : ScriptableWizard
13 public AVR_Component component;
14 public bool DestroyOnRemote =
true;
15 public bool ChangeLayerOnRemote =
false;
16 public bool ChangeLayerOnRemote_IncludeChildren =
false;
17 public int RemoteLayer = 0;
18 public UnityEngine.Events.UnityEvent onRemoteStart;
20 private SerializedObject serializedObject;
22 public static void CreateWizard(AVR_Component component)
24 AVR_Component_NetworkWizard wiz = ScriptableWizard.DisplayWizard<AVR_Component_NetworkWizard>(
"AVR_Component Network Settings",
"Apply");
25 wiz.component = component;
26 wiz.serializedObject =
new SerializedObject(component);
28 wiz.DestroyOnRemote = component.destroyOnRemote;
29 wiz.ChangeLayerOnRemote = component.changeLayerOnRemote;
30 wiz.ChangeLayerOnRemote_IncludeChildren = component.changeLayerOnRemote_IncludeChildren;
31 wiz.RemoteLayer = component.remoteLayer;
32 wiz.onRemoteStart = component.onRemoteStart;
38 component.destroyOnRemote = DestroyOnRemote;
39 component.changeLayerOnRemote = ChangeLayerOnRemote;
40 component.changeLayerOnRemote_IncludeChildren = ChangeLayerOnRemote_IncludeChildren;
41 component.remoteLayer = RemoteLayer;
42 component.onRemoteStart = onRemoteStart;
44 serializedObject.ApplyModifiedProperties();
46 UnityEditor.EditorUtility.SetDirty(component);
51 helpString =
"Set how this component behaves on a network.";
56 protected override bool DrawWizardGUI()
58 bool b = base.DrawWizardGUI();
62 foreach (var field
in component.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
65 var att = field.GetCustomAttributes(typeof(AVR.Core.Attributes.ShowInNetPrompt),
true).FirstOrDefault();
68 SerializedProperty prop = serializedObject.FindProperty(field.Name);
69 EditorGUILayout.PropertyField(prop);
73 catch(System.Exception)