ok is this normal if unity 3D is longer time active (not play) when I click Play my graphic get’s weird 1. frame stays always at first position and every 2. frame is the correct updated frame
at first I thought I have some leak at all new operators in every frame (creating 1000 new and not deleting them in end) because the bigger that my code got more often I’m getting this
but whenever I restart unity every frame is correctly updated
and today I’ve just opened unity and was so tired of everything from happening and went to bed and when I came back to try few stuff when I clicked play first time on run I got that weirdness again
ok I’ve just made an crash test and it does crash as usually I get it but usually it takes a day before unity crashes
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class UnityCrashTest : MonoBehaviour {
public Rect crash ;
void OnGUI(){
for (int i = 0; i < 1000; i++) {
GUI.Button(new Rect (i+80,i+80,50,50),"asdf","Box");
}
}
}
in a minute or 2 the graphics starts jumping but not as often if I have unity longer time running
as around every 2 sec I get jump to original position
but I was watching CPU and Memory and saw that memory was slooowly going up but at 10% memory usage unity couldn’t handle any longer and crashed
interesting thing is tho memory didn’t go back down (and if I start unity it’s like at beginning)
but if I restart PC memory goes back down
unity with this script crashes in around 30 min
sadly I cannot look in to GPU and Graphical memory
so how do I get rid of all new operators or how do I kill/destroy/delete all this new operators? after every frame so I won’t have leak
and after doing this if I restart unity around 5 times (with crash) I don’t even need to click play any longer and it just crashes in few min I can still click on windows and stuff… but not inside unity like - project play button scripts … …
and if I do it this way:
public Rect crash = new Rect (0,0,80,80);
void OnGUI(){
for (int i = 0; i < 10000; i++) {
GUI.Button(crash, "asdf","Box");
}
}
I have a bit laggy because it’s 10k times but the graphic isn’t doing that any longer
and I’ve figured out I kinda can’t update Rect every frame to different values without making new rect
and every new rect helps doing that
#EDIT:
figured out that time.deltatime does the trick tho don’t know why
if I change my camera from:
using UnityEngine;
using System.Collections;
public class CameraControll : MonoBehaviour {
public float YSensitivity = 100 ;
private float MouseRotationY ;
void Update() {
MouseRotationY += (Input.GetAxis("Mouse Y"));
transform.localEulerAngles = new Vector3 (MouseRotationY * YSensitivity * Time.deltaTime , 0 , 0);
}
}
to:
using UnityEngine;
using System.Collections;
public class CameraControll : MonoBehaviour {
public float YSensitivity = 100 ;
private float MouseRotationY ;
void Update() {
MouseRotationY += (Input.GetAxis("Mouse Y"));
transform.localEulerAngles = new Vector3 (MouseRotationY * YSensitivity , 0 , 0);
}
}
than camera isn’t jumpy any longer every 2. frame
tho this isn’t working for transform.position as that never jumps don’t know why the difference but that happenes for rotation
and why does that happen?