i starting project , got error can't figure out what's wrong it. appreaciate , sorry if it's stupid question. still new @ unity. answers.
i tried searching vector2(width,height) me looks fine. , if can please explain rect.center problem why did got it?
unity3d error:
assets/scenes/game/scripts/gui/gamegui.cs(22,22): error cs1061: type `unityengine.rect' not contain definition `center' , no extension method `center' of type `unityengine.rect' found (are missing using directive or assembly reference?)
code:
using unityengine; using system.collections; public class gamegui : monobehaviour { void onresume() { enabled = true; } void onpause() { enabled = false; } void ongui() { int fps = (int) (1f/time.deltatime*time.timescale); guilayout.box( "fps "+fps ); vector2 size = gui.skin.label.calcsize( new guicontent("+") ); rect rect = new rect(0, 0, size.x, size.y); rect.center = new vector2(screen.width, screen.height)/2f; gui.label( rect, "+" ); } }
thank time.
the center
property introduced in unity 3.5 according unity's script reference history page.. have calculate center on own. maybe constructor should this:
rect rect = new rect(screen.width/2f, screen.height/2f, size.x, size.y);
Comments
Post a Comment