/// <summary> /// Constructor for _Request /// </summary> /// <param name="name">Name of GameObject</param> /// <param name="type">Type of the Component as string</param> /// <param name="parameter">Parameter (DELETE, INSERT or UPDATE)</param> /// <param name="root">Reference to NetworkModel object</param> public _Request(string name, string type, string parameter, NetworkModel root) { this.name = name; this.type = type; this.parameter = parameter; this.timestamp = 0; if (root.TIMESTAMP) { this.timestamp = Util.Timestamp(); } this.components = new List <_Component> (); }
/// <summary> /// Constructor for _Request /// </summary> /// <param name="gameObject">GameObject</param> /// <param name="type">Type of the Component as string</param> /// <param name="root">Reference to NetworkModel object</param> public _Request(GameObject gameObject, string type, NetworkModel root) { this.name = gameObject.name; this.type = type; this.parameter = gameObject.transform.parent.name; if (this.parameter == root.gameObject.name) { this.parameter = "root"; } this.timestamp = 0; if (root.TIMESTAMP) { this.timestamp = Util.Timestamp(); } this.components = new List <_Component>(); // Save supported and enabled components of gameobject foreach (Component component in gameObject.GetComponents(typeof(Component))) { if (component.GetType().IsSubclassOf(typeof(MonoBehaviour)) && root.SCRIPTS) { this.components.Add(new _Script(component)); } else if (Util.TypeToSerializableType(component.GetType()) != null) { try { // Check if public variable is existing for component if ((bool)typeof(NetworkModel).GetField(component.GetType().Name.ToUpper()).GetValue(root)) { this.components.Add(Util.ComponentToSerializableComponent(component)); } } catch (Exception) { Debug.LogWarning("NetworkModel: Serializable class for " + component + "exists but no public bool variable to enable/disable it."); this.components.Add(Util.ComponentToSerializableComponent(component)); } } else if (root.DEBUGSEND) { Debug.Log("NetworkModel: Component " + component.GetType() + " is unknown and cannot be synchronized."); } } }