Created
December 12, 2015 01:26
-
-
Save whaison/a7af1978fe326f860670 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class ShadowScript3 : MonoBehaviour { | |
public Camera shadowCamera; | |
public GameObject shadow; | |
Texture texRed; | |
Texture texGreen; | |
Texture texBlue; | |
Texture texYellow; | |
MeshRenderer rend; | |
Texture ShadowMainTexture; | |
Material RendMaterial; | |
// Use this for initialization | |
void Start () { | |
shadow = GameObject.Find ("Shadow"); | |
texRed=Resources.Load("Shadow_red") as Texture; | |
texGreen=Resources.Load("Shadow_green") as Texture; | |
texBlue=Resources.Load("Shadow_blue") as Texture; | |
texYellow=Resources.Load("Shadow_yellow") as Texture; | |
rend = shadow.GetComponent<MeshRenderer>(); | |
RendMaterial = rend.material; | |
RendMaterial.mainTexture = texRed;//////////////////////初期値設定 | |
ShadowMainTexture = rend.material.mainTexture; | |
} | |
// Update is called once per frame | |
void Update () { | |
if(Input.GetMouseButton(0)) { | |
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); | |
RaycastHit hit; | |
if(Physics.Raycast(ray, out hit, 10000.0f)) { | |
Debug.Log ("point:" + hit.point + " obj:" + hit.transform.gameObject); | |
shadow.transform.position = hit.point; | |
shadowCamera.clearFlags = CameraClearFlags.Nothing; | |
} | |
} | |
} | |
int swichInt = 0; | |
public void switchBrush(){ | |
switch (swichInt) { | |
case 0: | |
RendMaterial.mainTexture = texRed; | |
swichInt = 1; | |
break; | |
case 1: | |
RendMaterial.mainTexture = texGreen; | |
swichInt = 2; | |
break; | |
case 2: | |
RendMaterial.mainTexture = texBlue; | |
swichInt = 3; | |
break; | |
case 3: | |
RendMaterial.mainTexture = texYellow; | |
swichInt = 0; | |
break; | |
default: | |
RendMaterial.mainTexture = texYellow; | |
swichInt = 0; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment