Yea I know. It’s been a while. I do have two very good excuses though: 2.6 and Unite ‘09. If you enjoyed those then zip it and read on. If not, I’m really out of ammo and sorry for the delay.
At Unite, I attended the talk by John Grden of infrared5 on the special (free) Unity for flash users day. During this session he complained about wanting to be able to copy his runtime transform changes inside the IDE (he was copying by way of paper notes it seemed). I decided to take up the challenge when he continued with “… but someone is probably going to show me how to do that after this” and after his talk I handed him a custom inspector editor script for solving that specific problem.
Later at the conference I had some time to kill and did a rewrite to expand the script to be general for any component type. I didn’t have the time to hand John that version, but I suppose I’ll just email him a link to this post.
So anyway – lets talk implementation:
- Add CopyInspector.cs to Assets/Editor.
- Add CopyTransformInspector.cs to Assets/Editor.
- For each other component to be made copy/paste-able:
- Add CopyYourComponentTypeInspector.cs to Assets/Editor.
- Rename it appropriately.
- Rename the class to match the file name.
- Change YourComponentType in “[CustomEditor (typeof (YourComponentType))]” to the type of component you wish to affect.
You’ll notice that CopyTransformInspector has some additional code to it. This is due to the fact that this inspector is rendered non-standard and the code provided just replicates that.
Not really sure why syntax highlighting is not kicking in… Will have a look at that later.
Codes!
CopyInspector.cs
CopyTransformInspector.cs
CopyYourComponentTypeInspector.cs