protected virtual void OnItemEndEdit(object sender, VirtualizingTreeViewItemDataBindingArgs e)
        {
            ExposeToEditor dataItem = (ExposeToEditor)e.Item;

            if (dataItem != null)
            {
                TMP_InputField inputField = e.EditorPresenter.GetComponentInChildren <TMP_InputField>(true);
                if (!string.IsNullOrEmpty(inputField.text))
                {
                    dataItem.SetName(inputField.text);
                    TextMeshProUGUI text = e.ItemPresenter.GetComponentInChildren <TextMeshProUGUI>(true);
                    text.text = dataItem.name;
                }
                else
                {
                    inputField.text = dataItem.name;
                }
            }

            //Following code is required to unfocus inputfield if focused and release InputManager
            if (EventSystem.current != null && !EventSystem.current.alreadySelecting)
            {
                EventSystem.current.SetSelectedGameObject(null);
            }
        }
        public override void Drop(object[] dragObjects, PointerEventData pointerEventData)
        {
            base.Drop(dragObjects, pointerEventData);

            m_isSpawningPrefab = true;
            if (CanDrop(dragObjects))
            {
                for (int i = 0; i < dragObjects.Length; ++i)
                {
                    object    dragObject = dragObjects[i];
                    AssetItem assetItem  = dragObject as AssetItem;

                    if (assetItem != null)
                    {
                        m_project.Load(assetItem, (error, obj) =>
                        {
                            if (obj is GameObject)
                            {
                                GameObject prefab     = (GameObject)obj;
                                bool wasPrefabEnabled = prefab.activeSelf;
                                prefab.SetActive(false);

                                GameObject prefabInstance = Instantiate(prefab, Vector3.zero, Quaternion.identity, ((GameObject)m_treeView.DropTarget).transform);

                                prefab.SetActive(wasPrefabEnabled);

                                ExposeToEditor exposeToEditor = prefabInstance.GetComponent <ExposeToEditor>();
                                if (exposeToEditor == null)
                                {
                                    exposeToEditor = prefabInstance.AddComponent <ExposeToEditor>();
                                }

                                exposeToEditor.SetName(obj.name);
                                exposeToEditor.Parent = ((GameObject)m_treeView.DropTarget).GetComponent <ExposeToEditor>();
                                prefabInstance.SetActive(true);

                                RuntimeUndo.BeginRecord();
                                RuntimeUndo.RecordSelection();
                                RuntimeUndo.BeginRegisterCreateObject(prefabInstance);
                                RuntimeUndo.EndRecord();

                                bool isEnabled      = RuntimeUndo.Enabled;
                                RuntimeUndo.Enabled = false;
                                RuntimeSelection.activeGameObject = prefabInstance;
                                RuntimeUndo.Enabled = isEnabled;

                                RuntimeUndo.BeginRecord();
                                RuntimeUndo.RegisterCreatedObject(prefabInstance);
                                RuntimeUndo.RecordSelection();
                                RuntimeUndo.EndRecord();

                                m_isSpawningPrefab = false;
                            }
                        });
                    }
                }
                m_treeView.ExternalItemDrop();
            }
        }
        protected override void UpdateOverride()
        {
            base.UpdateOverride();
            if (!RuntimeEditorApplication.IsPointerOverWindow(this))
            {
                return;
            }

            if (InputController.GetKeyDown(SelectAllKey))
            {
                if (InputController.GetKey(ModifierKey))
                {
                    if (RuntimeEditorApplication.IsActiveWindow(this))
                    {
                        m_treeView.SelectedItems = m_treeView.Items;
                    }
                }
            }

            if (RuntimeTools.SpawnPrefab == null)
            {
                return;
            }

            m_treeView.ExternalItemDrag(Input.mousePosition);

            if (Input.GetMouseButtonUp(0))
            {
                m_isSpawningPrefab = true;
                GameObject prefabInstance = RuntimeTools.SpawnPrefab.InstantiatePrefab(Vector3.zero, Quaternion.identity);
                prefabInstance.SetActive(true);

                ExposeToEditor exposeToEditor = prefabInstance.GetComponent <ExposeToEditor>();
                if (exposeToEditor == null)
                {
                    exposeToEditor = prefabInstance.AddComponent <ExposeToEditor>();
                }

                exposeToEditor.SetName(RuntimeTools.SpawnPrefab.name);
                RuntimeUndo.BeginRecord();
                RuntimeUndo.RecordSelection();
                RuntimeUndo.BeginRegisterCreateObject(prefabInstance);
                RuntimeUndo.EndRecord();

                bool isEnabled = RuntimeUndo.Enabled;
                RuntimeUndo.Enabled = false;
                RuntimeSelection.activeGameObject = prefabInstance;
                RuntimeUndo.Enabled = isEnabled;

                RuntimeUndo.BeginRecord();
                RuntimeUndo.RegisterCreatedObject(prefabInstance);
                RuntimeUndo.RecordSelection();
                RuntimeUndo.EndRecord();

                RuntimeTools.SpawnPrefab = null;
            }
        }
Exemple #4
0
        protected virtual void OnAssetItemLoaded(Error error, Object[] obj)
        {
            if (obj[0] is GameObject)
            {
                IScenePivot scenePivot = IOCContainer.Resolve <IScenePivot>();
                Vector3     up         = Vector3.up;
                if (Mathf.Abs(Vector3.Dot(Camera.transform.up, Vector3.up)) > Mathf.Cos(Mathf.Deg2Rad))
                {
                    up = Vector3.Cross(Camera.transform.right, Vector3.up);
                }
                else
                {
                    up = Vector3.up;
                }
                m_dragPlane = GetDragPlane(scenePivot, up);

                GameObject prefab           = (GameObject)obj[0];
                bool       wasPrefabEnabled = prefab.activeSelf;
                prefab.SetActive(false);

                Vector3 point;
                if (GetPointOnDragPlane(out point))
                {
                    m_prefabInstance = InstantiatePrefab(prefab, point, Quaternion.identity);
                }
                else
                {
                    m_prefabInstance = InstantiatePrefab(prefab, Vector3.zero, Quaternion.identity);
                }

                Debug.Log(m_prefabInstance.GetComponentsInChildren <MeshFilter>().Length);

                m_prefabInstanceTransforms = new HashSet <Transform>(m_prefabInstance.GetComponentsInChildren <Transform>(true));

                prefab.SetActive(wasPrefabEnabled);

                Transform[] transforms = m_prefabInstance.GetComponentsInChildren <Transform>();
                foreach (Transform transform in transforms)
                {
                    ExposeToEditor exposeToEditor = transform.GetComponent <ExposeToEditor>();
                    if (exposeToEditor == null)
                    {
                        exposeToEditor = transform.gameObject.AddComponent <ExposeToEditor>();
                    }
                }

                {
                    ExposeToEditor exposeToEditor = m_prefabInstance.GetComponent <ExposeToEditor>();
                    exposeToEditor.SetName(obj[0].name);
                }


                OnActivatePrefabInstance(m_prefabInstance);
            }
        }
        public override void DragEnter(object[] dragObjects, PointerEventData eventData)
        {
            base.DragEnter(dragObjects, eventData);
            if (Editor.DragDrop.DragObjects[0] is AssetItem)
            {
                AssetItem assetItem = (AssetItem)Editor.DragDrop.DragObjects[0];
                if (m_project.ToType(assetItem) == typeof(GameObject))
                {
                    Editor.DragDrop.SetCursor(KnownCursor.DropAllowed);
                    Editor.IsBusy = true;
                    m_project.Load(assetItem, (error, obj) =>
                    {
                        Editor.IsBusy = false;
                        if (IsPointerOver)
                        {
                            if (obj is GameObject)
                            {
                                IScenePivot scenePivot = IOCContainer.Resolve <IScenePivot>();
                                Vector3 up             = Vector3.up;
                                if (Mathf.Abs(Vector3.Dot(Camera.transform.up, Vector3.up)) > Mathf.Cos(Mathf.Deg2Rad))
                                {
                                    up = Vector3.Cross(Camera.transform.right, Vector3.up);
                                }
                                else
                                {
                                    up = Vector3.up;
                                }
                                m_dragPlane = new Plane(up, scenePivot.SecondaryPivot.position);

                                GameObject prefab     = (GameObject)obj;
                                bool wasPrefabEnabled = prefab.activeSelf;
                                prefab.SetActive(false);

                                m_prefabInstance = Instantiate(prefab, Vector3.zero, Quaternion.identity);

                                prefab.SetActive(wasPrefabEnabled);

                                ExposeToEditor exposeToEditor = m_prefabInstance.GetComponent <ExposeToEditor>();
                                if (exposeToEditor == null)
                                {
                                    exposeToEditor = m_prefabInstance.AddComponent <ExposeToEditor>();
                                }

                                exposeToEditor.SetName(obj.name);
                                m_prefabInstance.SetActive(true);
                            }
                        }
                    });
                }
            }
        }
        private void OnEndEditName(string name)
        {
            GameObject     go             = m_editor.Selection.activeGameObject;
            ExposeToEditor exposeToEditor = go.GetComponent <ExposeToEditor>();

            if (exposeToEditor != null)
            {
                exposeToEditor.SetName(name);
            }
            else
            {
                go.name = name;
            }
        }
Exemple #7
0
        protected virtual void OnAssetItemLoaded(Error error, Object[] obj)
        {
            if (error.HasError)
            {
                Debug.LogError(error.ToString());
                m_prefabInstance           = null;
                m_prefabInstanceTransforms = null;
            }
            else
            {
                if (obj[0] is GameObject)
                {
                    CreateDragPlane();

                    GameObject prefab           = (GameObject)obj[0];
                    bool       wasPrefabEnabled = prefab.activeSelf;
                    prefab.SetActive(false);

                    Vector3 point;
                    if (GetPointOnDragPlane(out point))
                    {
                        m_prefabInstance = InstantiatePrefab(prefab, point, prefab.GetComponent <Transform>().rotation);
                    }
                    else
                    {
                        m_prefabInstance = InstantiatePrefab(prefab, Vector3.zero, prefab.GetComponent <Transform>().rotation);
                    }

                    Editor.AddGameObjectToHierarchy(m_prefabInstance);

                    m_prefabInstanceTransforms = new HashSet <Transform>(m_prefabInstance.GetComponentsInChildren <Transform>(true));

                    prefab.SetActive(wasPrefabEnabled);

                    ExposeToEditor exposeToEditor = ExposePrefabInstance(m_prefabInstance);
                    exposeToEditor.SetName(obj[0].name);

                    OnActivatePrefabInstance(m_prefabInstance);

                    if (!Editor.DragDrop.InProgress)
                    {
                        RecordUndo();
                        m_prefabInstance           = null;
                        m_prefabInstanceTransforms = null;
                    }
                }
            }
        }
        public override void DragEnter(object[] dragObjects, PointerEventData eventData)
        {
            base.DragEnter(dragObjects, eventData);
            if(Editor.DragDrop.DragObjects[0] is AssetItem)
            {
                AssetItem assetItem = (AssetItem)Editor.DragDrop.DragObjects[0];
                if (m_project.ToType(assetItem) == typeof(GameObject))
                {
                    Editor.DragDrop.SetCursor(KnownCursor.DropAllowed);
                    Editor.IsBusy = true;
                    m_project.Load(assetItem, (error, obj) =>
                    {
                        Editor.IsBusy = false;
                        if(IsPointerOver)
                        {
                            if (obj is GameObject)
                            {
                                GameObject prefab = (GameObject)obj;
                                bool wasPrefabEnabled = prefab.activeSelf;
                                prefab.SetActive(false);

                                m_prefabInstance = Instantiate(prefab, Vector3.zero, Quaternion.identity);

                                prefab.SetActive(wasPrefabEnabled);

                                ExposeToEditor exposeToEditor = m_prefabInstance.GetComponent<ExposeToEditor>();
                                if (exposeToEditor == null)
                                {
                                    exposeToEditor = m_prefabInstance.AddComponent<ExposeToEditor>();
                                }

                                exposeToEditor.SetName(obj.name);
                                m_prefabInstance.SetActive(true);

                                if(m_dropExecuted)
                                {
                                    RecordUndo();
                                    m_prefabInstance = null;
                                    m_dropExecuted = true;
                                }
                            }
                        }
                    });
                }
            }
        }
Exemple #9
0
        protected virtual void OnAssetItemLoaded(Error error, Object[] obj)
        {
            if (obj[0] is GameObject)
            {
                CreateDragPlane();

                GameObject prefab           = (GameObject)obj[0];
                bool       wasPrefabEnabled = prefab.activeSelf;
                prefab.SetActive(false);

                Vector3 point;
                if (GetPointOnDragPlane(out point))
                {
                    m_prefabInstance = InstantiatePrefab(prefab, point, prefab.GetComponent <Transform>().rotation);
                }
                else
                {
                    m_prefabInstance = InstantiatePrefab(prefab, Vector3.zero, prefab.GetComponent <Transform>().rotation);
                }

                m_prefabInstanceTransforms = new HashSet <Transform>(m_prefabInstance.GetComponentsInChildren <Transform>(true));

                prefab.SetActive(wasPrefabEnabled);

                Transform[] transforms = m_prefabInstance.GetComponentsInChildren <Transform>();
                foreach (Transform transform in transforms)
                {
                    ExposeToEditor exposeToEditor = transform.GetComponent <ExposeToEditor>();
                    if (exposeToEditor == null)
                    {
                        exposeToEditor = transform.gameObject.AddComponent <ExposeToEditor>();
                    }
                }

                {
                    ExposeToEditor exposeToEditor = m_prefabInstance.GetComponent <ExposeToEditor>();
                    exposeToEditor.SetName(obj[0].name);
                }


                OnActivatePrefabInstance(m_prefabInstance);
            }
        }
Exemple #10
0
        protected virtual void OnNameChanged(ExposeToEditor obj)
        {
            AssetItem assetItem = m_project.ToAssetItem(obj);

            if (assetItem == null)
            {
                return;
            }
            VirtualizingTreeViewItem tvItem = m_listBox.GetTreeViewItem(assetItem);

            if (tvItem == null)
            {
                return;
            }
            TextMeshProUGUI text = tvItem.ItemPresenter.GetComponentInChildren <TextMeshProUGUI>(true);

            if (!Rename(text, assetItem, obj.name))
            {
                obj.SetName(assetItem.Name);
            }
        }
        private void OnEndEditName(string name)
        {
            GameObject[] gameObjects = m_editor.Selection.gameObjects;
            for (int i = 0; i < gameObjects.Length; ++i)
            {
                GameObject go = gameObjects[i];
                if (go == null)
                {
                    continue;
                }

                ExposeToEditor exposeToEditor = go.GetComponent <ExposeToEditor>();
                if (exposeToEditor != null)
                {
                    exposeToEditor.SetName(name, true);
                }
                else
                {
                    go.name = name;
                }
            }
        }
Exemple #12
0
        void IDropHandler.OnDrop(PointerEventData eventData)
        {
            GameObject go = eventData.pointerDrag;

            if (go != null)
            {
                ItemContainer itemContainer = go.GetComponent <ItemContainer>();
                if (itemContainer != null && itemContainer.Item != null)
                {
                    object item = itemContainer.Item;
                    if (item != null && item is GameObject)
                    {
                        GameObject prefab = item as GameObject;
                        if (RuntimePrefabs.IsPrefab(prefab.transform))
                        {
                            Ray ray = Camera.ScreenPointToRay(Input.mousePosition);
                            //Plane p = new Plane(Vector3.up, Vector3.zero);
                            float distance;
                            //if(!p.Raycast(ray, out distance))
                            {
                                distance = 15;
                            }
                            Vector3        worldPoint     = ray.GetPoint(distance);
                            GameObject     prefabInstance = Instantiate(prefab);
                            ExposeToEditor exposeToEditor = prefabInstance.GetComponent <ExposeToEditor>();
                            if (exposeToEditor != null)
                            {
                                exposeToEditor.SetName(prefab.name);
                            }
                            prefabInstance.transform.position   = worldPoint;
                            prefabInstance.transform.rotation   = prefab.transform.rotation;
                            prefabInstance.transform.localScale = prefab.transform.localScale;
                            RuntimeSelection.activeGameObject   = prefabInstance;
                        }
                    }
                }
            }
        }
        private void LateUpdate()
        {
            if (IsSelected)
            {
                m_updateCounter++;
                m_updateCounter %= UpdatePreviewInterval;
                if (m_updateCounter == 0)
                {
                    UpdatePreview();
                }

                if (m_state == State.Idle)
                {
                    return;
                }
            }

            if (m_state == State.Idle)
            {
                enabled = false;
                return;
            }

            GameObject go = m_resource as GameObject;

            if (!go)
            {
                return;
            }

            Vector3 point;

            if (RuntimeEditorApplication.PointerOverWindowType == RuntimeWindowType.SceneView)
            {
                if (m_state == State.AfterSpawn)
                {
                    if (GetPointOnDragPlane(out point))
                    {
                        m_instance.transform.position = point;
                        Ray        ray = RuntimeEditorApplication.ActiveSceneCamera.ScreenPointToRay(Input.mousePosition);
                        RaycastHit hit = Physics.RaycastAll(ray).Where(h => h.transform != m_instance.transform).FirstOrDefault();
                        if (hit.transform != null)
                        {
                            m_instance.transform.position = hit.point;
                        }
                    }
                }
                else
                {
                    m_state     = State.AfterSpawn;
                    m_dragPlane = new Plane(Vector3.up, m_editor.SceneView.SecondaryPivot.position);
                    if (!GetPointOnDragPlane(out point))
                    {
                        Camera camera = RuntimeEditorApplication.ActiveSceneCamera;
                        if (camera != null)
                        {
                            m_dragPlane = new Plane(-camera.transform.forward, camera.transform.forward * 7.5f);
                            GetPointOnDragPlane(out point);
                        }
                    }

                    m_instance = go.InstantiatePrefab(point, Quaternion.identity);
                    m_instance.SetActive(true);

                    ExposeToEditor exposeToEditor = m_instance.GetComponent <ExposeToEditor>();
                    if (exposeToEditor == null)
                    {
                        exposeToEditor = m_instance.AddComponent <ExposeToEditor>();
                    }
                    if (exposeToEditor != null)
                    {
                        exposeToEditor.SetName(m_resource.name);
                    }

                    bool isEnabled = RuntimeUndo.Enabled;
                    RuntimeUndo.Enabled = false;
                    RuntimeSelection.activeGameObject = m_instance;
                    RuntimeUndo.Enabled = isEnabled;
                }

                if (RuntimeTools.UnitSnapping)
                {
                    Vector3 pt = m_instance.transform.position;

                    point.x = Mathf.Round(pt.x);
                    point.y = Mathf.Round(pt.y);
                    point.z = Mathf.Round(pt.z);

                    m_instance.transform.position = point;
                }
            }
            else
            {
                if (m_state == State.AfterSpawn)
                {
                    DestroyInstance();
                }
            }
            if (Input.GetMouseButtonDown(1))
            {
                if (m_state == State.AfterSpawn)
                {
                    DestroyInstance();
                }
                EndSpawn();
            }

            if (Input.GetMouseButtonDown(0))
            {
                CompleteSpawn();
            }
        }
Exemple #14
0
        private void OnAssetItemsLoaded(Object[] objects, ExposeToEditor dropTarget, VirtualizingTreeViewItem treeViewItem)
        {
            GameObject[] createdObjects = new GameObject[objects.Length];
            for (int i = 0; i < objects.Length; ++i)
            {
                GameObject prefab           = (GameObject)objects[i];
                bool       wasPrefabEnabled = prefab.activeSelf;
                prefab.SetActive(false);
                GameObject prefabInstance = InstantiatePrefab(prefab);
                prefab.SetActive(wasPrefabEnabled);

                ExposeToEditor exposeToEditor = prefabInstance.GetComponent <ExposeToEditor>();
                if (exposeToEditor == null)
                {
                    exposeToEditor = prefabInstance.AddComponent <ExposeToEditor>();
                }

                exposeToEditor.SetName(prefab.name);

                if (dropTarget == null)
                {
                    exposeToEditor.transform.SetParent(null);
                    m_treeView.Add(exposeToEditor);
                }
                else
                {
                    if (m_treeView.DropAction == ItemDropAction.SetLastChild)
                    {
                        exposeToEditor.transform.SetParent(dropTarget.transform);
                        m_treeView.AddChild(dropTarget, exposeToEditor);
                        treeViewItem.CanExpand  = true;
                        treeViewItem.IsExpanded = true;
                    }
                    if (m_lastDropAction != ItemDropAction.None)
                    {
                        int index;
                        int siblingIndex;
                        if (m_lastDropAction == ItemDropAction.SetNextSibling)
                        {
                            index        = m_treeView.IndexOf(dropTarget) + 1;
                            siblingIndex = dropTarget.transform.GetSiblingIndex() + 1;
                        }
                        else
                        {
                            index        = m_treeView.IndexOf(dropTarget);
                            siblingIndex = dropTarget.transform.GetSiblingIndex();
                        }

                        exposeToEditor.transform.SetParent(dropTarget.transform.parent != null ? dropTarget.transform.parent : null);
                        exposeToEditor.transform.SetSiblingIndex(siblingIndex);

                        TreeViewItemContainerData newTreeViewItemData = (TreeViewItemContainerData)m_treeView.Insert(index, exposeToEditor);
                        VirtualizingTreeViewItem  newTreeViewItem     = m_treeView.GetTreeViewItem(exposeToEditor);
                        if (newTreeViewItem != null)
                        {
                            newTreeViewItem.Parent = treeViewItem.Parent;
                        }
                        else
                        {
                            newTreeViewItemData.Parent = treeViewItem.Parent;
                        }
                    }
                }

                OnActivatePrefabInstance(prefabInstance);
                createdObjects[i] = prefabInstance;
            }

            if (createdObjects.Length > 0)
            {
                IRuntimeEditor editor = IOC.Resolve <IRuntimeEditor>();
                editor.RegisterCreatedObjects(createdObjects);
            }

            m_treeView.ExternalItemDrop();
            m_isSpawningPrefab = false;
        }
        private void OnItemDrop(object sender, ItemDropArgs e)
        {
            if (e.IsExternal)
            {
                if (e.DragItems != null)
                {
                    for (int i = 0; i < e.DragItems.Length; ++i)
                    {
                        GameObject prefab = e.DragItems[i] as GameObject;
                        if (prefab != null)
                        {
                            if (RuntimePrefabs.IsPrefab(prefab.transform))
                            {
                                GameObject     prefabInstance = Instantiate(prefab);
                                ExposeToEditor exposeToEditor = prefabInstance.GetComponent <ExposeToEditor>();
                                if (exposeToEditor != null)
                                {
                                    exposeToEditor.SetName(prefab.name);
                                }
                                prefabInstance.transform.position   = prefab.transform.position;
                                prefabInstance.transform.rotation   = prefab.transform.rotation;
                                prefabInstance.transform.localScale = prefab.transform.localScale;
                                RuntimeSelection.activeGameObject   = prefabInstance;
                            }
                        }
                    }
                }
            }
            else
            {
                Transform dropT = ((GameObject)e.DropTarget).transform;
                if (e.Action == ItemDropAction.SetLastChild)
                {
                    for (int i = 0; i < e.DragItems.Length; ++i)
                    {
                        Transform dragT = ((GameObject)e.DragItems[i]).transform;
                        dragT.SetParent(dropT, true);
                        dragT.SetAsLastSibling();
                    }
                }
                else if (e.Action == ItemDropAction.SetNextSibling)
                {
                    for (int i = 0; i < e.DragItems.Length; ++i)
                    {
                        Transform dragT = ((GameObject)e.DragItems[i]).transform;
                        if (dragT.parent != dropT.parent)
                        {
                            dragT.SetParent(dropT.parent, true);
                        }

                        int siblingIndex = dropT.GetSiblingIndex();
                        dragT.SetSiblingIndex(siblingIndex + 1);
                    }
                }
                else if (e.Action == ItemDropAction.SetPrevSibling)
                {
                    for (int i = 0; i < e.DragItems.Length; ++i)
                    {
                        Transform dragT = ((GameObject)e.DragItems[i]).transform;
                        if (dragT.parent != dropT.parent)
                        {
                            dragT.SetParent(dropT.parent, true);
                        }

                        int siblingIndex = dropT.GetSiblingIndex();
                        dragT.SetSiblingIndex(siblingIndex);
                    }
                }
            }
        }
Exemple #16
0
        public override void Drop(object[] dragObjects, PointerEventData pointerEventData)
        {
            base.Drop(dragObjects, pointerEventData);

            if (CanDrop(dragObjects))
            {
                ExposeToEditor           dropTarget   = (ExposeToEditor)m_treeView.DropTarget;
                VirtualizingTreeViewItem treeViewItem = null;
                if (dropTarget != null)
                {
                    treeViewItem = m_treeView.GetTreeViewItem(m_treeView.DropTarget);
                }

                AssetItem[] loadAssetItems = dragObjects.Where(o => o is AssetItem && m_project.ToType((AssetItem)o) == typeof(GameObject)).Select(o => (AssetItem)o).ToArray();
                if (loadAssetItems.Length > 0)
                {
                    m_isSpawningPrefab = true;
                    Editor.IsBusy      = true;
                    m_project.Load(loadAssetItems, (error, objects) =>
                    {
                        Editor.IsBusy = false;
                        if (error.HasError)
                        {
                            IWindowManager wm = IOC.Resolve <IWindowManager>();
                            wm.MessageBox("Unable to load asset items.", error.ErrorText);
                            return;
                        }

                        GameObject[] createdObjects = new GameObject[objects.Length];
                        for (int i = 0; i < objects.Length; ++i)
                        {
                            GameObject prefab     = (GameObject)objects[i];
                            bool wasPrefabEnabled = prefab.activeSelf;
                            prefab.SetActive(false);
                            GameObject prefabInstance = Instantiate(prefab, Vector3.zero, Quaternion.identity);
                            prefab.SetActive(wasPrefabEnabled);

                            ExposeToEditor exposeToEditor = prefabInstance.GetComponent <ExposeToEditor>();
                            if (exposeToEditor == null)
                            {
                                exposeToEditor = prefabInstance.AddComponent <ExposeToEditor>();
                            }

                            exposeToEditor.SetName(prefab.name);

                            if (dropTarget == null)
                            {
                                exposeToEditor.transform.SetParent(null);
                                m_treeView.Add(exposeToEditor);
                            }
                            else
                            {
                                if (m_treeView.DropAction == ItemDropAction.SetLastChild)
                                {
                                    exposeToEditor.transform.SetParent(dropTarget.transform);
                                    m_treeView.AddChild(dropTarget, exposeToEditor);
                                    treeViewItem.CanExpand  = true;
                                    treeViewItem.IsExpanded = true;
                                }
                                else if (m_treeView.DropAction != ItemDropAction.None)
                                {
                                    int index;
                                    int siblingIndex;
                                    if (m_treeView.DropAction == ItemDropAction.SetNextSibling)
                                    {
                                        index        = m_treeView.IndexOf(dropTarget) + 1;
                                        siblingIndex = dropTarget.transform.GetSiblingIndex() + 1;
                                    }
                                    else
                                    {
                                        index        = m_treeView.IndexOf(dropTarget);
                                        siblingIndex = dropTarget.transform.GetSiblingIndex();
                                    }

                                    exposeToEditor.transform.SetParent(dropTarget.transform.parent != null ? dropTarget.transform.parent : null);
                                    exposeToEditor.transform.SetSiblingIndex(siblingIndex);

                                    TreeViewItemContainerData newTreeViewItemData = (TreeViewItemContainerData)m_treeView.Insert(index, exposeToEditor);
                                    VirtualizingTreeViewItem newTreeViewItem      = m_treeView.GetTreeViewItem(exposeToEditor);
                                    if (newTreeViewItem != null)
                                    {
                                        newTreeViewItem.Parent = treeViewItem.Parent;
                                    }
                                    else
                                    {
                                        newTreeViewItemData.Parent = treeViewItem.Parent;
                                    }
                                }
                            }

                            prefabInstance.SetActive(true);
                            createdObjects[i] = prefabInstance;
                        }

                        if (createdObjects.Length > 0)
                        {
                            IRuntimeEditor editor = IOC.Resolve <IRuntimeEditor>();
                            editor.RegisterCreatedObjects(createdObjects);
                        }

                        m_treeView.ExternalItemDrop();
                        m_isSpawningPrefab = false;
                    });
                }
                else
                {
                    m_treeView.ExternalItemDrop();
                }
            }
            else
            {
                m_treeView.ExternalItemDrop();
            }
        }