- Home /
Remove script function for manipulating inspector values in IDE (not runtime)
Is there a way to have a script remove itself from an object?
This would be useful for IDE-only operations - for example, zeroing transform coords, instead of having to type it in each time. It's for one-time use before runtime. Usage: drag and drop script into object. script sets object transforms to origin. script removes itself.
Answer by Eric5h5 · Dec 19, 2010 at 04:03 AM
There's no reason to do that; just use an editor script (Usage: select object, select Zero Coords from GameObject menu):
@MenuItem ("GameObject/Zero Coords")
static function ZeroCoords () { Selection.activeObject.transform.position = Vector3.zero; }
this is very useful - so i'm trying to write a similar ide-menu-helper script, where the previously selected object is snapped into place of the newly selected object... but there does not appear to be a way to access previously selected objects - reading in forums, it looks like the instanceID can't be used to select objects... would you have any insight how to create this helper script?
Not sure, sorry...if something isn't currently selected I don't know how you'd deter$$anonymous$$e that it was selected before.
Your answer
![](https://koobas.hobune.stream/wayback/20220613091612im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Obj.meta files deleted during import of Assets 0 Answers
How to delete a Variable in a script in game 1 Answer
DestroyObject is not destroying everything. 1 Answer
Managing assetbundles (caching vs non-caching) 0 Answers
delete node in xml 2 Answers