Question by
glogloglik · Nov 27, 2015 at 04:30 PM ·
webglsendmessagecommunicationjquery
WebGL communicates poorly with Unity
Hello guys,
I'm creating a model of Solar System and I have one scene with one planet and some moons on the screen. Underneath it I have a list of objects in the scene, which work as a links. When I click on one object, an arrow should appear and follow the planet. However, right now it just appears in the middle of the screen and stops frozen in scene. I tried to locate the problem for hours but no such luck. Doesn't anyone has any idea what could be wrong, please?
I'm also using my own WebGL template but that shouldn't be a problem I hope..
jQuery function calling Unity function FocusOnObject
$("a.linkToObject").click( function(){
var ElementName = $(this).attr("class");
SendMessage("_Manager", "FocusOnObject", "ElementName");
});
Script which is implemented in every scene
public class WebManagerController : MonoBehaviour {
public GameObject arrow;
private Vector3 offset = new Vector3(0, 40, 0);
private bool arrowActivated = false;
private GameObject focusedObjekt = null;
private string name = null;
public void Start(){
arrow.SetActive(false);
}
public void Update(){
if (arrowActivated == true){
SipkaController();
}
}
public void FocusOnObject(string nameObjektu){
arrowActivated = true;
arrow.SetActive(true);
focusedObjekt = GameObject.Find(nameObjektu);
}
public void ArrowController(){
arrow.transform.position = focusedObjekt.transform.position + offset;
}
}
Comment