Unity3D How to copy object to paste at same position? - unity3d

I want to copy object and paste at same position by using Ctrl+c Barn1_Door_A at the center of map like this image.
when I paste by Ctrl+v the object is out of map like this image.
The component value of object is same value but why it paste out of map. How to fix it?

Highlight Barn1_Door_A and press Ctrl+d. It should duplicate the gameobject in the same location.
The only reason I can think of why your object isn't located in the same spot as the other one is the it is being made in a different place in the hierarchy (i.e not as a child of LockedBuildings)

Related

How to get cursor position of McCLIM

I'm trying to add Input Method supportto McCLIM so that it can input CJK in McCLIM, using input method client like fcitx.
To draw fcitx better, I want to get the cursor position of text editing area when it changed.
looks like this:
I found something called cursor-position/stream-cursor-position, but I don't know how to get the cursor/stream currently focus on. I have tried *standard-output*, but it failed.
How could I do this?
I know you're not using libx11, but I'd like just show you how libX11 do this.
Basically this is done by XIM_SET_IC_VALUES in the protocol. The values the spot location within a nested value of preedit attributes.
The spot is simply a X point (x, y). Despite of that, the point is a relative coordinates to the focus window. The focus window is also a part of ic vlaues, with property name XNFocusWindow.
If you don't set focus window, the client window that passed through XCreateIC will be used as the focus window.
XVaNestedList preedit_attr;
preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &nspot, NULL);
XSetICValues(ic, XNPreeditAttributes, preedit_attr, NULL);
XFree(preedit_attr);

Leaflet geoman setLatLngs not restoring object to the getLatLngs position

I have an issue that when leaflet geoman removes a vertex on for example polygon, I cannot restore the latLngs of the object.
What im doing:
On object click -> object.getLatLngs(). Works fine.
If I start editing the object and then object.setLatLngs(ObjectClickLatLngs) it works fine.
But the issue is: Click object -> start editing -> Right click vertex(to delete vertex) -> object.setLatLngs(ObjectclickLatLngs). Now the vertex is deleted and did not restore to the latLngs it had previously.
Try to click the polygon, change a vertex then click "restore object to initial position" (works as expected)
Then click the polygon, but right click a vertex(to delete) without moving it then click "restore object to initial position" (now the object is not in the state it should be, expected it to restore to same position as initial)
https://jsfiddle.net/6tzxg2ds/2/
The Problem is that JavaScript refrence the variable to the source, so when the latlng of the layer is changed, then the restoreLatLngs is also updated.
You can "destroy" the refrence with this:
restoreLatLngs = JSON.parse(JSON.stringify(x.target.getLatLngs()));

In LibreOffice Calc change the size of a shape by clicking it

I have several shapes in LO Calc and I need those shapes to change their sizes when they are mouse clicked: the first click enlarges the shape, the second click restores the original size.
I'm trying to do this with a macro assigned to those shapes. My problem and my question: how to determine within a macro which shape has been clicked?
I know how to get the current selected shape:
dim doc as object
doc = ThisComponent
someVar = doc.CurrentSelection...
But a shape when clicked is not getting selected and this method is not working.
I tried to add a parameter for the event object to the macro:
sub ChangeSize( oEvent )
But this produces a message about wrong number of parameters.
Is there a way to detect the caller of a macro in LO Basic? Or maybe another way to implement size changing with a mouse click?
P.S. One can use a separate button for calling the macro and click this button after selecting the needed shape, but this way is less convenient.
EDIT: As I guessed below in the comments, the described task can be solved via the mouse and shape coordinates. The key points for the solution I found here:
How to get Document-Coordinates from a Mouse Click in an OpenOffice BASIC Macro
Instead of detecting the caller, assign a different one-line macro for each shape clicked event.
Sub ShapeClickedA
ChangeSize("ShapeA")
End Sub
Sub ShapeClickedB
ChangeSize("ShapeB")
End Sub
Related: LibreOffice macro showing simple TextBox shape
P.S. After answering, I realized you asked the linked question as well. How is this different, and is the other answer not satisfactory?

Locating TreeObject in large Tree

I have a large tree and I can 'select' (i.e.highlight) any node of it. But if I have a large tree with all nodes expanded the user still needs to manually scroll down or up in order to locate the highlighted element. Is there a way which not only highlights the selected element but also locates it by automatically scrolling up/down in the tree?
TreePath path = createTreePath(editorID, treeObject);
getTreeViewer().setSelection(new TreeSelection(path), true);
getTreeViewer().refresh();
getTreeViewer().jumpToSelectedElement(true); // I need something like this. I made up the name of this imaginary method.
Use
public void reveal(Object elementOrTreePath)
As its name suggests elementOrTreePath can be a tree path or just an element.

SWT: Position a dialog based upon the position of the caret in a StyledText control

I have SWT application that is a set of Groups that contain various controls including a StlyedText widget. They are all laid out using the Form layout.
I want to show a dialog directly below the caret inside of the StyledText. However, I have to position the dialog relative to the parent shell.
My first idea is to get the position of the shell plus the position of the StyledText plus the offset of the caret. When I try to get the position of the StyledText, it says 0,0 (I assume because of my layout choice, the Form layout). I don't see a good way to get the position from the FormData either (it appears to be computed).
I am able to get the position of the mouse cursor, but I would like to have it be right under what the user is typing.
Anyone have any ideas?
In order to get the actual postion, the function toDisplay() should be used. For example:
Point displayPoint = myText.toDisplay(sqlText.getLocation());
That gets me to the position of the Text. I then added the caret position in order to move my dialog window to the line of text that is being written:
Point caretLocation = myText.getCaret().getLocation();
Point calcPoint = new Point(displayPoint.x+caretLocation.x, displayPoint.y+caretLocation.y);
I then used that location to position my dialog window.