private void UpdatePreview(Material material)
 {
     if (Preview && m_image != null)
     {
         m_image.sprite = ResourcePreview.CreatePreview(material, Preview);
     }
 }
Пример #2
0
        private void CompleteSpawn(object item)
        {
            ItemContainer itemContainer = m_listBox.GetItemContainer(item);

            if (itemContainer != null)
            {
                ResourcePreview resource = itemContainer.GetComponentInChildren <ResourcePreview>();
                resource.CompleteSpawn();
            }

            if (RuntimeEditorApplication.IsPointerOverWindow(RuntimeWindowType.Resources))
            {
                RuntimeTools.SpawnPrefab = null;
            }

            if (Drop != null)
            {
                Drop(this, new ProjectResourcesEventArgs(new [] { (ProjectItemObjectPair)item }));
            }
        }
Пример #3
0
        private void OnItemBeginDrag(object sender, ItemArgs e)
        {
            CursorHelper.SetCursor(this, DragIcon, new Vector2(DragIcon.width / 2, DragIcon.height / 2), CursorMode.Auto);

            ItemContainer itemContainer = m_listBox.GetItemContainer(e.Items[0]);

            if (itemContainer != null)
            {
                ResourcePreview runtimeResource = itemContainer.GetComponentInChildren <ResourcePreview>();
                runtimeResource.BeginSpawn();
            }

            ProjectItemObjectPair objectItemPair = (ProjectItemObjectPair)e.Items[0];

            if (BeginDrag != null)
            {
                BeginDrag(this, new ProjectResourcesEventArgs(new[] { objectItemPair }));
            }

            if (objectItemPair.IsResource)
            {
                DragDrop.RaiseBeginDrag(new[] { objectItemPair.Object });
            }
        }
Пример #4
0
        private void OnItemDataBinding(object sender, ItemDataBindingArgs e)
        {
            ProjectItemObjectPair pair = e.Item as ProjectItemObjectPair;

            if (pair != null)
            {
                Text            text       = e.ItemPresenter.GetComponentInChildren <Text>(true);
                ResourcePreview rtResource = e.ItemPresenter.GetComponentInChildren <ResourcePreview>(true);

                if (pair.IsFolder || pair.IsScene)
                {
                    UnityObject     obj      = pair.Object;
                    ProjectItemType itemType = ProjectItemType.None;
                    if (pair.IsFolder)
                    {
                        if (pair.ProjectItem.IsExposedFromEditor)
                        {
                            itemType = ProjectItemType.ExposedFolder;
                        }
                        else
                        {
                            itemType = ProjectItemType.Folder;
                        }
                    }
                    else if (pair.IsScene)
                    {
                        itemType = ProjectItemType.Scene;
                    }

                    rtResource.Set(itemType, null);
                    text.text = pair.ProjectItem.Name;
                }
                else
                {
                    if (pair.ProjectItem != null && pair.ProjectItem.IsExposedFromEditor)
                    {
                        rtResource.Set(ProjectItemType.ExposedResource, pair.Object);
                    }
                    else
                    {
                        if (pair.Object is NoneItem)
                        {
                            rtResource.Set(ProjectItemType.None, pair.Object);
                        }
                        else
                        {
                            rtResource.Set(ProjectItemType.Resource, pair.Object);
                        }
                    }

                    if (pair.ProjectItem != null)
                    {
                        text.text = pair.ProjectItem.Name;
                    }
                    else
                    {
                        text.text = pair.Object.name;
                    }
                }

                if (pair.ProjectItem != null)
                {
                    ProjectItem item = pair.ProjectItem;
                    e.CanEdit = !item.IsExposedFromEditor;
                    if (item.IsFolder && item.IsScene)
                    {
                        e.CanDrag = !item.IsExposedFromEditor;
                    }
                    else
                    {
                        e.CanDrag = true;
                    }
                }
                else
                {
                    e.CanDrag = false;
                    e.CanEdit = false;
                }
            }
        }