public ComponentEditor(EditorTypeAssociation typeAssociation, ActiveEditorTracker tracker, Editor inspector) { if (typeAssociation.editor == null) { throw new ArgumentNullException("typeAssociation"); } if (!typeof(IEditor).IsAssignableFrom(typeAssociation.editor) || !typeof(UnityObject).IsAssignableFrom(typeAssociation.editor)) { throw new ArgumentException("Tool type must implement UnityEngine.ScriptableObject, IEditor.", "typeAssociation"); } this.tracker = tracker; m_Inspector = inspector; m_LockedInspector = tracker.isLocked; m_EditorTypeAssociation = typeAssociation; m_EditorToolScope = EditorToolScope.NotInitialized; }
public UnityObject InstantiateEditor() { var toolType = editorType; m_Editor = ScriptableObject.CreateInstance(toolType, x => { ((IEditor)x).SetTargets(targets); ((IEditor)x).SetTarget(target); }); m_Editor.hideFlags = HideFlags.DontSave; if (m_Editor is EditorToolContext) { m_EditorToolScope = EditorToolScope.ToolContext; } else if (m_Editor is EditorTool tool && EditorToolUtility.GetEnumWithEditorTool(tool, EditorToolManager.activeToolContext) != Tool.Custom) { m_EditorToolScope = EditorToolScope.ManipulationToolOverride; }