Is it possible to get position in 2D scene WITHOUT script? - unity3d

I have placed a png background to my game, and i would like to know the position of certain element in the background (the top on the tree, i have pointed with red arrow)
I would like to know the 2D position of this tree top. I want to click with mouse on the tree top and get the position.
I don't want to use script.
I need to know a lot of locations in the background and i want to get them while the game is not played, but rather when i am in editor mode in the scene view, as shown in the picture.
Is this possible?

Pretty simple. Click the + in the top left of the Hierarchy, and add an Empty GameObject. Make sure it's Z position is the same as your background, and move it using the handles in the scene to the top of the tree. Once there, look at the position on the right, and that is the position of that point.

Related

Player keeps gettings stuck on game object in 2D tile based scene

I am creating a 2D grid based game in Unity. I am using Tile maps for background (one grid and two tile maps).
On the first tile map I have the background (like grass) and on the second one I have things I add, like a hole in the ground. Now I add game objects to the scene (a sprite tree). I have two BoxCollider2D on the tree, first one is just a small one at the bottom of the tree and the other one covers the whole tree but is set as trigger (I have a script that automatically fades out the tree when user is behind it).
The problem is that the user keeps getting stuck at the collider (I think) at the bottom of the tree. It works from some angles. I tried creating a small 2D square too and sometimes I get stuck to that too. What am I missing?
I have added a custom material that has friction set to 0 on both the Player and the tree.
I don't know if it is relevant but the tree is quite big so I had to set its size to 0.5 instead of 1.
remove the interaction between the player and the tree, see in project setting, modify the script to work with a raycast
or just make the tree collider a Trigger..

How to bring forward an object in unity?

I've a simple project with a few objects.
I tried to move "player" object (Marked in the picture) to top of other objects but still it is in backward!
How to bring it to forward?
We need some more information to give an accurate answer for your exact situation, such as the properties of the Sprite Renderer (assuming Player is a sprite) and the properties of your Canvas and UI elements (especially if it is a world space canvas), and any code you might be using to instantiate, render, or move the player.
In general though, for sprites, you can bring a sprite in front of other sprites by either changing the Z value of the transform (negative Z is closer to the camera), or better by changing the Order in Layer of the player sprite renderer, and make sure it is in a layer that is in front of the other sprites.
As for Canvas UI elements, the element at the bottom of the hierarchy will be rendered last, meaning it will show in front of everything. Think of a UI hierarchy like stacking papers on top of each other. The first piece of paper placed down will be at the bottom of the pile.

Loaded SKTileMap from scene disappear

I'm trying to make a game and I need to render a tileMap that the player can move but also modify its size.
First I created it programmatically, filled it randomly and it worked perfectly fine. As a result I designed a custom tileMap in the scene editor and I used it in code so that the player is able to move it or change its size and there I have a problem.
The tileMap is a 48x48 tileMap but if the intersection between the 24 and 25 column touch the left side of the screen, the whole tileMap (even the part on screen) disappear and if I bring it back on the screen (by selecting the invisible position where it was) and drag it back on the right it reappears.
The only solution that I found is to design the whole tileMap programmatically but this will take quite a long amount of time. Has anyone found how to tackle this issue ?
(changing shouldCullNonVisibleNodes and transparency has no effect)

How can I create a Plane in Unity, that always shows up when using the AR-Camera in an App

I have an AR app, where I want to have a plane with text on it, that is always shown when using the AR-Camera.
The Programm only uses the AR-Camera. The Plane doesn´t show up at all so far, even though it does in the preview.
The Plane doesn´t show up anywhere in the AR environment.
I don´t really know what to add since I think the question is simple. If you need further details just let me know.
Little Update: After the start of the app and after the Unity Logo shows up, the screen is black for a few seconds and during that time I can see my Panel on the black background. As soon as the AR-Camera is activated, the Panel is gone.
Here is how to do it in 3 simple steps:
You need to add a Plane object to your Unity's scene
You have to align the Plane in the view of your main Camera's object, to your liking
You have to set the Plane as a child of your Camera's object by simply dragging your Plane entry to Camera entry in the Scene Tree Editor Pane (located in most cases on the left side of your Editor's window)

Unity - MRTK - HoloLens: Modify Collider of 2D-Buttons so the Cursor gets closer

My current problem is that the cursor appears too far away from a button. You can see in the screenshot what I mean. Hovering over a button from the list lookes like this:
Question: What can I do so the cursor get closer to the button, because on the HoloLens you see the distance?
Looking somewhere else on the canvas except the buttons, the cursor gets closer:
--Edit--
I should mention that the scene has a scaled cube (the gray thing in the screenshot) and in front of that a world canvas (white thing), which contains the scrollview/list.
I saw the same behaviour for UI elements.
I can only provide you a workaround. It is a bit hacky but it works:
Go through all UI elements especially Text and Image and disable the option RayCast Target.
This makes the Cursor be sitting right on top of them ... but you will notice your Buttons are now non-responsive and you can not interact with them anymore.
This happens because the Physics system requires either a RayCastTarget or a Collider in order to fire it's pointer events like e.g. PointerEnter, PointerDown etc.
Therefore now add a BoxCollider (not BoxCollider2D!) to your Buttons and scale it to the correct size. It looks like you are using a VerticalLayoutGroup so you can simply correct the positioning of the BoxCollider by setting the RectTransform to centered once (the VerticalLayoutgroup will anyway re-enforce the Top-Left anchoring). In my case the BoxCollider needs with 0.8 and height 0.1 ... and for the z I choose 0.01 but it can be smaller if you whish
Hurray, now the buttons are interactable again and the Cursor only has it's usual distance + the half of the choosen z thikness of the BoxColliders.
Since the Background cube has it's own BoxCollider anyway we don't need to add further Colliders for the ScrollView and UI panels.
You might have to add some though for the ScrollBars as well if you need them!
As said this is more like a quick workaround and might not be a final solution since whenever a size of the Button or the ScrollRect is changed you have to rework those hardcoded BoxCollider dimesnions as well ...
I had similar issue on 3D objects. This could happen because the objects collider definition. I mean, you can import a render mesh but the mesh collider could be different (bigger, smaller, ...)
I hope this solves your problem ;)