Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Item1Texture : Texture;
- var Item2Texture : Texture;
- var Item3Texture : Texture;
- var Item4Texture : Texture;
- //=======================
- @HideInInspector
- var Item1Place : boolean;
- @HideInInspector
- var Item2Place : boolean;
- @HideInInspector
- var Item3Place : boolean;
- @HideInInspector
- var Item4Place : boolean;
- @HideInInspector
- var Item1TextureChange : boolean;
- @HideInInspector
- var Item2TextureChange : boolean;
- @HideInInspector
- var Item3TextureChange : boolean;
- @HideInInspector
- var Item4TextureChange : boolean;
- @HideInInspector
- var range : float = Mathf.Infinity;
- @HideInInspector
- var hit : RaycastHit;
- @HideInInspector
- var BlockTexture : Texture;
- //=======================
- //var EnableGlobalPlacement : boolean;
- function Update()
- {
- if(Input.GetKeyDown("1"))
- {
- Item1Place = true;
- Item2Place = false;
- Item3Place = false;
- Item4Place = false;
- //seperator
- Item2TextureChange = false;
- Item3TextureChange = false;
- Item4TextureChange = false;
- Item1TextureChange = true;
- }
- if(Input.GetKeyDown("2"))
- {
- Item1Place = false;
- Item2Place = true;
- Item3Place = false;
- Item4Place = false;
- //seperator
- Item1TextureChange = false;
- Item3TextureChange = false;
- Item4TextureChange = false;
- Item2TextureChange = true;
- }
- if(Input.GetKeyDown("3"))
- {
- Item1Place = false;
- Item2Place = false;
- Item3Place = true;
- Item4Place = false;
- //seperator
- Item1TextureChange = false;
- Item2TextureChange = false;
- Item4TextureChange = false;
- Item3TextureChange = true;
- }
- if(Input.GetKeyDown("4"))
- {
- Item1Place = false;
- Item2Place = false;
- Item3Place = false;
- Item4Place = true;
- //seperator
- Item1TextureChange = false;
- Item2TextureChange = false;
- Item3TextureChange = false;
- Item4TextureChange = true;
- }
- //Enable or Disable Global Placement
- // GetComponent(Place).enabled = true;
- if(Item1Place == true)
- {
- if (Input.GetMouseButtonDown(0))
- {
- Build();
- }
- }
- if(Item2Place == true)
- {
- if (Input.GetMouseButtonDown(0))
- {
- Build();
- }
- }
- if(Item3Place == true)
- {
- if (Input.GetMouseButtonDown(0))
- {
- Build();
- }
- }
- if(Item4Place == true)
- {
- if (Input.GetMouseButtonDown(0))
- {
- Build();
- }
- }
- if(Item1TextureChange == true)
- {
- BlockTexture = Item1Texture;
- }
- if(Item2TextureChange == true)
- {
- BlockTexture = Item2Texture;
- }
- if(Item3TextureChange == true)
- {
- BlockTexture = Item3Texture;
- }
- if(Item4TextureChange == true)
- {
- BlockTexture = Item4Texture;
- }
- }
- function Build()
- {
- if(HitBlock()){
- var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
- cube.renderer.material.mainTexture = BlockTexture;
- cube.transform.position = hit.transform.position + hit.normal;
- }
- }
- function HitBlock() : boolean
- {
- return Physics.Raycast(transform.position, transform.forward, hit, range);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement