Inheritance: MonoBehaviour
Exemple #1
0
	protected virtual void Awake()
	{
		GameObject settings = SceneManager.Settings;

		if (!settings)
		{
			robot = SafeGetComponentInParent<RobotRequired> ().DeepCopy ();
			network = SafeGetComponentInParent<Network> ().DeepCopy ();
			replay = SafeGetComponentInParent<Replay> ().DeepCopy ();
			positionHistory = SafeGetComponentInParent<PositionHistory>();
			physics = SafeGetComponentInParent<Physics>().DeepCopy();
			limits = SafeGetComponentInParent<Limits>().DeepCopy();
			input = SafeGetComponentInParent<UserInput>().DeepCopy();
			return;
		}

		//for now only RobotRequired (Session), Replay and Network from the menu
		robot = settings.GetComponent<RobotRequired> ().DeepCopy ();
		replay = settings.GetComponent<Replay> ().DeepCopy ();
		network = settings.GetComponent<Network> ().DeepCopy ();
		/*
		positionHistory = settings.GetComponent<PositionHistory>();
		physics = settings.GetComponent<Physics>().DeepCopy();
		limits = settings.GetComponent<Limits>().DeepCopy();
		input = settings.GetComponent<UserInput>().DeepCopy();
		*/
		positionHistory = SafeGetComponentInParent<PositionHistory>();
		physics = SafeGetComponentInParent<Physics>().DeepCopy();
		limits = SafeGetComponentInParent<Limits>().DeepCopy();
		input = SafeGetComponentInParent<UserInput>().DeepCopy();

	}
	private void SettingsFromUI()
	{
		//for now only RobotRequired, Replay and Network configured through the menu
		RobotRequired robot=GetComponent<RobotRequired> ();
		Replay replay=GetComponent<Replay> ();
		Network network=GetComponent<Network> ();

		robot.sessionDirectory = TextFromInputField ("SessionInputField");
		replay.mode = (ReplayMode)IntFromDropdown ("ReplayDropdown");
		network.hostIp = TextFromInputField ("HostIPInputField");
		network.robotIp = TextFromInputField ("RobotIPInputField");
	}
	public RobotRequired DeepCopy()
	{
		RobotRequired other = (RobotRequired) this.MemberwiseClone();
		other.sessionDirectory = string.Copy(sessionDirectory);
		return other;
	}