Hey,
for some reason, a few lines of code in my custom minimap script works in editor but doesnt work in a build (both web and standalone)
Im using this script (didnt write it myself) for the player texture dot on the minimap. I dont use the standard GuiTexture because you can't rotate it.
using UnityEngine;
[ExecuteInEditMode()]
public class RotatableGuiItem : MonoBehaviour {
public Texture2D texture = null;
public float angle = 0;
public Vector2 size = new Vector2(128, 128);
Vector2 pos = new Vector2(0, 0);
Rect rect;
Vector2 pivot;
void Start() {
UpdateSettings();
}
void UpdateSettings() {
pos = new Vector2(transform.localPosition.x, transform.localPosition.y);
rect = new Rect(pos.x - size.x * 0.5f, pos.y - size.y * 0.5f, size.x, size.y);
pivot = new Vector2(rect.xMin + rect.width * 0.5f, rect.yMin + rect.height * 0.5f);
}
void OnGUI() {
if (Application.isEditor) { UpdateSettings(); }
Matrix4x4 matrixBackup = GUI.matrix;
GUIUtility.RotateAroundPivot(angle, pivot);
GUI.DrawTexture(rect, texture);
GUI.matrix = matrixBackup;
}
}
Then i use this script to move and rotate the dot
var target : GameObject;
var x_scale : float;
var y_scale : float;
var x_offset : float;
var y_offset : float;
function Update () {
transform.position.x = x_offset + GameObject.Find("First Person Controller").transform.position.x * x_scale;
transform.position.y = y_offset + GameObject.Find("First Person Controller").transform.position.z * y_scale;
GetComponent("RotatableGuiItem").angle = target.transform.eulerAngles.y;
}
The texture on my minimap rotates fine in the Build but doesnt move (it does move properly when i test in the editor). So the script works (because it rotates), but somehow it doesnt pick up the transform.position lines of code.
Any suggestions? Is it perhaps the combination of c sharp and java script which doesnt work in a final build?
I didnt see any weird things in the build log (for as much as i can judge as a Unity/programmer newbie)