Пример #1
0
        public void Initialize(SerializedProperty property)
        {
            targetProperty = property;
            targetObjects  = null;
            pasteType      = PasteType.Normal;

            Object context = property.serializedObject.targetObject;
            List <SerializedClipboard> clipboardRaw = PasteBinWindow.GetSerializedClipboards();

            for (int i = 0; i < clipboardRaw.Count; i++)
            {
                object value = clipboardRaw[i].RootValue.GetClipboardObject(context);
                if (targetProperty.CanPasteValue(value, false))
                {
                    clipboard.Add(clipboardRaw[i]);
                    clipboardValues.Add(value);

                    if (!shouldShowSmartPasteButton)
                    {
                        switch (clipboardRaw[i].RootType)
                        {
                        case SerializedClipboard.IPObjectType.Array:
                        case SerializedClipboard.IPObjectType.AssetReference:
                        case SerializedClipboard.IPObjectType.GenericObject:
                        case SerializedClipboard.IPObjectType.ManagedReference:
                        case SerializedClipboard.IPObjectType.SceneObjectReference:
                            shouldShowSmartPasteButton = true;
                            break;
                        }
                    }
                }
            }
        }
Пример #2
0
        public void Initialize(Object[] objects, PasteType pasteType)
        {
            targetProperty = null;
            targetObjects  = objects;
            this.pasteType = pasteType;

            List <SerializedClipboard> clipboardRaw = PasteBinWindow.GetSerializedClipboards();

            for (int i = 0; i < clipboardRaw.Count; i++)
            {
                switch (pasteType)
                {
                case PasteType.Normal:
                    if (!clipboardRaw[i].CanPasteToObject(objects[0]))
                    {
                        continue;
                    }

                    shouldShowSmartPasteButton = true; break;

                case PasteType.ComponentAsNew:
                    if (!clipboardRaw[i].CanPasteAsNewComponent((Component)objects[0]))
                    {
                        continue;
                    }

                    shouldShowSmartPasteButton = true; break;

                case PasteType.CompleteGameObject: if (!clipboardRaw[i].CanPasteCompleteGameObject((GameObject)objects[0]))
                    {
                        continue;
                    }
                    break;

                case PasteType.AssetFiles: if (!clipboardRaw[i].CanPasteAssetFiles(objects))
                    {
                        continue;
                    }
                    break;
                }

                clipboard.Add(clipboardRaw[i]);
                clipboardValues.Add(clipboardRaw[i].RootValue.GetClipboardObject(null));
            }
        }