Hi all, really simple task here. What else do I need to get my 3D text to behave as a button..? I have this code on the text, its highlighting fine, do I need some kind of collision on the text itself? Code (csharp): var highlightColor = Color.yellow; function OnMouseDown () { renderer.material.color = highlightColor; Application.LoadLevel ("MainApp"); } function OnMouseUp () { renderer.material.color = Color(0,0,0); } function Start () { var www = WWW ("http://server.co.uk/someasset_01.unity3d"); yield www; // Get the designated main asset and instantiate it. Instantiate(www.assetBundle.mainAsset); } thanks -hosse
just add a collider and use raycast something like this: Code (csharp): private var hit : RaycastHit; private var ray : Ray; private var HitGameObject : GameObject; static var PlayerCamera : GameObject; public var rayDistance : float = 100; function Awake() { PlayerCamera = GameObject.Find("Main Camera"); } function Update () { ray = PlayerCamera.camera.ScreenPointToRay (Input.mousePosition); if(Input.GetMouseButtonDown(0)) { if (Physics.Raycast (ray, hit, rayDistance)) { HitGameObject = hit.collider.gameObject; } }}
hi there, Thanks for the reply.! I can't figure out where to put my code in this raycast script to get my level to load.... can you help.. i just get errors.! I have a collider on the 3d text.. just not sure where this code needs to be entered,. Code (csharp): Application.LoadLevel ("MainApp");
Thanks Eric, Raycasting wasn't needed.! Thanks to synapsemassage, I got your code working too. My new problem is getting my assetbundle to load OnMouseDown... this is what I have so far. I also don't fully understand the instantiate part either.. Code (csharp): var highlightColor = Color.yellow; function OnMouseDown () { renderer.material.color = highlightColor; } function Start () { var www = WWW ("http://hosse.co.uk/someasset_01.unity3d"); yield www; var progress : float // Get the assetbundle and instantiate it. Instantiate(www.assetBundle.mainAsset); }