I confused , this is my c sharp script that create and log the float:
using UnityEngine;
using System.Collections;
public class guicontrol : MonoBehaviour {
void CalculatePosition(string ObjectName) {
GameObject theobject = GameObject.Find (ObjectName);
int selectedwidth = 1366;
int selectedheight = 768;
int screenwidth = Screen.width;
int screenheight = Screen.height;
float coordinatey = theobject.transform.localPosition.y;
float coordinatex = theobject.transform.localPosition.x;
float coordinatez = theobject.transform.localPosition.z;
Debug.Log ("work at current stats : " + screenwidth + " " + screenheight);
if (screenwidth != selectedwidth || screenheight != selectedheight) {
float coordinateytomove = (screenheight / selectedheight) * coordinatey;
float coordinatextomove = (screenwidth / selectedwidth) * coordinatex;
Debug.Log (coordinateytomove + " " + coordinatextomove);
}
}
}
When I calculate it manually in calculator , the result of coordinatextomove
was :
-2.99853587116
but in the debug log was :
-3 0
-3
was the coordinateytomove
which don't change from its current coordinate , but why if the coordinatextomove
changed , its debug logged 0
instead of -2.99853587116
? If there's previous post answered this question , forgive me and give me the link of the post :) .