Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

Materials causing editor and player crash

$
0
0
For some odd reason, I have stumbled upon some code that I need to be in my program but it will cause a crash in unity nearly all of the time. The simple lines of code are here: if (((cameras.transform.position - planetPos).magnitude < 1.025f*rad) && renderer.material != groundFromGround) { renderer.material = groundFromGround; renderer.material.SetTexture("_DetailTex", ((Texture2D) Resources.Load("Models/Bump"))); renderer.material.SetTexture("_DetailTex2", ((Texture2D) Resources.Load("Models/Gbumb"))); renderer.material.SetFloat("_MultTest", (4096)/(Mathf.Pow(2, timesSplit))); } if (((cameras.transform.position - planetPos).magnitude > 1.025f*rad) && renderer.material != groundfromspace) { renderer.material = groundfromspace; renderer.material.SetTexture("_DetailTex", ((Texture2D) Resources.Load("Models/Bump"))); renderer.material.SetTexture("_DetailTex2", ((Texture2D) Resources.Load("Models/Gbumb"))); renderer.material.SetFloat("_MultTest", (4096)/(Mathf.Pow(2, timesSplit))); } Is there something with this code that is causing an error within Unity or is there a simple fix to stop the crashes and slowdown? Note: cameras is just the main camera not multiple cameras.

Viewing all articles
Browse latest Browse all 2383


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>