void SetClipInfo() { if (Panel && Panel.hasClipping && Camera && Camera.GetComponent <Camera>() && Renderers != null && Renderers.Count > 0) { Vector2 soft = Panel.clipSoftness; Vector2 sharpness = new Vector2(1000.0f, 1000.0f); if (soft.x > 0f) { sharpness.x = Panel.baseClipRegion.z / soft.x; } if (soft.y > 0f) { sharpness.y = Panel.baseClipRegion.w / soft.y; } Vector4 panelCenterAndSharpness; Camera camera = Camera.GetComponent <Camera>(); Vector3[] panelWorldCorners = Panel.worldCorners; Vector3 leftBottom = camera.WorldToViewportPoint(panelWorldCorners[0]); Vector3 topRight = camera.WorldToViewportPoint(panelWorldCorners[2]); Vector3 center = Vector3.Lerp(leftBottom, topRight, 0.5f); panelCenterAndSharpness.x = center.x; panelCenterAndSharpness.y = center.y; panelCenterAndSharpness.z = sharpness.x; panelCenterAndSharpness.w = sharpness.y; for (int i = 0; i < Renderers.Count; i++) { Renderer renderer = Renderers[i]; Material mat = null; if (!Application.isPlaying) { mat = renderer.sharedMaterial; } else { mat = renderer.material; } if (mat == null) { continue; } mat.SetFloat(PanelWidthAttribID, topRight.x - leftBottom.x); mat.SetFloat(PanelHeightAttribID, topRight.y - leftBottom.y); mat.SetVector(PanelCenterAndSharpnessAttribID, panelCenterAndSharpness); } } }
private void SetUICameraDepthAndCullingMask() { mUICameras = FindObjectOfType <UICamera>(); mUICamera = mUICameras.GetComponent <Camera>(); mUICamera.depth = mDefaultUIDepth + 1; mUICamera.cullingMask = 1 << (int)GameLayer.BossShow; AudioController.Instance.PlayBackgroundMusic("BossIn", false); }
/// <summary> /// Immediately update the root's scale. Call this function after changing the min/max/manual height values. /// </summary> public void UpdateScale(bool updateAnchors = true) { if (mTrans != null) { float calcActiveHeight = activeHeight; if (calcActiveHeight > 0f) { float size = 2f / calcActiveHeight; Vector3 ls = mTrans.localScale; if (mUICamera != null) { if (!(Mathf.Abs(ls.x - size * mUICamera.GetComponent <Camera>().orthographicSize) <= UIRootEpsilon) || !(Mathf.Abs(ls.y - size * mUICamera.GetComponent <Camera>().orthographicSize) <= UIRootEpsilon) || !(Mathf.Abs(ls.z - size * mUICamera.GetComponent <Camera>().orthographicSize) <= UIRootEpsilon)) { mTrans.localScale = new Vector3(standardScale, standardScale, standardScale); float oldMainSize = mUICamera.GetComponent <Camera>().orthographicSize; float newMainSize = standardScale / size; mUICamera.GetComponent <Camera>().orthographicSize = newMainSize; CurrentOrthographicSize = newMainSize; //初始化各摄像机 for (int i = 0; i < mCameraList.Length; i++) { float oldSize = mCameraList[i].GetComponent <Camera>().orthographicSize; mCameraList[i].GetComponent <Camera>().orthographicSize = oldSize / oldMainSize * newMainSize; } if (updateAnchors) { BroadcastMessage("UpdateAnchors"); } /* * if (EasyJoystick.Instance) * { * EasyJoystick.Instance.FixedScale(); * } * */ } } } } }
void LateUpdate() { var c = targetCamera; if (c == null) { c = Camera.main; } if (c == null) { return; } _wsPosition = GetVector3Value(); if (_nguiCamera != null) { var ss = c.WorldToViewportPoint(_wsPosition); ss = _nguiCamera.GetComponent <Camera>().ViewportToWorldPoint(ss); if (pixelPerfect) { ss.x = (int)ss.x; ss.y = (int)ss.y; } ss.z = 0; gameObject.transform.localPosition = ss; } if (_anchor != null) { var ss = c.WorldToViewportPoint(_wsPosition); ss.x = -2 * ss.x * _anchor.localPosition.x; ss.y = -2 * ss.y * _anchor.localPosition.y; if (pixelPerfect) { ss.x = (int)ss.x; ss.y = (int)ss.y; } ss.z = 0; gameObject.transform.localPosition = ss; } }
void Awake() { Instance = this; currentMenu = MenuType.Main; Transform UIRoot = transform.FindChild("UI Root"); MainCamera = UIRoot.FindChild("Camera").GetComponent<UICamera>(); MainCamera.enabled = true; MainCamera.GetComponent<Camera>().enabled = true; // Get transforms for each menu MainMenu = UIRoot.FindChild("Main Menu"); SettingsMenu = UIRoot.FindChild("Settings Menu"); LeaderboardMenu = UIRoot.FindChild("Leaderboard Menu"); GameMenu = UIRoot.FindChild("Game Menu"); CustomizeMenu = UIRoot.FindChild("Customize Menu"); ToggleMenusOn(); }
public void SetViewport(int x, int y, float viewportWidth, float viewportHeight) { float viewportX = x * viewportWidth; float viewportY = y * viewportHeight; Rect viewport = new Rect( viewportX + ViewerManager.Instance.ViewportEpsilon, viewportY + ViewerManager.Instance.ViewportEpsilon, viewportWidth - (ViewerManager.Instance.ViewportEpsilon * 2.0f), viewportHeight - (ViewerManager.Instance.ViewportEpsilon * 2.0f)); Camera.rect = viewport; UICamera.rect = viewport; AspectRatio aspectRatio = UICamera.GetComponent <AspectRatio>(); if (null != aspectRatio) { aspectRatio.UpdateAspectRatio(); } }
/// <summary> /// Create a new UI. /// </summary> static public UIPanel CreateUI (Transform trans, bool advanced3D, int layer) { // Find the existing UI Root UIRoot root = (trans != null) ? NGUITools.FindInParents<UIRoot>(trans.gameObject) : null; if (root == null && UIRoot.list.Count > 0) { foreach (UIRoot r in UIRoot.list) { if (r.gameObject.layer == layer) { root = r; break; } } } // If we are working with a different UI type, we need to treat it as a brand-new one instead if (root != null) { UICamera cam = root.GetComponentInChildren<UICamera>(); if (cam != null && cam.GetComponent<Camera>().orthographic == advanced3D) { trans = null; root = null; } } // If no root found, create one if (root == null) { GameObject go = NGUITools.AddChild(null, false); root = go.AddComponent<UIRoot>(); // Automatically find the layers if none were specified if (layer == -1) layer = LayerMask.NameToLayer("UI"); if (layer == -1) layer = LayerMask.NameToLayer("2D UI"); go.layer = layer; if (advanced3D) { go.name = "UI Root (3D)"; root.scalingStyle = UIRoot.Scaling.Constrained; } else { go.name = "UI Root"; root.scalingStyle = UIRoot.Scaling.Flexible; } } // Find the first panel UIPanel panel = root.GetComponentInChildren<UIPanel>(); if (panel == null) { // Find other active cameras in the scene Camera[] cameras = NGUITools.FindActive<Camera>(); float depth = -1f; bool colorCleared = false; int mask = (1 << root.gameObject.layer); for (int i = 0; i < cameras.Length; ++i) { Camera c = cameras[i]; // If the color is being cleared, we won't need to if (c.clearFlags == CameraClearFlags.Color || c.clearFlags == CameraClearFlags.Skybox) colorCleared = true; // Choose the maximum depth depth = Mathf.Max(depth, c.depth); // Make sure this camera can't see the UI c.cullingMask = (c.cullingMask & (~mask)); } // Create a camera that will draw the UI Camera cam = NGUITools.AddChild<Camera>(root.gameObject, false); cam.gameObject.AddComponent<UICamera>(); cam.clearFlags = colorCleared ? CameraClearFlags.Depth : CameraClearFlags.Color; cam.backgroundColor = Color.grey; cam.cullingMask = mask; cam.depth = depth + 1f; if (advanced3D) { cam.nearClipPlane = 0.1f; cam.farClipPlane = 4f; cam.transform.localPosition = new Vector3(0f, 0f, -700f); } else { cam.orthographic = true; cam.orthographicSize = 1; cam.nearClipPlane = -10; cam.farClipPlane = 10; } // Make sure there is an audio listener present AudioListener[] listeners = NGUITools.FindActive<AudioListener>(); if (listeners == null || listeners.Length == 0) cam.gameObject.AddComponent<AudioListener>(); // Add a panel to the root panel = root.gameObject.AddComponent<UIPanel>(); #if UNITY_EDITOR UnityEditor.Selection.activeGameObject = panel.gameObject; #endif } if (trans != null) { // Find the root object while (trans.parent != null) trans = trans.parent; if (NGUITools.IsChild(trans, panel.transform)) { // Odd hierarchy -- can't reparent panel = trans.gameObject.AddComponent<UIPanel>(); } else { // Reparent this root object to be a child of the panel trans.parent = panel.transform; trans.localScale = Vector3.one; trans.localPosition = Vector3.zero; SetChildLayer(panel.cachedTransform, panel.cachedGameObject.layer); } } return panel; }
// Token: 0x060032D2 RID: 13010 RVA: 0x000FF7A4 File Offset: 0x000FDBA4 public static UIPanel CreateUI(Transform trans, bool advanced3D, int layer) { UIRoot uiroot = (!(trans != null)) ? null : NGUITools.FindInParents <UIRoot>(trans.gameObject); if (uiroot == null && UIRoot.list.Count > 0) { foreach (UIRoot uiroot2 in UIRoot.list) { if (uiroot2.gameObject.layer == layer) { uiroot = uiroot2; break; } } } if (uiroot != null) { UICamera componentInChildren = uiroot.GetComponentInChildren <UICamera>(); if (componentInChildren != null && componentInChildren.GetComponent <Camera>().orthographic == advanced3D) { trans = null; uiroot = null; } } if (uiroot == null) { GameObject gameObject = NGUITools.AddChild(null, false); uiroot = gameObject.AddComponent <UIRoot>(); if (layer == -1) { layer = LayerMask.NameToLayer("UI"); } if (layer == -1) { layer = LayerMask.NameToLayer("2D UI"); } gameObject.layer = layer; if (advanced3D) { gameObject.name = "UI Root (3D)"; uiroot.scalingStyle = UIRoot.Scaling.Constrained; } else { gameObject.name = "UI Root"; uiroot.scalingStyle = UIRoot.Scaling.Flexible; } } UIPanel uipanel = uiroot.GetComponentInChildren <UIPanel>(); if (uipanel == null) { Camera[] array = NGUITools.FindActive <Camera>(); float num = -1f; bool flag = false; int num2 = 1 << uiroot.gameObject.layer; foreach (Camera camera in array) { if (camera.clearFlags == CameraClearFlags.Color || camera.clearFlags == CameraClearFlags.Skybox) { flag = true; } num = Mathf.Max(num, camera.depth); camera.cullingMask &= ~num2; } Camera camera2 = NGUITools.AddChild <Camera>(uiroot.gameObject, false); camera2.gameObject.AddComponent <UICamera>(); camera2.clearFlags = ((!flag) ? CameraClearFlags.Color : CameraClearFlags.Depth); camera2.backgroundColor = Color.grey; camera2.cullingMask = num2; camera2.depth = num + 1f; if (advanced3D) { camera2.nearClipPlane = 0.1f; camera2.farClipPlane = 4f; camera2.transform.localPosition = new Vector3(0f, 0f, -700f); } else { camera2.orthographic = true; camera2.orthographicSize = 1f; camera2.nearClipPlane = -10f; camera2.farClipPlane = 10f; } AudioListener[] array2 = NGUITools.FindActive <AudioListener>(); if (array2 == null || array2.Length == 0) { camera2.gameObject.AddComponent <AudioListener>(); } uipanel = uiroot.gameObject.AddComponent <UIPanel>(); } if (trans != null) { while (trans.parent != null) { trans = trans.parent; } if (NGUITools.IsChild(trans, uipanel.transform)) { uipanel = trans.gameObject.AddComponent <UIPanel>(); } else { trans.parent = uipanel.transform; trans.localScale = Vector3.one; trans.localPosition = Vector3.zero; NGUITools.SetChildLayer(uipanel.cachedTransform, uipanel.cachedGameObject.layer); } } return(uipanel); }
/// <summary> /// Draw the inspector widget. /// </summary> public override void OnInspectorGUI() { UIPanel panel = target as UIPanel; BetterList <UIDrawCall> drawcalls = panel.drawCalls; EditorGUIUtility.LookLikeControls(80f); //NGUIEditorTools.DrawSeparator(); EditorGUILayout.Space(); float alpha = EditorGUILayout.Slider("Alpha", panel.alpha, 0f, 1f); if (alpha != panel.alpha) { NGUIEditorTools.RegisterUndo("Panel Alpha", panel); panel.alpha = alpha; } if (panel.showInPanelTool != EditorGUILayout.Toggle("Panel Tool", panel.showInPanelTool)) { panel.showInPanelTool = !panel.showInPanelTool; EditorUtility.SetDirty(panel); EditorWindow.FocusWindowIfItsOpen <UIPanelTool>(); } GUILayout.BeginHorizontal(); bool norms = EditorGUILayout.Toggle("Normals", panel.generateNormals, GUILayout.Width(100f)); GUILayout.Label("Needed for lit shaders"); GUILayout.EndHorizontal(); if (panel.generateNormals != norms) { panel.generateNormals = norms; panel.UpdateDrawcalls(); EditorUtility.SetDirty(panel); } GUILayout.BeginHorizontal(); bool depth = EditorGUILayout.Toggle("Depth Pass", panel.depthPass, GUILayout.Width(100f)); GUILayout.Label("Doubles draw calls, saves fillrate"); GUILayout.EndHorizontal(); if (panel.depthPass != depth) { panel.depthPass = depth; panel.UpdateDrawcalls(); EditorUtility.SetDirty(panel); } if (depth) { UICamera cam = UICamera.FindCameraForLayer(panel.gameObject.layer); if (cam == null || cam.GetComponent <Camera>().orthographic) { EditorGUILayout.HelpBox("Please note that depth pass will only save fillrate when used with 3D UIs, and only UIs drawn by the game camera. If you are using a separate camera for the UI, you will not see any benefit!", MessageType.Warning); } } GUILayout.BeginHorizontal(); bool stat = EditorGUILayout.Toggle("Static", panel.widgetsAreStatic, GUILayout.Width(100f)); GUILayout.Label("Check if widgets won't move"); GUILayout.EndHorizontal(); if (panel.widgetsAreStatic != stat) { panel.widgetsAreStatic = stat; panel.UpdateDrawcalls(); EditorUtility.SetDirty(panel); } EditorGUILayout.LabelField("Widgets", panel.widgets.size.ToString()); EditorGUILayout.LabelField("Draw Calls", drawcalls.size.ToString()); UIPanel.DebugInfo di = (UIPanel.DebugInfo)EditorGUILayout.EnumPopup("Debug Info", panel.debugInfo); if (panel.debugInfo != di) { panel.debugInfo = di; EditorUtility.SetDirty(panel); } UIDrawCall.Clipping clipping = (UIDrawCall.Clipping)EditorGUILayout.EnumPopup("Clipping", panel.clipping); if (panel.clipping != clipping) { panel.clipping = clipping; EditorUtility.SetDirty(panel); } if (panel.clipping != UIDrawCall.Clipping.None) { Vector4 range = panel.clipRange; GUILayout.BeginHorizontal(); GUILayout.Space(80f); Vector2 pos = EditorGUILayout.Vector2Field("Center", new Vector2(range.x, range.y)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(80f); Vector2 size = EditorGUILayout.Vector2Field("Size", new Vector2(range.z, range.w)); GUILayout.EndHorizontal(); if (size.x < 0f) { size.x = 0f; } if (size.y < 0f) { size.y = 0f; } range.x = pos.x; range.y = pos.y; range.z = size.x; range.w = size.y; if (panel.clipRange != range) { NGUIEditorTools.RegisterUndo("Clipping Change", panel); panel.clipRange = range; EditorUtility.SetDirty(panel); } if (panel.clipping == UIDrawCall.Clipping.SoftClip) { GUILayout.BeginHorizontal(); GUILayout.Space(80f); Vector2 soft = EditorGUILayout.Vector2Field("Softness", panel.clipSoftness); GUILayout.EndHorizontal(); if (soft.x < 1f) { soft.x = 1f; } if (soft.y < 1f) { soft.y = 1f; } if (panel.clipSoftness != soft) { NGUIEditorTools.RegisterUndo("Clipping Change", panel); panel.clipSoftness = soft; EditorUtility.SetDirty(panel); } } #if !UNITY_3_5 && !UNITY_4_0 && (UNITY_ANDROID || UNITY_IPHONE) if (PlayerSettings.targetGlesGraphics == TargetGlesGraphics.OpenGLES_1_x) { EditorGUILayout.HelpBox("Clipping requires shader support!\n\nOpen File -> Build Settings -> Player Settings -> Other Settings, then set:\n\n- Graphics Level: OpenGL ES 2.0.", MessageType.Error); } #endif } if (clipping == UIDrawCall.Clipping.HardClip) { EditorGUILayout.HelpBox("Hard clipping has been removed due to major performance issues on certain Android devices. Alpha clipping will be used instead.", MessageType.Warning); } if (clipping != UIDrawCall.Clipping.None && !NGUIEditorTools.IsUniform(panel.transform.lossyScale)) { EditorGUILayout.HelpBox("Clipped panels must have a uniform scale, or clipping won't work properly!", MessageType.Error); if (GUILayout.Button("Auto-fix")) { NGUIEditorTools.FixUniform(panel.gameObject); } } foreach (UIDrawCall dc in drawcalls) { NGUIEditorTools.DrawSeparator(); EditorGUILayout.ObjectField("Material", dc.material, typeof(Material), false); EditorGUILayout.LabelField("Triangles", dc.triangles.ToString()); if (clipping != UIDrawCall.Clipping.None && !dc.isClipped) { EditorGUILayout.HelpBox("You must switch this material's shader to Unlit/Transparent Colored or Unlit/Premultiplied Colored in order for clipping to work.", MessageType.Warning); } } }
public static UIPanel CreateUI(Transform trans, bool advanced3D, int layer) { UIRoot uIRoot = (!(trans != null)) ? null : NGUITools.FindInParents <UIRoot>(trans.get_gameObject()); if (uIRoot == null && UIRoot.list.get_Count() > 0) { using (List <UIRoot> .Enumerator enumerator = UIRoot.list.GetEnumerator()) { while (enumerator.MoveNext()) { UIRoot current = enumerator.get_Current(); if (current.get_gameObject().get_layer() == layer) { uIRoot = current; break; } } } } if (uIRoot != null) { UICamera componentInChildren = uIRoot.GetComponentInChildren <UICamera>(); if (componentInChildren != null && componentInChildren.GetComponent <Camera>().get_orthographic() == advanced3D) { trans = null; uIRoot = null; } } if (uIRoot == null) { GameObject gameObject = NGUITools.AddChild(null, false); uIRoot = gameObject.AddComponent <UIRoot>(); if (layer == -1) { layer = LayerMask.NameToLayer("UI"); } if (layer == -1) { layer = LayerMask.NameToLayer("2D UI"); } gameObject.set_layer(layer); if (advanced3D) { gameObject.set_name("UI Root (3D)"); uIRoot.scalingStyle = UIRoot.Scaling.Constrained; } else { gameObject.set_name("UI Root"); uIRoot.scalingStyle = UIRoot.Scaling.Flexible; } } UIPanel uIPanel = uIRoot.GetComponentInChildren <UIPanel>(); if (uIPanel == null) { Camera[] array = NGUITools.FindActive <Camera>(); float num = -1f; bool flag = false; int num2 = 1 << uIRoot.get_gameObject().get_layer(); for (int i = 0; i < array.Length; i++) { Camera camera = array[i]; if (camera.get_clearFlags() == 2 || camera.get_clearFlags() == 1) { flag = true; } num = Mathf.Max(num, camera.get_depth()); camera.set_cullingMask(camera.get_cullingMask() & ~num2); } Camera camera2 = NGUITools.AddChild <Camera>(uIRoot.get_gameObject(), false); camera2.get_gameObject().AddComponent <UICamera>(); camera2.set_clearFlags((!flag) ? 2 : 3); camera2.set_backgroundColor(Color.get_grey()); camera2.set_cullingMask(num2); camera2.set_depth(num + 1f); if (advanced3D) { camera2.set_nearClipPlane(0.1f); camera2.set_farClipPlane(4f); camera2.get_transform().set_localPosition(new Vector3(0f, 0f, -700f)); } else { camera2.set_orthographic(true); camera2.set_orthographicSize(1f); camera2.set_nearClipPlane(-10f); camera2.set_farClipPlane(10f); } AudioListener[] array2 = NGUITools.FindActive <AudioListener>(); if (array2 == null || array2.Length == 0) { camera2.get_gameObject().AddComponent <AudioListener>(); } uIPanel = uIRoot.get_gameObject().AddComponent <UIPanel>(); } if (trans != null) { while (trans.get_parent() != null) { trans = trans.get_parent(); } if (NGUITools.IsChild(trans, uIPanel.get_transform())) { uIPanel = trans.get_gameObject().AddComponent <UIPanel>(); } else { trans.set_parent(uIPanel.get_transform()); trans.set_localScale(Vector3.get_one()); trans.set_localPosition(Vector3.get_zero()); NGUITools.SetChildLayer(uIPanel.cachedTransform, uIPanel.cachedGameObject.get_layer()); } } return(uIPanel); }
void LateUpdate() { // If we are in calibration scene, disable 3d cursor if (this.transform.parent == null) { this.enabled = false; return; } // TODO: instead of searching hierarchy on every frame, find the UICameras more efficiently uiCamera = ruisCamera.transform.GetComponentInChildren <UICamera>(); //menuScript.transform.parent.parent.GetComponentsInChildren<UICamera>(); if (menuScript.menuIsVisible && !instancedCursor) { instancedCursor = Instantiate(this.markerObject) as GameObject; } if (!menuScript.menuIsVisible && instancedCursor) { Destroy(instancedCursor); } if (!menuScript.menuIsVisible) { return; } mouseInputCoordinates = Input.mousePosition; if (ruisCamera.centerCamera) { if (instancedCursor) { instancedCursor.transform.rotation = ruisCamera.centerCamera.transform.rotation; } } else { if (instancedCursor) { instancedCursor.transform.rotation = ruisCamera.transform.rotation; } } // HACK for MecanimBlendedCharacter: Keep cursor visible size even if character is scaled if (menuScript.transform.parent) { instancedCursor.transform.localScale = originalLocalScale * Mathf.Max(menuScript.transform.parent.lossyScale.x, menuScript.transform.parent.lossyScale.y); } RaycastHit hit; if (uiCamera) { /* * if(!ruisCamera.associatedDisplay.isStereo * && (camera.gameObject.name == "CameraLeft" || camera.gameObject.name == "CameraRight" || camera.gameObject.name == "guiCameraForRift" ||)) ||{ || camera.enabled = false; || continue; ||} || ||if(ruisCamera.associatedDisplay.isStereo || && !ruisCamera.associatedDisplay.enableOculusRift || && !(camera.gameObject.name == "CameraLeft" || camera.gameObject.name == "CameraRight" || )) || { || camera.enabled = false; || continue; || } ||if(ruisCamera.associatedDisplay.enableOculusRift || && camera.gameObject.name != "guiCameraForRift") || { || camera.enabled = false; || continue; || } */ Ray ray; Camera rayCamera = uiCamera.GetComponent <Camera>(); if (rayCamera) { if (UnityEngine.XR.XRSettings.enabled && rayCamera.stereoTargetEye != StereoTargetEyeMask.None) // if(ruisCamera.associatedDisplay != null && ruisCamera.associatedDisplay.isHmdDisplay) { // *** TODO remove this hack when Camera.ScreenPointToRay() works again ray = RUISDisplayManager.HMDScreenPointToRay(mouseInputCoordinates, rayCamera); } else { ray = rayCamera.ScreenPointToRay(mouseInputCoordinates); } } else { ray = new Ray(); } if (ruisCamera.associatedDisplay != null && ruisCamera.associatedDisplay.isObliqueFrustum) { Quaternion outerRot = ruisCamera.transform.rotation; wallOrientation = Quaternion.LookRotation(-ruisCamera.associatedDisplay.DisplayNormal, ruisCamera.associatedDisplay.DisplayUp); // *** HACK why is this sign flip necessary to keep the menu at right place?? outerRot = new Quaternion(outerRot.x, outerRot.y, -outerRot.z, outerRot.w); instancedCursor.transform.rotation = outerRot * wallOrientation; trackerPosition = outerRot * ruisCamera.KeystoningHeadTrackerPosition; ray.origin += trackerPosition - outerRot * (new Vector3(ruisDisplayManager.guiX, ruisDisplayManager.guiY, ruisDisplayManager.guiZ)); // ray.direction = wallOrientation * ray.direction; } if (Physics.Raycast(ray, out hit, Mathf.Infinity, LayerMask.GetMask(LayerMask.LayerToName(ruisDisplayManager.menuLayer)))) { if (instancedCursor) { instancedCursor.transform.position = hit.point; if (!wasVisible) { instancedCursor.SetActive(true); } wasVisible = true; } #if UNITY_EDITOR Debug.DrawLine(ray.origin, hit.point); #endif } else { if (wasVisible) { instancedCursor.SetActive(false); } wasVisible = false; } } }
void Update() { uiCam.enabled = !GameManager.isPaused && !RoundEndManager.isRoundEnded; chatOutput.alpha = 1f - blackSprite.alpha; uiCam.GetComponent <BlurEffect>().blurSpread = blurREM; GunController primaryWep = WeaponDatabase.GetWeaponByID(primarySelection.selectionIndex); primaryTooltip.textSize = 0.8f; primaryTooltip.text = "Weapon Statistics:[C6BCB6]" + "||" + "Damage: " + (primaryWep.bulletInfo.damage * primaryWep.bulletsPerShot) + "||" + "Rate of Fire: " + primaryWep.firstRPM.ToString("F0") + " RPM" + "||" + "Vertical Recoil: " + primaryWep.upKickAmount + "||" + "Horizontal Recoil: " + primaryWep.sideKickAmount + "||" + "Effective Range: " + primaryWep.GetMinimumRange() + "-" + primaryWep.GetMaximumRange() + "m" + "||" + "Weight: " + primaryWep.weaponWeight.ToString("F2") + " kg"; GunController secondaryWep = WeaponDatabase.GetWeaponByID(secondarySelection.selectionIndex); secondaryTooltip.textSize = 0.8f; secondaryTooltip.text = "Weapon Statistics:[C6BCB6]" + "||" + "Damage: " + (secondaryWep.bulletInfo.damage * secondaryWep.bulletsPerShot) + "||" + "Rate of Fire: " + secondaryWep.firstRPM.ToString("F0") + " RPM" + "||" + "Vertical Recoil: " + secondaryWep.upKickAmount + "||" + "Horizontal Recoil: " + secondaryWep.sideKickAmount + "||" + "Effective Range: " + secondaryWep.GetMinimumRange() + "-" + secondaryWep.GetMaximumRange() + "m" + "||" + "Weight: " + secondaryWep.weaponWeight.ToString("F2") + " kg"; if (GeneralVariables.gameModeHasTeams) { if (spectateFollow.target == null) { GetAllTeamInstances(); } else { Rigidbody theRigid = spectateFollow.target.GetComponent <Rigidbody>(); if (theRigid != null && !theRigid.isKinematic) { spectateFollow.target = null; GetAllTeamInstances(); } } } if (mpGUI != null) { timeLabel.color = mpGUI.timerLabels[0].color; if (GeneralVariables.Networking.countingDown) { timeLabel.text = "MATCH STARTING: " + GeneralVariables.Networking.countdown.ToString(); } else { if (mpGUI.timerLabels[0].text == "--") { timeLabel.text = "WAITING FOR: " + mpGUI.serverPL.ToString() + " player" + ((mpGUI.serverPL == 1) ? "" : "s"); } else { timeLabel.text = mpGUI.timerLabels[0].text + ":" + mpGUI.timerLabels[1].text; } } if (GeneralVariables.gameModeHasTeams) { redTitle.text = "RED TEAM"; blueTitle.text = "BLUE TEAM"; } else { redTitle.text = (mpGUI.youAreWinning) ? "YOU" : mpGUI.winningPlayerName.ToUpper(); blueTitle.text = (mpGUI.youAreWinning) ? mpGUI.runnerUpName.ToUpper() : "YOU"; } redTeamProgress.value = mpGUI.redTeamProgress.value; redTeamProgress.foregroundWidget.color = mpGUI.redTeamProgress.foregroundWidget.color; blueTeamProgress.value = mpGUI.blueTeamProgress.value; blueTeamProgress.foregroundWidget.color = mpGUI.blueTeamProgress.foregroundWidget.color; redTeamValue.text = mpGUI.redTeamValue.text; blueTeamValue.text = mpGUI.blueTeamValue.text; } if (Topan.Network.isConnected && GeneralVariables.Networking != null) { string suffix = "ready"; int playersWaiting = Topan.Network.connectedPlayers.Length; if (GeneralVariables.Networking.matchStarted) { matchStatus.text = "BATTLE INITIATED"; matchStatus.alpha = matchStatus.defaultAlpha; suffix = "in battle"; } else { matchStatus.text = "BATTLE AWAITING"; matchStatus.alpha = (matchStatus.defaultAlpha - 0.2f) + Mathf.PingPong(Time.time * 2f * 0.2f, 0.2f); playersWaiting = Mathf.CeilToInt(playersWaiting * 0.25f); if (Topan.Network.HasServerInfo("pl")) { playersWaiting -= (int)((byte)Topan.Network.GetServerInfo("pl")); } } matchName.text = Topan.Network.GameName; matchDetails.text = StaticMapsList.mapsArraySorted[(byte)Topan.Network.GetServerInfo("m")].mapName + "\n" + "> [5C5C5C]" + NetworkingGeneral.currentGameType.typeName + "[-]" + "\n" + "\n" + Mathf.Max(0, playersWaiting).ToString() + " combatant" + ((playersWaiting == 0 || playersWaiting > 1) ? "s " : " ") + suffix; } if (spectatorPositions != null && spectatorPositions.Count > 0) { if (Input.GetKeyDown(KeyCode.Space) && !RestrictionManager.restricted && UICamera.selectedObject == null && !isTransitioning) { autoSpectate = false; StartCoroutine(TransitionToIndex(specIndex + 1)); } if (autoSpectate && Time.time - autoSpectateTimer >= spectateCycleInterval && specIndex < spectatorPositions.Count && spectatorPositions.Count > 1 && !isTransitioning) { int newRandomPoint = 0; do { newRandomPoint = Random.Range(0, spectatorPositions.Count); }while (newRandomPoint == specIndex); autoSpectateTimer = Time.time; StartCoroutine(TransitionToIndex(newRandomPoint)); } specIndex = Mathf.Clamp(specIndex, 0, spectatorPositions.Count + myAvailableTeamList.Count - 1); if (specIndex >= spectatorPositions.Count && myAvailableTeamList.Count > 0) { spectateFollow.enabled = true; spectateFollow.offset = Vector3.up * 0.8f; spectateFollow.target = myAvailableTeamList[specIndex - spectatorPositions.Count]; spectateLabel.text = "Spectating: " + myAvailableTeamList[specIndex - spectatorPositions.Count].root.name; spectateNote.text = "[SPACE] to switch cameras" + "\n" + "[RMB] to rotate camera"; } else { spectateFollow.enabled = false; spectateFollow.target = null; //Regular spectator cameras specCamTr.position = spectatorPositions[specIndex].position; specCamSway.focusRot = spectatorPositions[specIndex].eulerAngles; spectateLabel.text = "Spectating: Camera_" + (specIndex + 1).ToString("000"); spectateNote.text = "[SPACE] to switch cameras"; } } }