- Home /
Prefab linking
How can i link prefab (that not in "resources" folder) to a scripts property via script (ExecuteInEditMode). (how can i emulate drag'n'drop prefab to a property in editor via script)
Answer by _dns_ · Sep 19, 2014 at 04:03 PM
Hi, in the Editor, I use AssetDatabase.LoadAssetAtPath() to set a reference to an Asset or prefab: http://docs.unity3d.com/ScriptReference/AssetDatabase.LoadAssetAtPath.html.
You might also need to use EditorUtility.SetDirty( yourGameObject-ContainingTheMonoBehavior-ContainingTheProperty ) to tell Unity that you changed the object and that it needs to be saved during next scene save.
Your answer
Follow this Question
Related Questions
Why unity executes scripts in prefabs which are not on scene? 1 Answer
Changes via script in prefab mode not applied to instances 0 Answers
How to break a prefab connection via c# 0 Answers
Link variables of a script in dynamically instantiated prefab before start is called 1 Answer
Adding a child via code in edit mode won't work for prefab instance 0 Answers