protected override IToolbar CreateDecorator(Type decoratorType, UnityObject[] targets) { var strip = decoratorType.Instantiate(false, ArrayTypeUtility.RetypeArray(targets)).CastTo <IToolbar>(); strip.Initialize(); return(strip); }
public static IEditorTool GetEditorTool(params UnityObject[] targets) { if (!ArrayTypeUtility.TryGetCommonType(targets, out var commonType)) { return(null); } return(instance.GetDecorator(targets)); }
public static IEditorTool GetEditorTool(IEnumerable <UnityObject> targets) { if (!ArrayTypeUtility.TryGetCommonType(targets, out var commonType)) { return(null); } // Array gets copied on creation anyway so it's safe to pool var targetsArray = targets.ToArrayPooled(); var editorTool = instance.GetDecorator(targetsArray); targetsArray.Free(); return(editorTool); }
public static EditorPopup Open(UnityObject[] targets, Rect activator) { Ensure.That(nameof(targets)).IsNotNull(targets); Ensure.That(nameof(targets)).HasNoNullItem(targets); if (!ArrayTypeUtility.TryGetCommonType(targets, out var commonType)) { throw new InvalidOperationException("Cannot create editor for objects of mismatching types."); } var popup = CreateInstance <EditorPopup>(); popup.isPopup = true; try { popup.Initialize(targets); } catch (Exception ex) { Debug.LogException(ex); popup.Close(); return(null); } popup.activatorPosition = activator; popup.position = Rect.zero; popup.isPopup = true; popup.ShowAsDropDown(popup.activatorPosition, new Vector2(PeekPlugin.Configuration.editorPopupWidth, 1)); popup.minSize = new Vector2(200, 16); popup.maxSize = new Vector2(4000, 4000); popup.Focus(); return(popup); }
protected override Type GetDecoratedType(UnityObject[] targets) { return(ArrayTypeUtility.GetCommonType(targets)); }
protected override IEditorTool CreateDecorator(Type decoratorType, UnityObject[] targets) { var editorTool = decoratorType.Instantiate(false, ArrayTypeUtility.RetypeArray(targets)).CastTo <IEditorTool>(); return(editorTool); }