- Home /
How can I create a GameObject at the corner of screen
Unity is so difficult compared to delphi. In delphi you can just say:
Rectangle1.Position.Y := 0;
Rectangle1.Position.X := screen.Width - Rectangle1.Width;
This will just change the position of the Rectangle to the top right corner of the screen. But in Unity there's so much to lean just to do this and I don't know where I start. Can someone please simplify this to me? I just want create a object at the top right corner of the screen, both in smartphones and pcs.
I'm using Unity2D
EDIT: This is the Inspector of the object that I want to create: http://i.imgur.com/TZ3gqWR.png
And this is the code that I use to create the object:
Instantiate(objectName, new Vector3(0, 0, 0), Quaternion.identity);
EDIT to be more clear:
DISCLAI$$anonymous$$ER: I'm assu$$anonymous$$g you are referring to an object in GUI and not in world. Does this object need to be created during Runtime? You could always place a blank object at the location if so, otherwise just get the vector coordinates and tell your new object to position there via the RectTransform.position, of course it WILL need parented to a canvas to be visible.
I played long time ago, was top Diamond Terran :)
Great, my game name is "$$anonymous$$arabunta" if you play again some day.
Still not sure if you mean its a UI item or not, IF it is a UI item, it will never appear on screen unless childed to a visible canvas. Afterwards you can position it as much as you want.
I created a prefab using a png image, that's all.
Answer by terranblake_business · Jan 01, 2017 at 08:39 PM
In your best interest @DiegoBittencourt, especially if you are switching to Unity for the first time, you should look into Unity's free tutorials. They cover a lot of the information that you need to learn the basics of Unity, as well as giving you the ability to teach yourself the rest of the game engine.
With regards to your specific question, "https://unity3d.com/learn/tutorials/projects/2d-roguelike-tutorial/adding-ui-level-transitions" should be a very good place to start. Unity does a very good job at giving "the little guys," all the information they may need, to build all kinds of games, for lots of platforms.
Hopefully this helps you out a little bit.
Answer by Grench1 · Jan 01, 2017 at 09:02 PM
There are some ways to do this in HTML, In the Android case you can get a look of AndroidStudio. But for unity there is a class named "Screen" wich is great when handling screen information. Here is the Unity ref: https://docs.unity3d.com/ScriptReference/Screen.html