- Home /
How to enable copy/paste/delete for programatically selected objects?
I'm writing some editor scripts and I'm using Selection.activeGameObject to programmatically select objects in the editor. The problem is, whenever I select an object programmatically the Copy/Paste/Delete/Duplicate commands from the Edit menu are disabled.
Does anyone know how to programmatically select an object and enable the Edit menu commands?
Answer by vexe · May 13, 2014 at 10:52 PM
Yes, you can either select the object and execute a menu command:
 public static void PerformOperation(string operation)
 {
     EditorApplication.ExecuteMenuItem("Edit/" + operation);
 }
 
 Selection.activeObject = myObj;
 PerformOperation("Copy");
Or, you can select the object and send a key down event, see this answer (sends a F2 for rename)
Your answer
 
 
             Follow this Question
Related Questions
Copy Material 1 Answer
Overriding Component Copy/Paste 2 Answers
Copy/Paste Key Combos in Webplayer 1 Answer
How to record hideFlags for Undo/Redo 0 Answers
Parent losing references to Child fields after duplication, copy/paste 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                