- Home /
How can I prevent the children of a prefab from being edited/selected
How do I prevent the children of a prefab from being either selected and/or can I prevent the transform of a child from being modified?
Example I have a animated game object and a physics trigger under a parent game object.
Parent(Prefab)
|-> Animated Mesh
|-> Trigger
In the editor, the animated mesh can be selected and moved independent of the prefab. I would either like to move the selection from the child to the parent or prevent the childrens' transforms from changing.
T
Answer by vbbartlett · Jan 10, 2013 at 05:27 PM
Hope this helps someone else I created an editor class
[InitializeOnLoad]
public class CPrefabSelector {
//static so that it is around all the time
static CPrefabSelector()
{
//add an OnSceneGUIO delegate to run all the time in the scene
SceneView.onSceneGUIDelegate += OnScene;
}
private static void OnScene(SceneView sceneview)
{
//Change the selection to what it should be.
}
Hey could you elaborate a bit more on this solution? I have tried to get this to work to no avail. What you need to react on is EventType.$$anonymous$$ouseUp however that seems to get eaten up by some other built in controls. If you try to override the built in controls then the original selection doesn't happen at all :/