Created
January 12, 2015 07:37
-
-
Save kazuooooo/2bd0bbeb960674b30eb5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 myscript : MonoBehaviour { | |
| // int counter =0; | |
| // GameObject obj = null; | |
| // Use this for initialization | |
| void Start () { | |
| GameObject[] objs = GameObject.FindGameObjectsWithTag ("Player"); | |
| foreach (GameObject obj in objs) { | |
| //colorオブジェクトを取得 | |
| Color c = obj.renderer.material.color; | |
| //透明度を1に設定 | |
| c.a = 1f; | |
| obj.renderer.material.color = c; | |
| //ShaderにTransparent/Diffuseを設定 | |
| obj.renderer.material.shader = Shader.Find ("Transparent/Diffuse"); | |
| } | |
| } | |
| // Update is called once per frame | |
| void Update () { | |
| GameObject cube = GameObject.Find ("Cube"); | |
| try{ | |
| cube.transform.Rotate(1f,-1f,-1f); | |
| }catch(System.Exception e){} | |
| Move (KeyCode.LeftArrow, -1f, 0, 1f); | |
| Move (KeyCode.RightArrow, 1f, 0, -1f); | |
| Move (KeyCode.UpArrow, 1f, 0, 1f); | |
| Move (KeyCode.DownArrow, -1f, 0, -1f); | |
| } | |
| void Move(KeyCode key,float x,float y,float z){ | |
| if (Input.GetKey (key)) { | |
| rigidbody.AddForce (new Vector3 (x, y, z)); | |
| } | |
| } | |
| void OnCollisionEnter(Collision collision){ | |
| if (collision.gameObject.tag == "Player") { | |
| Color c = collision.gameObject.renderer.material.color; | |
| //半透明にする | |
| c.a = 0.25f; | |
| collision.gameObject.renderer.material.color = c; | |
| } | |
| } | |
| void OnCollisionStay(Collision collision){ | |
| } | |
| void OnCollisionExit(Collision collision){ | |
| if (collision.gameObject.tag == "Player") { | |
| Color c = collision.gameObject.renderer.material.color; | |
| c.a = 1f; | |
| collision.gameObject.renderer.material.color = c; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment