private void Update() { if (Input.mousePosition.y < 150) { runtimeBuilder.DisableMouseInputForBuild(); return; } else { runtimeBuilder.EnableMouseInputForBuild(); } // Press right mouse button to destroy hovering Tile (if hovering) if (Input.GetMouseButtonDown(1)) { // Get GameObject which is mouse hovering if (runtimeBuilder.GetCurrentSelectedObject()) { // Destroy selected tile bool isSuccess = runtimeBuilder.DestroyCurrentSelectedObject(); if (isSuccess) { Debug.Log("Object Destroyed"); } else { Debug.Log("No Object Selected"); } } } if (Input.GetKeyDown(KeyCode.Tab)) { ShowOrHideUI(); } // Weapon animation if (Input.GetMouseButtonDown(0)) { Weapon.transform.localPosition = new Vector3(1.02f, -0.3856888f, 1.018038f); Weapon.transform.localEulerAngles = new Vector3(33f, 0, 0); } if (Input.GetMouseButtonUp(0)) { Weapon.transform.localPosition = new Vector3(1.02f, 0.1f, 1.0f); Weapon.transform.localEulerAngles = new Vector3(-14f, 0, 0); } }
private void Update() { if (Input.GetMouseButtonDown(2)) { middleClickDetected = true; } if (Input.GetMouseButtonUp(2)) { middleClickDetected = false; } if (Input.GetKeyDown(KeyCode.LeftAlt)) { cameraActionDetected = true; } if (Input.GetKeyUp(KeyCode.LeftAlt)) { cameraActionDetected = false; } #if UNITY_IOS if (Input.GetMouseButtonDown(1)) { cameraActionDetected = true; } if (Input.GetMouseButtonUp(1)) { cameraActionDetected = false; } #endif // Disable RuntimeBuild when moving camera if (middleClickDetected || cameraActionDetected) { runtimeBuilder.DisableMouseInputForBuild(); return; } else { runtimeBuilder.EnableMouseInputForBuild(); } if (Input.mousePosition.y < 70) { runtimeBuilder.DisableMouseInputForBuild(); } else { runtimeBuilder.EnableMouseInputForBuild(); } if (Input.GetKeyDown(KeyCode.LeftAlt)) { runtimeBuilder.DisableMouseInputForBuild(); } if (Input.GetKeyUp(KeyCode.LeftAlt)) { runtimeBuilder.EnableMouseInputForBuild(); return; } /* * if(Input.mousePosition.y<100) * { * // Disable ability to build * runtimeBuilder.DisableToBuild(); * } * else * { * Enable ability to build * runtimeBuilder.EnableToBuild(); * } */ // Press O to rotate current tile LEFT if (Input.GetKeyDown(KeyCode.O)) { runtimeBuilder.RotateCurrentTileLeft(); // runtimeBuilder.AddTileInCategory(GameObject.Find("CubeCube"),"Castle","Test","My Test",new Texture2D(20,20),true); } // Press P to rotate current tile RIGHT else if (Input.GetKeyDown(KeyCode.P)) { // runtimeBuilder.RemoveTileFromCategory("Castle","Test"); runtimeBuilder.RotateCurrentTileRight(); } // Press K to rotate current tile UP else if (Input.GetKeyDown(KeyCode.K)) { runtimeBuilder.RotateCurrentTileUp(); } // Press L to rotate current tile DOWN else if (Input.GetKeyDown(KeyCode.L)) { runtimeBuilder.RotateCurrentTileDown(); } // Press J to FLIP tile else if (Input.GetKeyDown(KeyCode.J)) { runtimeBuilder.RotateCurrentTileFlip(); } // Press SPAPCE to destroy hovering Tile (if hovering) else if (Input.GetKeyDown(KeyCode.Space)) { // Get GameObject which is mouse hovering if (runtimeBuilder.GetCurrentSelectedObject()) { // Destroy selected tile bool isSuccess = runtimeBuilder.DestroyCurrentSelectedObject(); if (isSuccess) { Debug.Log("Object Destroyed"); } else { Debug.Log("No Object Selected"); } } } // Press 1 to set build mode to NORMAL else if (Input.GetKeyDown(KeyCode.Alpha1)) { runtimeBuilder.SetBuildMode(uteRuntimeBuilder.BuildMode.Normal); } // Press 2 to set build mode to Continous else if (Input.GetKeyDown(KeyCode.Alpha2)) { runtimeBuilder.SetBuildMode(uteRuntimeBuilder.BuildMode.Continuous); } // Press 3 to set build mode to Mass else if (Input.GetKeyDown(KeyCode.Alpha3)) { runtimeBuilder.SetBuildMode(uteRuntimeBuilder.BuildMode.Mass); } // Press 4 to decrease Mass Build height else if (Input.GetKeyDown(KeyCode.Alpha4)) { runtimeBuilder.MassBuildHeightDown(); } // Press 5 to increase Mass Build height else if (Input.GetKeyDown(KeyCode.Alpha5)) { runtimeBuilder.MassBuildHeightUp(); } // Press 6 to set Mass Build height to 1 else if (Input.GetKeyDown(KeyCode.Alpha6)) { runtimeBuilder.MassBuildResetHeight(); } // Press 7 to Cancel Mass Build placement else if (Input.GetKeyDown(KeyCode.Alpha7)) { runtimeBuilder.MassBuildCancel(); } // Press 9 Save Map as test1 else if (Input.GetKeyDown(KeyCode.Alpha9)) { runtimeBuilder.SaveMap("test1"); } // Press 8 to Load Map with name test1 else if (Input.GetKeyDown(KeyCode.Alpha8)) { runtimeBuilder.LoadMap("test1"); // To Load Map additively use runtimeBuilder.LoadMap("test1",true); } // Press 0 to Delete Map with name test1 else if (Input.GetKeyDown(KeyCode.Alpha0)) { runtimeBuilder.DeleteMap("test1"); } // Batch Static Tiles else if (Input.GetKeyDown(KeyCode.B)) { // first argument is to add mesh collider (important to note that if you add mesh collider and you destroy selected "tile" it will destroy the whole batched mesh) // second to remove objects that are left after batching (important to note that if you remove all leftovers you will not be able to save your map at runtime) // Basically use true/true only if you load map for playable version runtimeBuilder.Batch(false, false); } else if (Input.GetKeyDown(KeyCode.V)) { // Unbach Tiles (only if you do not remove left overs with Batch) runtimeBuilder.UnBatch(); } else if (Input.GetKeyDown(KeyCode.H)) { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { // Procedural Tile placement at Vector3 position runtimeBuilder.PlaceCurrentTileAtPosition(new Vector3(i, 1, j)); } } } else if (Input.GetKeyDown(KeyCode.F)) { // Place Tile at current position (by default is now with mouse click but you can force it to place with other inputs) runtimeBuilder.PlaceCurrentTileAtCurrentPosition(); // If you want to disable default mouse click tile placement use: // runtimeBuilder.DisableMouseInputForBuild(); } }