Line renderer is not working for android build game

陌路散爱 提交于 2021-01-29 04:50:37

问题


In my game when i run the game in unity editor in unity remote the linerneder shows like below **enter image description here**

But when I build it and run it in android device the linerender disappers like below enter image description here

code for line renderer is below:

var targetObject : GameObject;
private var lineRenderer : LineRenderer;

function Start() {
    lineRenderer = GetComponent(LineRenderer);
  }

 function Update () {
    lineRenderer.SetPosition(0,this.transform.localPosition);
    lineRenderer.SetPosition(1,targetObject.transform.localPosition);
}

I have no idea what is the problem .Please help me with it


回答1:


If you're using

LineRenderer.material = new Material (Shader.Find("#SHADERNAME"));

you will receive an error and the LineRenderer will not work correctly.

I solve the problem creating a material, assign a proper shader (I use shader -> Particles -> Additive), and, in the script, LineRenderer.material = Resources.Load ("#PATH TO YOUR MATERIAL") as Material.

You can see other options here:

http://answers.unity3d.com/questions/1079400/linerenderer-doesnt-work-in-build.html



来源:https://stackoverflow.com/questions/28177705/line-renderer-is-not-working-for-android-build-game

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!