- Home /
Can I put Transform (gameObject) into GUILayout in javascript?
see I am working on one project that I want to put drag and drop gameObject on GUILayout in javascript If it is possible then how please help me. ,
Let me help explain the question as it seems both answers so far did not get what's being asked in the first place. He is asking ( which is exactly what I am trying to do too ) is : When we make a custom editor window - using GUILayout obviously, Can we make a slot for transform(gameObject) that shows in the editor window just as it would in normal script as public variable ?
Answer by robertbu · May 26, 2013 at 06:34 AM
GUI objects live in GUI coordinates. GameObjects live in world coordinates. So you cannot use real game objects in a GUILayout. With standard GUI calls, you specify the position, so it is possible to get real world objects to track GUI objects, but using GUILayout, you turn over positioning to the class and therefore don't have the coordinates.
Answer by numberkruncher · May 26, 2013 at 02:29 PM
I am not sure exactly what you are aiming for, but @robertbu is correct, you cannot simply place game objects into a GUILayout.
However... if you are using Unity Pro then what you can do is render the meshes associated with a game object or prefab onto a GUI using the `Graphics` class. You can reserve some space in your GUI layout using `GUILayoutUtility.GetRect` and then convert from local space of your game object into GUI space. Of course this is probably not for the faint hearted since it will involve some matrix math.
Alternatively, an easier solution, if you are using a GUI solution like NGUI, you could probably just place your foreground game objects onto the "UI" layer. I have not tried this, but I cannot see why this would not work.