// Use this for initialization void Start () { wanted_mode = CursorLockMode.Locked; targetDirection = transform.localRotation.eulerAngles; controller = GetComponent<CharacterController>(); health = GetComponent<PlayerHealth>(); Go_To_Spawn(); }
// Use this for initialization void Start() { _mo= GameObject.Find("MainCamera").GetComponent<mouseorbit>(); _player = GameObject.Find ("player"); Cursor.visible = false; Cmode = CursorLockMode.Locked; }
// Use this for initialization void Update() { if (Input.GetKeyDown(KeyCode.Escape)) Cursor.lockState = wantedMode = CursorLockMode.None; }
public void ApplyMode() { switch (lockMode) { case CurState.None: _newMode = CursorLockMode.None; break; case CurState.LockedToCenter: _newMode = CursorLockMode.Locked; break; case CurState.ConfinedToGameWindow: _newMode = CursorLockMode.Confined; break; } switch (renderMode) { case RenderMode.Auto: _renderAs = CursorMode.Auto; break; case RenderMode.ForceSoftware: _renderAs = CursorMode.ForceSoftware; break; } Cursor.visible = !hideCursor.Value; Texture2D newTexture = cursorTexture.Value as Texture2D; Cursor.SetCursor(newTexture, (hotSpot.IsNone) ? Vector2.zero : hotSpot.Value, _renderAs); Cursor.lockState = _newMode; }
void OnGUI() { GUILayout.BeginVertical(); // Release cursor on escape keypress if (Input.GetKeyDown(KeyCode.Escape)) Cursor.lockState = wantedMode = CursorLockMode.None; switch (Cursor.lockState) { case CursorLockMode.None: GUILayout.Label("Cursor is normal"); if (GUILayout.Button("Lock cursor")) wantedMode = CursorLockMode.Locked; if (GUILayout.Button("Confine cursor")) wantedMode = CursorLockMode.Confined; break; case CursorLockMode.Confined: GUILayout.Label("Cursor is confined"); if (GUILayout.Button("Lock cursor")) wantedMode = CursorLockMode.Locked; if (GUILayout.Button("Release cursor")) wantedMode = CursorLockMode.None; break; case CursorLockMode.Locked: GUILayout.Label("Cursor is locked"); if (GUILayout.Button("Unlock cursor")) wantedMode = CursorLockMode.None; if (GUILayout.Button("Confine cursor")) wantedMode = CursorLockMode.Confined; break; } GUILayout.EndVertical(); SetCursorState(); }
void Start() { Cursor.lockState = wantedMode; Cursor.visible = false; wantedMode = CursorLockMode.Locked; cameraTransform = Camera.main.transform; rb = GetComponent<Rigidbody> (); }
void AssureCursorState(CursorLockMode lockMode, bool visibility) { if (Cursor.lockState != lockMode) { Cursor.lockState = lockMode; } if (Cursor.visible != visibility) { Cursor.visible = visibility; } }
void Start() { wantedMode = CursorLockMode.Locked; Cursor.lockState = wantedMode; // Hide cursor when locking Cursor.visible = (CursorLockMode.Locked != wantedMode); invertVert = PlayerPrefs.GetInt("InvertVert") == 1 ? true : false; invertHorizontal = PlayerPrefs.GetInt("InvertHorizontal") == 1 ? true : false; }
/*void SetCursorState () { Cursor.lockState = wantedMode; // Hide cursor when locking Cursor.visible = (CursorLockMode.Locked != wantedMode); } */ // Update is called once per frame void Update () { if (Input.GetKeyDown("escape")) print("escape key was hit"); Cursor.lockState = wantedMode = CursorLockMode.Locked; //Cursor.lockState = wantedMode = CursorLockMode.Locked; }
public void SetLockState(bool locked) { if (locked) { wanted = CursorLockMode.Locked; } else { wanted = CursorLockMode.None; } visible = !locked; //SetCursor(); }
// Update is called once per frame void Update() { Cursor.lockState = clm; if (cursor == true) { Cursor.visible = true; clm = CursorLockMode.None; } else { Cursor.visible = false; clm = CursorLockMode.Locked; //test ederken rahatsız edecektir test süresince kapatmanı tavsiye ederim } if (oyuncudis <= 3) { if(Input.GetButtonDown("talk")) { //"talk" kısmı inputlardan atanması gerekiyor talksekmesi.SetActive (true); konusmadurumubende = true; firstname = gameObject.name; fpc.enabled = false; cursor = true; } } if (Input.GetButtonUp ("talk") && konusmadurumubende == true) { talksekmesi.SetActive (false); gameObject.name = isimci.name; isimci.name = firstname; fpc.enabled = true; cursor = false; } oyuncudis = Vector3.Distance (transform.position, player.position); // odun1 yazan kısma butondaki isim değiştirme functionına göre isim veriniz if (gameObject.name == "odun1") { gameObject.GetComponent<AICharacterControl> ().target = odun1; } }
public void SetCursorState(CursorLockMode mode) { m_lastRequestedCursorState = mode; Cursor.lockState = mode; Cursor.visible = (CursorLockMode.Locked != mode); #if UNITY_EDITOR //Confined mode doesn't work in the editor for some reason. if (mode == CursorLockMode.Confined) { Cursor.lockState = CursorLockMode.None; } #endif }
//cursor_control; void _cursor() { Cursor.lockState = Cmode; if(Input.GetKeyUp(KeyCode.LeftAlt)){ Cursor.visible=!Cursor.visible; if(Cmode == CursorLockMode.None){ Cmode = CursorLockMode.Locked; _mo.enabled = true; }else if(Cmode == CursorLockMode.Locked){ Cmode = CursorLockMode.None; _mo.enabled = false; } } }
void FixedUpdate() { // if (player.inMenu == false) { if (Input.GetKeyDown(KeyCode.Escape) && wantedMode != CursorLockMode.None) { Cursor.lockState = wantedMode = CursorLockMode.None; SetCursorState(); } if (Input.GetMouseButtonDown(0) && wantedMode != CursorLockMode.Locked) { Cursor.lockState = wantedMode = CursorLockMode.Locked; SetCursorState(); } // } else if (wantedMode == CursorLockMode.Locked) { // Cursor.lockState = wantedMode = CursorLockMode.None; // SetCursorState(); // } }
// Update is called once per frame void Update () { if (gameObject.activeInHierarchy) { wantedMode = CursorLockMode.Confined; Cursor.lockState = wantedMode; // Hide cursor when locking Cursor.visible = true; } playerList.text = ""; foreach(PhotonPlayer player in PhotonNetwork.playerList) { playerList.text += player.name + "\n"; } playerNumber.text = "Ready Players " + vehicleSpawn.Players.Length + "/" + PhotonNetwork.playerList.Length; }
// Update is called once per frame void Update () { if (Input.GetButtonDown("Cancel")) { leaveButton.SetActive(!leaveButton.activeInHierarchy); if (leaveButton.activeInHierarchy) { wantedMode = CursorLockMode.Confined; Cursor.lockState = wantedMode; // Hide cursor when locking Cursor.visible = true; } else { wantedMode = CursorLockMode.Locked; Cursor.lockState = wantedMode; // Hide cursor when locking Cursor.visible = false; } } }
void OnGUI() { GUILayout.BeginVertical (); if (Input.GetKeyDown (KeyCode.Escape)) { Cursor.lockState = wantedMode = CursorLockMode.None; } switch (Cursor.lockState) { case CursorLockMode.None: GUILayout.Label("Cursor is Normal"); if(GUILayout.Button("Lock Cursor")) { wantedMode = CursorLockMode.Locked; } break; case CursorLockMode.Locked: GUILayout.Label ("Cursor is Locked Press Escape to Unlock"); break; } // if (isSphere == true) { // sphereCount++; // } // // if (isCube == true) { // cubeCount++; // } // // GUILayout.Label ("Spheres "+ sphereCount); // GUILayout.Label ("Cubes " + cubeCount); GUILayout.EndVertical (); SetCursorState (); }
public void SetState(CursorLockMode state) { //Set state of cursor Cursor.lockState = state; }
public void SetToCursor() { lockModeIntended = CursorLockMode.Confined; SetLockedModeToIntended(); }
public SceneInfo(string scene, string displayNameTranslationKey, bool revertTime = true, CursorLockMode lockMode = CursorLockMode.None, int index = 0) { // Setup all member variables scenePath = scene; displayName = displayNameTranslationKey; revertTimeScale = revertTime; cursorMode = lockMode; ordinal = index; // Setup translation variable translatedDisplayName = new TranslatedString(displayName, (Ordinal + 1)); }
void UpdateCursorStatus(CursorLockMode _clmMode, bool _bIsvisible) { Cursor.lockState = _clmMode; Cursor.visible = _bIsvisible; }
void OnGUI() { //Rect textureCrop = new Rect ((tex.width/2f-Screen.width/2f)/tex.width, (tex.height/2f-Screen.height/2f)/tex.height, Screen.width/tex.width, Screen.height/tex.height); // Rect textureCrop = new Rect ((tex.width/2f-Screen.width/2f)/tex.width, (tex.height/2f-Screen.height/2f)/tex.height, 1f, 1f); // Vector2 position = new Vector2 (Screen.width/2f, 0f); // GUI.BeginGroup (new Rect (position.x, position.y, tex.width * textureCrop.width, tex.height * textureCrop.height)); GUI.DrawTexture(new Rect(Screen.width / 2, 0, Screen.width / 2, Screen.height), tex); // GUI.DrawTexture (new Rect (-tex.width * textureCrop.x, -tex.height * textureCrop.y, tex.width * textureCrop.width, tex.height * textureCrop.height), tex ); // GUI.EndGroup (); if (Input.GetKeyDown(KeyCode.Escape)) { Cursor.lockState = wantedMode = CursorLockMode.None; } GUILayout.BeginVertical(); // Release cursor on escape keypress // if (Input.GetKeyDown (KeyCode.Escape)) { // // switch(Cursor.lockState) { // case CursorLockMode.None: // wantedMode = CursorLockMode.Locked; // break; // case CursorLockMode.Locked: // wantedMode = CursorLockMode.None; // break; // case CursorLockMode.Confined: // wantedMode = CursorLockMode.None; // break; // } // // } switch (Cursor.lockState) { case CursorLockMode.None: GUILayout.Label("Cursor is normal"); if (GUILayout.Button("Lock cursor")) { wantedMode = CursorLockMode.Locked; } if (GUILayout.Button("Confine cursor")) { wantedMode = CursorLockMode.Confined; } break; case CursorLockMode.Confined: GUILayout.Label("Cursor is confined"); if (GUILayout.Button("Lock cursor")) { wantedMode = CursorLockMode.Locked; } if (GUILayout.Button("Release cursor")) { wantedMode = CursorLockMode.None; } break; case CursorLockMode.Locked: GUILayout.Label("Cursor is locked"); if (GUILayout.Button("Unlock cursor")) { wantedMode = CursorLockMode.None; } if (GUILayout.Button("Confine cursor")) { wantedMode = CursorLockMode.Confined; } break; } GUILayout.EndVertical(); SetCursorState(); }
void SaveCursorState() { savedCursorVisible = Cursor.visible; savedCursorLockState = Cursor.lockState; }
void Awake() { lockMode = CursorLockMode.Locked; Cursor.lockState = lockMode; Cursor.visible = false; }
void Start() { cursorMode = CursorLockMode.Locked; SetCursorState(); }
void lockmouse() { Cursor.lockState = wantedMode = CursorLockMode.Locked; }
/// <summary> Make the EditorWindow fullscreen, or return to how it was. Opens the fullscreen window on the screen at a specified position. </summary> public static void SetFullscreen(this EditorWindow editorWindow, bool setFullscreen, Vector2 atPosition) { Type windowType = editorWindow.GetWindowType(); var fullscreenState = EditorFullscreenState.FindWindowState(editorWindow); CursorLockMode currentCursorLockMode = Cursor.lockState; if (setFullscreen == false) { if (fullscreenState.EditorWin != null) { if (fullscreenState.CloseOnExitFullscreen) { //Close the window editorWindow.Close(); } else { //Restore the window editorWindow.SetBorderlessPosition(fullscreenState.PreFullscreenPosition); fullscreenState.EditorWin.minSize = fullscreenState.PreFullscreenMinSize; fullscreenState.EditorWin.maxSize = fullscreenState.PreFullscreenMaxSize; fullscreenState.EditorWin.position = fullscreenState.PreFullscreenPosition; if (editorWindow.maximized != fullscreenState.PreFullscreenMaximized) { editorWindow.maximized = fullscreenState.PreFullscreenMaximized; } } } if (editorWindow.GetWindowType() == FS.gameViewType) { Unsupported.SetAllowCursorLock(false); //Unlock the cursor when exiting game fullscreen } if (fullscreenState.UnfocusedGameViewOnEnteringFullscreen == true) { //Refocus the first docked game view var gameView = GetDockedGameView(editorWindow, false); if (gameView != null) { gameView.Focus(); } } } else { if (!fullscreenState.IsFullscreen) { fullscreenState.PreFullscreenPosition = editorWindow.position; fullscreenState.PreFullscreenPosition.y -= FS.windowTopPadding; fullscreenState.PreFullscreenMinSize = editorWindow.minSize; fullscreenState.PreFullscreenMaxSize = editorWindow.maxSize; fullscreenState.PreFullscreenMaximized = editorWindow.maximized; } editorWindow.SetWindowTitle("FULLSCREEN_WINDOW_" + editorWindow.GetInstanceID(), true); if (!editorWindow.IsFullscreen()) { editorWindow.maximized = false; if (fullscreenState.ShowTopTabs) { editorWindow.Show(); } else { editorWindow.ShowWithMode(ShowMode.PopupMenu); editorWindow.SetSaveToLayout(true); } fullscreenState.FullscreenAtPosition = atPosition; editorWindow.SetBorderlessPosition(new Rect(atPosition.x, atPosition.y, 100, 100)); } else if (fullscreenState.IsFullscreen) { //If already fullscreen, resize slightly to make sure the taskbar gets covered (E.g. when loading fullscreen state on startup) var tempBounds = editorWindow.position; tempBounds.yMax -= 1; editorWindow.SetBorderlessPosition(tempBounds); } fullscreenState.ScreenBounds = editorWindow.MakeFullscreenWindow(!fullscreenState.ShowTopToolbar, atPosition); editorWindow.ExitFullscreenForOtherWindowsOnScreen(atPosition); fullscreenState.WindowName = editorWindow.name; fullscreenState.EditorWin = editorWindow; fullscreenState.IsFullscreen = true; //Usability improvement for Unity bug where only one visible game window accepts input. (Unfocus docked game views if opening fullscreen view on the same screen.) try { var gameView = GetDockedGameView(editorWindow, true); if (gameView != null) { bool onSameDisplay = EditorDisplay.ClosestToPoint(gameView.position.center).Bounds.Contains(atPosition); var hostView = gameView.GetHostView(); if (onSameDisplay && hostView != null && FS.dockAreaType != null) { FieldInfo m_Panes = FS.dockAreaType.GetField("m_Panes", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); var dockAreaPanes = (List <EditorWindow>)m_Panes.GetValue(hostView); foreach (var sibling in dockAreaPanes) { if (sibling.GetType() != FS.gameViewType) { sibling.Focus(); //Focus the first non-game sibling of the docked game view fullscreenState.UnfocusedGameViewOnEnteringFullscreen = true; break; } } } } } catch (System.Exception e) { if (FS.LogNonFatalErrors) { Debug.LogException(e); } } editorWindow.Focus(); Cursor.lockState = currentCursorLockMode; //Ensure that the cursor lock mode remains the same when entering fullscreen } FS.SaveFullscreenState(); FS.TriggerFullscreenEvent(editorWindow, windowType, atPosition, setFullscreen); }
void Start() { wantedMode = CursorLockMode.Locked; }
public static void Prefix_set_lockState(ref CursorLockMode value) { CursorUnlocker.Prefix_set_lockState(ref value); }
public static void ToggleCursorLockState(CursorLockMode lockmode) { Cursor.lockState = lockmode; }
void Start() { wanted = CursorLockMode.None; visible = true; }
private void RotationInput(ref float rotationX, ref float rotationY) { if (Application.isMobilePlatform) { Rect screenRect = new Rect( Screen.width * MOBILE_RECT.x, Screen.height * MOBILE_RECT.y, Screen.width * MOBILE_RECT.width, Screen.height * MOBILE_RECT.height ); for (int i = 0; i < Input.touchCount; ++i) { Touch touch = Input.touches[i]; if (touch.phase == TouchPhase.Moved && screenRect.Contains(touch.position)) { Vector2 sensitivityValue = this.sensitivity.GetValue(gameObject); rotationX = (touch.deltaPosition.x / Screen.width) * sensitivityValue.x * 10f * Time.timeScale; rotationY = (touch.deltaPosition.y / Screen.height) * sensitivityValue.y * 10f * Time.timeScale; orbitInputTime = Time.time; this.recoverSpeedX = 0f; this.recoverSpeedY = 0f; break; } } } else { bool inputConditions; if (this.orbitInput == OrbitInput.MouseMove) { inputConditions = true; } else if (this.orbitInput == OrbitInput.HoldLeftMouse && Input.GetMouseButton(0)) { inputConditions = true; } else if (this.orbitInput == OrbitInput.HoldRightMouse && Input.GetMouseButton(1)) { inputConditions = true; } else if (this.orbitInput == OrbitInput.HoldMiddleMouse && Input.GetMouseButton(2)) { inputConditions = true; } else { inputConditions = false; } if (inputConditions) { float axisX = Input.GetAxisRaw(INPUT_MOUSE_X); float axisY = Input.GetAxisRaw(INPUT_MOUSE_Y); if (this.cursorLock != Cursor.lockState && !Mathf.Approximately(axisX + axisY, 0f)) { this.cursorLock = Cursor.lockState; return; } Vector2 sensitivityValue = this.sensitivity.GetValue(gameObject); rotationX = axisX * sensitivityValue.x * Time.timeScale; rotationY = axisY * sensitivityValue.y * Time.timeScale; if (!Mathf.Approximately(axisX, 0f) || !Mathf.Approximately(axisY, 0f)) { orbitInputTime = Time.time; this.recoverSpeedX = 0f; this.recoverSpeedY = 0f; } } } }
/// <summary> /// Set a specific LockMode state /// </summary> /// <param name="lockMode">The requested state</param> public void SetCursorState(CursorLockMode lockMode) { wantedMode = lockMode; SetCursorState(); }
// Use this for initialization void Start() { Invoke("StartGame", 7f); lockMode = CursorLockMode.Locked; Cursor.visible = (CursorLockMode.Locked != lockMode); }
void Start() { rb = GetComponent <Rigidbody>(); wantedMode = CursorLockMode.Locked; SetCursorState(); }
public static void LoadScene(bool levelComplete, int sceneIndex, CursorLockMode cursorMode, params Type[] typesToDestroy) => LoadScene(levelComplete, sceneIndex, cursorMode, (IEnumerable <Type>)typesToDestroy);
public void Start() { mode = CursorLockMode.Confined; Cursor.lockState = mode; Cursor.visible = true; }
public void setCursorLockState(bool lockMouse) { cursorLockState = lockMouse ? CursorLockMode.Locked : CursorLockMode.None; }
void Start() { cursorLock = CursorLockMode.Locked; }
void OnGUI() { //Rect textureCrop = new Rect ((tex.width/2f-Screen.width/2f)/tex.width, (tex.height/2f-Screen.height/2f)/tex.height, Screen.width/tex.width, Screen.height/tex.height); // Rect textureCrop = new Rect ((tex.width/2f-Screen.width/2f)/tex.width, (tex.height/2f-Screen.height/2f)/tex.height, 1f, 1f); // Vector2 position = new Vector2 (Screen.width/2f, 0f); // GUI.BeginGroup (new Rect (position.x, position.y, tex.width * textureCrop.width, tex.height * textureCrop.height)); GUI.DrawTexture (new Rect (Screen.width/2, 0, Screen.width/2, Screen.height), tex); // GUI.DrawTexture (new Rect (-tex.width * textureCrop.x, -tex.height * textureCrop.y, tex.width * textureCrop.width, tex.height * textureCrop.height), tex ); // GUI.EndGroup (); if (Input.GetKeyDown (KeyCode.Escape)) { Cursor.lockState = wantedMode = CursorLockMode.None; } GUILayout.BeginVertical (); // Release cursor on escape keypress // if (Input.GetKeyDown (KeyCode.Escape)) { // // switch(Cursor.lockState) { // case CursorLockMode.None: // wantedMode = CursorLockMode.Locked; // break; // case CursorLockMode.Locked: // wantedMode = CursorLockMode.None; // break; // case CursorLockMode.Confined: // wantedMode = CursorLockMode.None; // break; // } // // } switch (Cursor.lockState) { case CursorLockMode.None: GUILayout.Label ("Cursor is normal"); if (GUILayout.Button ("Lock cursor")) wantedMode = CursorLockMode.Locked; if (GUILayout.Button ("Confine cursor")) wantedMode = CursorLockMode.Confined; break; case CursorLockMode.Confined: GUILayout.Label ("Cursor is confined"); if (GUILayout.Button ("Lock cursor")) wantedMode = CursorLockMode.Locked; if (GUILayout.Button ("Release cursor")) wantedMode = CursorLockMode.None; break; case CursorLockMode.Locked: GUILayout.Label ("Cursor is locked"); if (GUILayout.Button ("Unlock cursor")) wantedMode = CursorLockMode.None; if (GUILayout.Button ("Confine cursor")) wantedMode = CursorLockMode.Confined; break; } GUILayout.EndVertical (); SetCursorState (); }
void OnGUI() { GUILayout.BeginVertical (); GUILayout.Label("Player Health: " + gameObject.GetComponent<HealthControllerExample>().health); GUIStyle FPSStyle = new GUIStyle (); float msec = deltaTime * 1000.0f; float fps = 1.0f / deltaTime; if (fps < 10) { FPSStyle.normal.textColor = Color.red; } else { if (fps < 30){ FPSStyle.normal.textColor = Color.yellow; } else { FPSStyle.normal.textColor = Color.green; } } string fpsText = string.Format ("{0:0.0} ms ({1:0.} fps)", msec, fps); GUILayout.Label (fpsText, FPSStyle); if (Input.GetKeyDown (KeyCode.Escape)) Cursor.lockState = wantedMode = CursorLockMode.None; switch (Cursor.lockState) { case CursorLockMode.None: GUILayout.Label ("Cursor is normal"); if (GUILayout.Button ("Lock cursor")) wantedMode = CursorLockMode.Locked; if (GUILayout.Button ("Confine cursor")) wantedMode = CursorLockMode.Confined; break; case CursorLockMode.Confined: GUILayout.Label ("Cursor is confined"); if (GUILayout.Button ("Lock cursor")) wantedMode = CursorLockMode.Locked; if (GUILayout.Button ("Release cursor")) wantedMode = CursorLockMode.None; break; case CursorLockMode.Locked: GUILayout.Label ("Cursor is locked"); if (GUILayout.Button ("Unlock cursor")) wantedMode = CursorLockMode.None; if (GUILayout.Button ("Confine cursor")) wantedMode = CursorLockMode.Confined; break; } if (randomizer) { GUILayout.Label (""); if (GUILayout.Button ("Full Room")) { randize.MakeRoom(1, 0, 0); } if (GUILayout.Button ("Nort Room")){ randize.MakeRoom(1, 1, 0); } if (GUILayout.Button ("East Room")) { randize.MakeRoom(1, 2, 0); } if (GUILayout.Button ("Sout Room")) { randize.MakeRoom(1, 3, 0); } if (GUILayout.Button ("West Room")) { randize.MakeRoom(1, 4, 0); } } GUILayout.EndVertical (); SetCursorState (); }
void Start() { cc = GetComponent <CharacterController>(); cursorLock = CursorLockMode.Locked; }
private void UnlockCursor() { lockModeCurrent = CursorLockMode.None; Cursor.lockState = lockModeCurrent; }
void SetCursorMode(CursorLockMode mode) { Cursor.lockState = mode; }
private void SetLockedModeToIntended() { lockModeCurrent = lockModeIntended; Cursor.lockState = lockModeIntended; }
private void Start() { this.lastCursorMode = CursorLockMode.Locked; }
public void SetLocked() { lockModeIntended = CursorLockMode.Locked; SetLockedModeToIntended(); }
void SetCursorState(CursorLockMode wantedMode) { Cursor.lockState = wantedMode; // Hide cursor when locking Cursor.visible = (CursorLockMode.Locked != wantedMode); }
/// <summary> /// Allow the current camera controls to determine the mouse lock state /// Also possible to simply apply LockState (when false) /// </summary> /// <param name="useStates">Whether or not to let the controls determine the state</param> public void SetCursorState(bool useStates = false) { if (useStates) { //wantedMode = CursorLockMode.Confined; wantedMode = CursorLockMode.None; } Cursor.lockState = wantedMode; // Hide cursor when locking Cursor.visible = (CursorLockMode.Locked != wantedMode); }
void doCursor() { Cursor.lockState = cursorLock; cursorLock = CursorLockMode.Locked; }
// Update is called once per frame void Update() { if(ps != null) { #region Health Bar healthText.text = (int)System.Math.Ceiling(ps.health) + "/" + System.Math.Ceiling(ps.maxHealth); healthSlider.value = (ps.health / ps.maxHealth); if(playerNameText.text == "") playerNameText.text = ps.playerName; #endregion #region Action Bar ActionBarUpdate(ref ability1, ps.abilities[0]); ActionBarUpdate(ref ability2, ps.abilities[1]); ActionBarUpdate(ref ability3, ps.abilities[2]); if(tooltips.Length > 0) { // Show area of effect when tooltip is being hovered over if (tooltips[0].isOn) ps.abilities[0].ShowAreaOfEffect(true); else ps.abilities[0].ShowAreaOfEffect(false); if (tooltips[1].isOn) ps.abilities[1].ShowAreaOfEffect(true); else ps.abilities[1].ShowAreaOfEffect(false); if (tooltips[2].isOn) ps.abilities[2].ShowAreaOfEffect(true); else ps.abilities[2].ShowAreaOfEffect(false); } #endregion #region Trap Bar if (Input.GetKeyDown(KeyCode.Alpha1) && !ps.GetComponentInChildren<SpawnTraps>().isPlacing && !OnCooldown(trap1Cooldown, trap1Timer) && ps.CanIMove()) { SpawnBananaTrap(); } ActionBarUpdate(ref trap1, trap1Cooldown, trap1Timer); if (Input.GetKeyDown(KeyCode.Alpha2) && !ps.GetComponentInChildren<SpawnTraps>().isPlacing && !OnCooldown(trap2Cooldown, trap2Timer) && ps.CanIMove()) { SpawnSpikeTrap(); } ActionBarUpdate(ref trap2, trap2Cooldown, trap2Timer); if (Input.GetKeyDown(KeyCode.Alpha3) && !ps.GetComponentInChildren<SpawnTraps>().isPlacing && !OnCooldown(trap3Cooldown, trap3Timer) && ps.CanIMove()) { SpawnSapTrap(); } ActionBarUpdate(ref trap3, trap3Cooldown, trap3Timer); #endregion #region Cast Bar (currently working for respawning, stunned, drowning and camouflage) if (ps.isDead) { // RESPAWNING if (!castBar.gameObject.activeSelf || currentText != "Respawning") { //Reset graphics and text if disabled or using the wrong text castBar.gameObject.SetActive(true); castBar.fillRect.GetComponentInChildren<Image>().color = new Color(238f / 255f, 0f, 2f / 255f); castBar.targetGraphic.GetComponentInChildren<Image>().color = new Color(51f / 255f, 68f / 255f, 34f / 255f); currentText = "Respawning"; castBar.GetComponentInChildren<Text>().text = currentText; } float value = 1 - (ps.deathTimeLeft() / ps.deathCooldown); if (value > 0) castBar.value = value; else castBar.gameObject.SetActive(false); } else if (ps.isStunned) { // STUNNED if (!castBar.gameObject.activeSelf || currentText.Substring(0, 7) != "Stunned") { castBar.gameObject.SetActive(true); castBar.fillRect.GetComponentInChildren<Image>().color = new Color(248f / 255f, 74f / 255f, 2f / 255f); castBar.targetGraphic.GetComponentInChildren<Image>().color = new Color(255f / 255f, 255f / 255f, 255f / 255f); currentText = "Stunned"; castBar.GetComponentInChildren<Text>().text = currentText; castBar.value = 1; } float value = ps.stunTimeLeft(); if (value > 0.01f) castBar.GetComponentInChildren<Text>().text = "Stunned for " + Mathf.Ceil(value) + "s.."; else castBar.gameObject.SetActive(false); } else if(pl.isSwimming) { // DROWNING if (!castBar.gameObject.activeSelf || currentText != "Drowning") { castBar.gameObject.SetActive(true); castBar.fillRect.GetComponentInChildren<Image>().color = new Color(67f / 255f, 112f / 255f, 238f / 255f); castBar.targetGraphic.GetComponentInChildren<Image>().color = new Color(51f / 255f, 68f / 255f, 255f / 255f); currentText = "Drowning"; castBar.GetComponentInChildren<Text>().text = currentText; } float value = 1 - pl.drownTimeLeft(); if (value > 0.01f) castBar.value = value; else castBar.gameObject.SetActive(false); } else if (ps.GetComponent<Camouflage>().isCamouflaged) { // STEALTHED if (!castBar.gameObject.activeSelf || currentText.Substring(0, 7) != "Stealth") { castBar.gameObject.SetActive(true); castBar.fillRect.GetComponentInChildren<Image>().color = new Color(49f / 255f, 187f / 255f, 0f / 255f); //Foreground castBar.targetGraphic.GetComponentInChildren<Image>().color = new Color(51f / 255f, 68f / 255f, 37f / 255f); //Background currentText = "Stealthed"; castBar.GetComponentInChildren<Text>().text = currentText; castBar.value = 1; } float timer = ps.GetComponent<Camouflage>().stealthTimeLeft(true); float value = ps.GetComponent<Camouflage>().stealthTimeLeft(false); if (!ps.GetComponent<Camouflage>().hasMovedFromCamouflagePoint) { castBar.GetComponentInChildren<Text>().text = "Stealthed ..."; } else if (timer > 0.01f) { castBar.GetComponentInChildren<Text>().text = "Stealthed for " + Mathf.Ceil(timer) + "s.."; castBar.value = value; } else castBar.gameObject.SetActive(false); } else if (castBar.gameObject.activeSelf) { if(!currentText.EndsWith("Berries")) castBar.gameObject.SetActive(false); } #endregion if(Input.GetKeyDown(KeyCode.Tab)) { if(!scoreBoard.showScoreBoard) pl.TriggerScoreBoard(); scoreBoard.showScoreBoard = !scoreBoard.showScoreBoard; } } // When pressing Alt the mouse will be released from whatever state is set if(Input.GetMouseButtonDown(1)) { if (wantedMode != CursorLockMode.Locked) { Cursor.lockState = wantedMode = CursorLockMode.Locked; SetCursorState(); } else SetCursorState(true); } if (Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1)) { if (wantedMode != CursorLockMode.None) { Cursor.lockState = wantedMode = CursorLockMode.None; SetCursorState(); } else SetCursorState(true); } }
/// <summary> /// 设置光标显示模式 /// </summary> /// <param name="visible">是否显示</param> /// <param name="locked">0=无限制,1=游戏中心,2=游戏窗口范围内</param> public void SetCursor(bool visible, CursorLockMode locked) { Cursor.visible = visible; Cursor.lockState = locked; }
void Update() { // Look rotation: transform.Rotate(Vector3.up * Input.GetAxis("Mouse X") * mouseSensitivityX); verticalLookRotation += Input.GetAxis("Mouse Y") * mouseSensitivityY; verticalLookRotation = Mathf.Clamp(verticalLookRotation,-60,60); cameraTransform.localEulerAngles = Vector3.left * verticalLookRotation; // Calculate movement: float inputX = Input.GetAxisRaw("Horizontal"); float inputY = Input.GetAxisRaw("Vertical"); Vector3 moveDir = new Vector3(inputX,0, inputY).normalized; Vector3 targetMoveAmount = moveDir * walkSpeed; moveAmount = Vector3.SmoothDamp(moveAmount,targetMoveAmount,ref smoothMoveVelocity,.15f); // Jump if (Input.GetButtonDown("Jump")) { if (grounded) { rb.AddForce(transform.up * jumpForce); Debug.Log ("Jump!"); } } // Grounded check Ray ray = new Ray(transform.position, -transform.up); RaycastHit hit; //if (Physics.Raycast(ray, out hit, 2f + .1f, groundedMask)) { if (Physics.Raycast(transform.position, -transform.up, 3)) { grounded = true; } else { grounded = false; } if (Input.GetKeyDown (KeyCode.Escape)) { Cursor.lockState = wantedMode = CursorLockMode.None; Cursor.visible = true; Debug.Log ("Free"); } }
void Update() { if // dead (User.Health <= 0f) { makeBombInvisible(); } // frag monitor // if its been long enough since last frag, reset MultiFrag count if (Time.time - PrevFrag > 10f) { MultiFragCount = 0; } if (User.local) { net.LocEnt.Actor = this; // fov adjustment // Camera.main.aspect == the horizontal proportion (compared to the vertical proportion of 1.0) // Camera.main.fieldOfView == VERTICAL FOV Camera.main.fieldOfView = (1.0f / Camera.main.aspect) * FOV; if (Spectating) { stickToSpectated(); return; } else { localUserUpdate(); } } else { if (lastUpdateTime > 0f) { NonLocalUpdate(); } // visible avatar anims camHolder.transform.localEulerAngles = camAngle; } setEyeHeight(); Vector3 lookDir = camHolder.transform.forward; //lookDir.y = 0; lookDir.Normalize(); animObj.transform.LookAt(animObj.transform.position + lookDir, transform.up); animObj.transform.localEulerAngles = new Vector3(0, animObj.transform.localEulerAngles.y, 0); showCorrectGuns(); //animate(); setVulnerability(); setHudGunVis(); // sync model to body var v = transform.position; v.y -= 0.9f; // FIXME: i think height is 1.8 //Model.transform.position = v; //Model.transform.rotation = transform.rotation; //Model.transform.localEulerAngles = new Vector3(0, bod.transform.eulerAngles.y, 0); prevLockMode = Cursor.lockState; }
void OnEnable() { savedCursorMode = Cursor.lockState; Cursor.lockState = CursorLockMode.Locked; }
void Start() { rotationY = 0.0f; rotationX = 0.0f; FOV = 90.0f; gunShot = this.GetComponent<AudioSource> (); wantedMode = CursorLockMode.Locked; sensitivityM = sensitivityMDefault; }
private void BasicFirstPersonControls() { Vector3 moveDirection = Vector3.zero; if (Input.GetKey(KeyCode.W)) { moveDirection += transform.forward; } if (Input.GetKey(KeyCode.S)) { moveDirection += -transform.forward; } if (Input.GetKey(KeyCode.A)) { moveDirection += -transform.right; } if (Input.GetKey(KeyCode.D)) { moveDirection += transform.right; } if (Input.GetKey(KeyCode.Space)) { moveDirection += transform.up; } if (Input.GetKey(KeyCode.LeftShift)) { moveDirection += -transform.up; } transform.position += moveDirection.normalized * speed * Time.deltaTime; float mouseX = Input.GetAxis("Mouse X"); float mouseY = Input.GetAxis("Mouse Y"); if (mouseX > 0 || mouseY > 0) { transform.Rotate(Vector3.up, mouseX * motionScale * Time.deltaTime, Space.World); CameraUpDownMovement(); } if (mouseX < 0 || mouseY < 0) { transform.Rotate(Vector3.down, -mouseX * motionScale * Time.deltaTime, Space.World); CameraUpDownMovement(); } //This will also deal with opening the menu and what not if (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Escape)) { if (cursorMode != CursorLockMode.Locked) { cursorMode = CursorLockMode.Locked; } else if (cursorMode == CursorLockMode.Locked) { cursorMode = CursorLockMode.None; } SetCursorState(); } }
void Update() { wantedMode = CursorLockMode.Locked; SetCursorState(); }
void Awake() { lockMode = CursorLockMode.Locked; Cursor.lockState = lockMode; }