/// <summary> /// Close all window related to adding/configuring sensor, also called in SimUI /// </summary> public void EndProcesses() { isChoosingOption = false; if (currentSensor != null) { currentSensor.ResetConfigurationState(); currentSensor = null; } sensorOptionPanel.SetActive(false); sensorTypePanel.SetActive(false); CancelOptionSelection(); CancelTypeSelection(); ResetConfigurationWindow(); HideSensorOutput(); //configureSensorButton.GetComponentInChildren<Text>().text = "Add/Configure Sensor"; selectedNode = null; if (preConfigState != null) { dynamicCamera.SwitchToState(preConfigState); preConfigState = null; } HideInvisibleSensors(); }
/// <summary> /// End the reset process and puts the robot back down /// </summary> public void EndReset() { IsResetting = false; EndRobotReset(); if (lastCameraState != null) { DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>(); dynamicCamera.SwitchCameraState(lastCameraState); lastCameraState = null; } OnEndReset(); Destroy(resetMoveArrows); resetMoveArrows = null; foreach (Tracker t in GetComponentsInChildren <Tracker>()) { t.Clear(); } InputControl.freeze = false; canvas.GetComponent <Canvas>().enabled = true; resetCanvas.SetActive(false); SimUI.getSimUI().CloseNavigationTooltip(); }
/// <summary> /// Start the sensor configuration /// </summary> public void StartConfiguration() { if (configureSensorPanel.activeSelf) { configureSensorPanel.SetActive(false); } if (currentSensor.sensorType.Equals("Gyro")) { configureSensorPanel = Auxiliary.FindObject(canvas, "GyroConfigurationPanel"); sensorConfigHeader = Auxiliary.FindObject(configureSensorPanel, "SensorConfigHeader"); } else if (configureSensorPanel.name.Equals("GyroConfigurationPanel")) { configureSensorPanel = Auxiliary.FindObject(canvas, "SensorConfigurationPanel"); sensorConfigHeader = Auxiliary.FindObject(configureSensorPanel, "SensorConfigHeader"); } HideInvisibleSensors(); currentSensor.ChangeVisibility(true); SyncHideSensorButton(); configureSensorPanel.SetActive(true); sensorConfigHeader.GetComponentInChildren <Text>().text = currentSensor.name; if (preConfigState == null) { preConfigState = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>().ActiveState; } dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, currentSensor.gameObject)); }
// Use this for initialization public override void Start() { moveArrows = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs\\MoveArrows")); moveArrows.name = "IndicatorMoveArrows"; moveArrows.transform.parent = sensor.transform; moveArrows.transform.rotation = sensor.transform.rotation; moveArrows.transform.localPosition = UnityEngine.Vector3.zero; moveArrows.GetComponent <MoveArrows>().Translate = (translation) => sensor.transform.Translate(translation, Space.World); StateMachine.SceneGlobal.Link <SensorSpawnState>(moveArrows); DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>(); lastCameraState = dynamicCamera.ActiveState; dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, sensor)); Button resetButton = GameObject.Find("ResetButton").GetComponent <Button>(); resetButton.onClick.RemoveAllListeners(); resetButton.onClick.AddListener(ResetSpawn); Button returnButton = GameObject.Find("ReturnButton").GetComponent <Button>(); returnButton.onClick.RemoveAllListeners(); returnButton.onClick.AddListener(ReturnToMainState); }
// Use this for initialization public override void Start() { #region init ui = GameObject.Find("GoalStateUI"); helpMenu = Auxiliary.FindObject(ui, "Help"); toolbar = Auxiliary.FindObject(ui, "ResetStateToolbar"); overlay = Auxiliary.FindObject(ui, "Overlay"); #endregion if (goalIndicator != null) { GameObject.Destroy(goalIndicator); } if (goalIndicator == null) { goalIndicator = GameObject.CreatePrimitive(PrimitiveType.Cube); // Create cube to show goal region goalIndicator.name = "GoalIndicator"; Renderer render = goalIndicator.GetComponentInChildren <Renderer>(); render.material.shader = Shader.Find("Transparent/Diffuse"); Color newColor = new Color(0, 0.88f, 0, 0.6f); render.material.color = newColor; } goalIndicator.transform.position = color.Equals("Red") ? gm.redGoals[gamepieceIndex][goalIndex].GetComponent <Goal>().position : gm.blueGoals[gamepieceIndex][goalIndex].GetComponent <Goal>().position; goalIndicator.transform.localScale = color.Equals("Red") ? gm.redGoals[gamepieceIndex][goalIndex].GetComponent <Goal>().scale : gm.blueGoals[gamepieceIndex][goalIndex].GetComponent <Goal>().scale; settingGamepieceGoalVertical = false; GameObject moveArrows = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs\\MoveArrows")); moveArrows.name = "IndicatorMoveArrows"; moveArrows.transform.parent = goalIndicator.transform; moveArrows.transform.localPosition = UnityEngine.Vector3.zero; if (move) { moveArrows.GetComponent <MoveArrows>().Translate = (translation) => goalIndicator.transform.Translate(translation, Space.World); } else { moveArrows.GetComponent <MoveArrows>().Translate = (translation) => goalIndicator.transform.localScale += translation;//goalIndicator.transform.localScale.Scale(translation); } StateMachine.SceneGlobal.Link <GoalState>(moveArrows); DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>(); lastCameraState = dynamicCamera.ActiveState; dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, goalIndicator)); Button resetButton = GameObject.Find("ResetButton").GetComponent <Button>(); resetButton.onClick.RemoveAllListeners(); resetButton.onClick.AddListener(Reset); Button helpButton = GameObject.Find("HelpButton").GetComponent <Button>(); helpButton.onClick.RemoveAllListeners(); helpButton.onClick.AddListener(HelpMenu); Button returnButton = GameObject.Find("ReturnButton").GetComponent <Button>(); returnButton.onClick.RemoveAllListeners(); returnButton.onClick.AddListener(ReturnToMainState); Button closeHelp = Auxiliary.FindObject(helpMenu, "CloseHelpButton").GetComponent <Button>(); closeHelp.onClick.RemoveAllListeners(); closeHelp.onClick.AddListener(CloseHelpMenu); }
/// <summary> /// Close all window related to adding/configuring sensor, also called in SimUI /// </summary> public void EndProcesses() { isChoosingOption = false; if (currentSensor != null) { currentSensor.ResetConfigurationState(); currentSensor = null; } sensorOptionPanel.SetActive(false); sensorTypePanel.SetActive(false); CancelOptionSelection(); CancelTypeSelection(); ResetConfigurationWindow(); //HideSensorOutput(); selectedNode = null; //Switch back to the original camera state if (preConfigState != null) { dynamicCamera.SwitchToState(preConfigState); preConfigState = null; } HideInvisibleSensors(); }
public void FinishGamepieceSpawn() { settingSpawn = 0; if (spawnIndicator != null) { Destroy(spawnIndicator); } if (lastCameraState != null) { DynamicCamera dynamicCamera = Camera.main.transform.GetComponent <DynamicCamera>(); dynamicCamera.SwitchCameraState(lastCameraState); lastCameraState = null; } //MainState.ControlsDisabled = false; }
public void StartGamepieceSpawn(int index) { if (definingRelease || definingIntake || addingGamepiece) { Debug.Log("User Error"); //Message Manager already dispatches error message to user } else if (settingSpawn == 0) { if (GameObject.Find(gamepieceNames[index]) != null) { if (spawnIndicator != null) { Destroy(spawnIndicator); } if (spawnIndicator == null) { spawnIndicator = Instantiate(AuxFunctions.FindObject(gamepieceNames[index]).GetComponentInParent <BRigidBody>().gameObject, new UnityEngine.Vector3(0, 3, 0), UnityEngine.Quaternion.identity); spawnIndicator.name = "SpawnIndicator"; Destroy(spawnIndicator.GetComponent <BRigidBody>()); if (spawnIndicator.transform.GetChild(0) != null) { spawnIndicator.transform.GetChild(0).name = "SpawnIndicatorMesh"; } Renderer render = spawnIndicator.GetComponentInChildren <Renderer>(); render.material.shader = Shader.Find("Transparent/Diffuse"); Color newColor = render.material.color; newColor.a = 0.6f; render.material.color = newColor; } spawnIndicator.transform.position = gamepieceSpawn[index]; settingSpawn = index + 1; DynamicCamera dynamicCamera = Camera.main.transform.GetComponent <DynamicCamera>(); lastCameraState = dynamicCamera.cameraState; dynamicCamera.SwitchCameraState(new DynamicCamera.SateliteState(dynamicCamera)); //MainState.ControlsDisabled = true; } else { UserMessageManager.Dispatch("You must define the gamepiece first!", 5f); } } else { FinishGamepieceSpawn(); //if already setting spawn, end editing process } }
/// <summary> /// Method for "Add/Configure Sensor" button. End configuration ends all window related to sensor addition/configuration /// </summary> public void ToggleSensorOption() { isChoosingOption = !isChoosingOption; sensorOptionPanel.SetActive(isChoosingOption); if (isChoosingOption) { preConfigState = dynamicCamera.cameraState; dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera)); configureSensorButton.GetComponentInChildren <Text>().text = "End Configuration"; } else { configureSensorButton.GetComponentInChildren <Text>().text = "Add/Configure Sensor"; EndProcesses(); } }
/// <summary> /// Activate the configure camera panel and start position configuration (which is the main configuration state for robot camera) /// </summary> public void ToggleCameraConfiguration() { robotCameraManager.ChangingCameraPosition = !robotCameraManager.ChangingCameraPosition; configureCameraPanel.SetActive(robotCameraManager.ChangingCameraPosition); if (robotCameraManager.ChangingCameraPosition) { preConfigCamState = dynamicCamera.ActiveState; dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, robotCameraManager.CurrentCamera)); } else { configureRobotCameraButton.GetComponentInChildren <Text>().text = "Configure"; ResetConfigurationWindow(); dynamicCamera.SwitchToState(preConfigCamState); } }
/// <summary> /// Method for "Add/Configure Sensor" button. End configuration ends all window related to sensor addition/configuration /// </summary> public void ToggleSensorOption() { //Deal with UI conflicts between robot camera & sensors robotCameraGUI.EndProcesses(); toolkit.EndProcesses(true); isChoosingOption = !isChoosingOption; if (isChoosingOption) { preConfigState = dynamicCamera.ActiveState; dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera)); ShowAllSensors(); } else { EndProcesses(); } }
/// <summary> /// Activate the configure camera panel and start position configuration /// </summary> public void ConfigureCameraPosition() { robotCamera.ChangingCameraPosition = !robotCamera.ChangingCameraPosition; configureCameraPanel.SetActive(robotCamera.ChangingCameraPosition); if (robotCamera.ChangingCameraPosition) { preConfigCamState = dynamicCamera.cameraState; dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, robotCamera.CurrentCamera)); //Update the node where current camera is attached to cameraNodeText.text = "Current Node: " + robotCamera.CurrentCamera.transform.parent.gameObject.name; configureRobotCameraButton.GetComponentInChildren <Text>().text = "End Configuration"; } else { configureRobotCameraButton.GetComponentInChildren <Text>().text = "Configure Robot Camera"; dynamicCamera.SwitchToState(preConfigCamState); } }
/// <summary> /// End the reset process and puts the robot back down /// </summary> public void EndReset() { IsResetting = false; foreach (RigidNode n in RootNode.ListAllNodes()) { BRigidBody br = n.MainObject.GetComponent <BRigidBody>(); if (br == null) { continue; } RigidBody r = (RigidBody)br.GetCollisionObject(); r.LinearFactor = r.AngularFactor = BulletSharp.Math.Vector3.One; } if (lastCameraState != null) { DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>(); dynamicCamera.SwitchCameraState(lastCameraState); lastCameraState = null; } OnEndReset(); Destroy(resetMoveArrows); resetMoveArrows = null; foreach (Tracker t in GetComponentsInChildren <Tracker>()) { t.Clear(); } if (helpMenu.activeSelf) { CloseHelpMenu(); } InputControl.freeze = false; canvas.GetComponent <Canvas>().enabled = true; resetCanvas.SetActive(false); }
/// <summary> /// Close all window related to adding/configuring sensor /// </summary> public void EndProcesses() { isChoosingOption = isSelectingSensor = isAddingSensor = isAddingBeamBreaker = isAddingUltrasonic = nodeConfirmed = false; sensorOptionPanel.SetActive(false); ResetConfigurationWindow(); sensorTypePanel.SetActive(false); selectedNode = null; CancelOptionSelection(); configureSensorButton.GetComponentInChildren <Text>().text = "Add/Configure Sensor"; if (currentSensor != null) { currentSensor.ResetConfigurationState(); currentSensor = null; } if (preConfigState != null) { dynamicCamera.SwitchToState(preConfigState); preConfigState = null; } }
// Use this for initialization public override void Start() { #region init ui = GameObject.Find("ResetSensorSpawnpointUI"); helpMenu = Auxiliary.FindObject(ui, "Help"); toolbar = Auxiliary.FindObject(ui, "ResetStateToolbar"); overlay = Auxiliary.FindObject(ui, "Overlay"); #endregion moveArrows = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs\\MoveArrows")); moveArrows.name = "IndicatorMoveArrows"; moveArrows.transform.parent = sensor.transform; moveArrows.transform.rotation = sensor.transform.rotation; moveArrows.transform.localPosition = UnityEngine.Vector3.zero; moveArrows.GetComponent <MoveArrows>().Translate = (translation) => sensor.transform.Translate(translation, Space.World); StateMachine.SceneGlobal.Link <SensorSpawnState>(moveArrows); DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>(); lastCameraState = dynamicCamera.ActiveState; dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, sensor)); Button resetButton = GameObject.Find("ResetButton").GetComponent <Button>(); resetButton.onClick.RemoveAllListeners(); resetButton.onClick.AddListener(ResetSpawn); Button helpButton = GameObject.Find("HelpButton").GetComponent <Button>(); helpButton.onClick.RemoveAllListeners(); helpButton.onClick.AddListener(HelpMenu); Button returnButton = GameObject.Find("ReturnButton").GetComponent <Button>(); returnButton.onClick.RemoveAllListeners(); returnButton.onClick.AddListener(ReturnToMainState); Button closeHelp = Auxiliary.FindObject(helpMenu, "CloseHelpButton").GetComponent <Button>(); closeHelp.onClick.RemoveAllListeners(); closeHelp.onClick.AddListener(CloseHelpMenu); }
/// <summary> /// Close all window related to adding/configuring sensor, also called in SimUI /// </summary> public void EndProcesses() { isChoosingOption = false; if (currentSensor != null) { currentSensor.GetComponentInChildren <MoveArrows>(true).gameObject.SetActive(false); currentSensor.ResetConfigurationState(); currentSensor = null; } //CancelOptionSelection(); //CancelTypeSelection(); ResetConfigurationWindow(); //HideSensorOutput(); //Switch back to the original camera state if (preConfigState != null) { dynamicCamera.SwitchToState(preConfigState); preConfigState = null; } HideInvisibleSensors(); }
/// <summary> /// Return the robot to robotStartPosition and destroy extra game pieces /// </summary> /// <param name="resetTransform"></param> public void BeginReset() { //GetDriverPractice().DestroyAllGamepieces(); InputControl.freeze = true; if (canvas == null) { canvas = GameObject.Find("Main Camera").transform.GetChild(0).gameObject; } if (resetCanvas == null) { resetCanvas = GameObject.Find("Main Camera").transform.GetChild(1).gameObject; } canvas.GetComponent <Canvas>().enabled = false; resetCanvas.SetActive(true); #region init if (helpMenu == null) { helpMenu = Auxiliary.FindObject(resetCanvas, "Help"); } if (toolbar == null) { toolbar = Auxiliary.FindObject(resetCanvas, "ResetStateToolbar"); } if (overlay == null) { overlay = Auxiliary.FindObject(resetCanvas, "Overlay"); } if (helpBodyText == null) { helpBodyText = Auxiliary.FindObject(resetCanvas, "BodyText").GetComponent <Text>(); } #endregion Button resetButton = Auxiliary.FindObject(resetCanvas, "ResetButton").GetComponent <Button>(); resetButton.onClick.RemoveAllListeners(); resetButton.onClick.AddListener(BeginRevertSpawnpoint); Button helpButton = Auxiliary.FindObject(resetCanvas, "HelpButton").GetComponent <Button>(); helpButton.onClick.RemoveAllListeners(); helpButton.onClick.AddListener(HelpMenu); Button returnButton = Auxiliary.FindObject(resetCanvas, "ReturnButton").GetComponent <Button>(); returnButton.onClick.RemoveAllListeners(); returnButton.onClick.AddListener(EndReset); Button closeHelp = Auxiliary.FindObject(helpMenu, "CloseHelpButton").GetComponent <Button>(); closeHelp.onClick.RemoveAllListeners(); closeHelp.onClick.AddListener(CloseHelpMenu); DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>(); lastCameraState = dynamicCamera.ActiveState; dynamicCamera.SwitchCameraState(new DynamicCamera.OrbitState(dynamicCamera)); foreach (SimulatorRobot robot in state.SpawnedRobots) { foreach (BRigidBody rb in robot.GetComponentsInChildren <BRigidBody>()) { if (rb != null && !rb.GetCollisionObject().IsActive) { rb.GetCollisionObject().Activate(); } } } if (!state.DynamicCameraObject.GetComponent <DynamicCamera>().ActiveState.GetType().Equals(typeof(DynamicCamera.ConfigurationState))) { IsResetting = true; foreach (RigidNode n in RootNode.ListAllNodes()) { BRigidBody br = n.MainObject.GetComponent <BRigidBody>(); if (br == null) { continue; } RigidBody r = (RigidBody)br.GetCollisionObject(); r.LinearVelocity = r.AngularVelocity = BulletSharp.Math.Vector3.Zero; r.LinearFactor = r.AngularFactor = BulletSharp.Math.Vector3.Zero; BulletSharp.Math.Matrix newTransform = r.WorldTransform; newTransform.Origin = (robotStartPosition + n.ComOffset).ToBullet(); newTransform.Basis = BulletSharp.Math.Matrix.Identity; r.WorldTransform = newTransform; } OnBeginReset(); //Where "save orientation" works RotateRobot(robotStartOrientation); AttachMoveArrows(); } else { UserMessageManager.Dispatch("Please don't reset robot during configuration!", 5f); } }
/// <summary> /// Return the robot to robotStartPosition and destroy extra game pieces /// </summary> /// <param name="resetTransform"></param> public void BeginReset() { //GetDriverPractice().DestroyAllGamepieces(); InputControl.freeze = true; if (canvas == null) { canvas = GameObject.Find("Canvas"); } if (resetCanvas == null) { resetCanvas = Auxiliary.FindObject(UnityEngine.Camera.main.gameObject, "ResetRobotSpawnpointUI"); } canvas.GetComponent <Canvas>().enabled = false; resetCanvas.SetActive(true); #region init if (toolbar == null) { toolbar = Auxiliary.FindObject(resetCanvas, "ResetStateToolbar"); } #endregion Button resetButton = Auxiliary.FindObject(resetCanvas, "ResetButton").GetComponent <Button>(); resetButton.onClick.RemoveAllListeners(); resetButton.onClick.AddListener(BeginRevertSpawnpoint); Button returnButton = Auxiliary.FindObject(resetCanvas, "ReturnButton").GetComponent <Button>(); returnButton.onClick.RemoveAllListeners(); returnButton.onClick.AddListener(EndReset); DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>(); lastCameraState = dynamicCamera.ActiveState; dynamicCamera.SwitchCameraState(new DynamicCamera.OrbitState(dynamicCamera)); foreach (SimulatorRobot robot in state.SpawnedRobots) { foreach (BRigidBody rb in robot.GetComponentsInChildren <BRigidBody>()) { if (rb != null && !rb.GetCollisionObject().IsActive) { rb.GetCollisionObject().Activate(); } } } if (!state.DynamicCameraObject.GetComponent <DynamicCamera>().ActiveState.GetType().Equals(typeof(DynamicCamera.ConfigurationState))) { IsResetting = true; BeginRobotReset(); OnBeginReset(); //Where "save orientation" works RotateRobot(robotStartOrientation); AttachMoveArrows(); } else { UserMessageManager.Dispatch("Please don't reset robot during configuration!", 5f); } SimUI.getSimUI().OpenNavigationTooltip(); }
// Use this for initialization public override void Start() { #region init ui = GameObject.Find("ResetGamepieceSpawnpointUI"); helpMenu = Auxiliary.FindObject(ui, "Help"); toolbar = Auxiliary.FindObject(ui, "ResetStateToolbar"); overlay = Auxiliary.FindObject(ui, "Overlay"); #endregion Gamepiece gamepiece = FieldDataHandler.gamepieces[gamepieceIndex]; //gamepiece indicator if (spawnIndicator != null) { GameObject.Destroy(spawnIndicator); } if (spawnIndicator == null) { spawnIndicator = GameObject.Instantiate(Auxiliary.FindGameObject(gamepiece.name), new UnityEngine.Vector3(0, 3, 0), UnityEngine.Quaternion.identity); spawnIndicator.SetActive(true); spawnIndicator.name = "SpawnIndicator"; GameObject.Destroy(spawnIndicator.GetComponent <BRigidBody>()); GameObject.Destroy(spawnIndicator.GetComponent <BCollisionShape>()); GameObject.Destroy(spawnIndicator.GetComponent <Tracker>()); if (spawnIndicator.transform.GetChild(0) != null) { spawnIndicator.transform.GetChild(0).name = "SpawnIndicatorMesh"; } Renderer render = spawnIndicator.GetComponentInChildren <Renderer>(); render.material.shader = Shader.Find("Transparent/Diffuse"); Color newColor = render.material.color; newColor.a = 0.6f; render.material.color = newColor; } spawnIndicator.transform.position = gamepiece.spawnpoint; //move arrow attachment GameObject moveArrows = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs\\MoveArrows")); moveArrows.name = "IndicatorMoveArrows"; moveArrows.transform.parent = spawnIndicator.transform; moveArrows.transform.localPosition = UnityEngine.Vector3.zero; //IMPORTANT moveArrows.GetComponent <MoveArrows>().Translate = (translation) => spawnIndicator.transform.Translate(translation, Space.World); StateMachine.SceneGlobal.Link <GamepieceSpawnState>(moveArrows); //camera stuff DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>(); lastCameraState = dynamicCamera.ActiveState; dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, spawnIndicator)); //help menu Button resetButton = GameObject.Find("ResetButton").GetComponent <Button>(); resetButton.onClick.RemoveAllListeners(); resetButton.onClick.AddListener(ResetSpawn); Button helpButton = GameObject.Find("HelpButton").GetComponent <Button>(); helpButton.onClick.RemoveAllListeners(); helpButton.onClick.AddListener(HelpMenu); Button returnButton = GameObject.Find("ReturnButton").GetComponent <Button>(); returnButton.onClick.RemoveAllListeners(); returnButton.onClick.AddListener(ReturnToMainState); Button closeHelp = Auxiliary.FindObject(helpMenu, "CloseHelpButton").GetComponent <Button>(); closeHelp.onClick.RemoveAllListeners(); closeHelp.onClick.AddListener(CloseHelpMenu); }
// Use this for initialization public override void Start() { //create indicator if (goalIndicator != null) { GameObject.Destroy(goalIndicator); } if (goalIndicator == null) { goalIndicator = GameObject.CreatePrimitive(PrimitiveType.Cube); // Create cube to show goal region goalIndicator.name = "GoalIndicator"; Renderer render = goalIndicator.GetComponentInChildren <Renderer>(); render.material.shader = Shader.Find("Transparent/Diffuse"); Color newColor = new Color(0, 0.88f, 0, 0.6f); render.material.color = newColor; } GameObject goal = color.Equals("Red") ? gm.redGoals[gamepieceIndex][goalIndex] : gm.blueGoals[gamepieceIndex][goalIndex]; goalIndicator.transform.position = goal.GetComponent <Goal>().position; goalIndicator.transform.eulerAngles = goal.GetComponent <Goal>().rotation; goalIndicator.transform.localScale = goal.GetComponent <Goal>().scale; settingGamepieceGoalVertical = false; //move arrow attachment GameObject moveArrows = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs\\MoveArrows")); moveArrows.name = "IndicatorMoveArrows"; moveArrows.transform.parent = goalIndicator.transform; moveArrows.transform.localPosition = UnityEngine.Vector3.zero; if (move) { moveArrows.GetComponent <MoveArrows>().Translate = (translation) => goalIndicator.transform.Translate(translation, Space.World); } else { moveArrows.GetComponent <MoveArrows>().Translate = (translation) => goalIndicator.transform.localScale += translation; } StateMachine.SceneGlobal.Link <GoalState>(moveArrows); //camera stuff DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>(); lastCameraState = dynamicCamera.ActiveState; dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, goalIndicator)); //UI callbacks Button resetButton = GameObject.Find("ResetButton").GetComponent <Button>(); resetButton.onClick.RemoveAllListeners(); resetButton.onClick.AddListener(Reset); Button returnButton = GameObject.Find("ReturnButton").GetComponent <Button>(); returnButton.onClick.RemoveAllListeners(); returnButton.onClick.AddListener(ReturnToMainState); if (move) { SimUI.getSimUI().OpenNavigationTooltip(); } }