Exemple #1
0
        protected override void DoubleClickedItem(int id)
        {
            TimelineLiteAssetTreeViewItem item = FindItem(id, rootItem) as TimelineLiteAssetTreeViewItem;

            if (item == null)
            {
                return;
            }
            TimelineLiteAsset data = item.UserData;

            Selection.activeObject = data;
        }
Exemple #2
0
        protected override void RenameEnded(RenameEndedArgs args)
        {
            TimelineLiteAssetTreeViewItem item = FindItem(args.itemID, rootItem) as TimelineLiteAssetTreeViewItem;

            if (item == null)
            {
                return;
            }
            TimelineLiteAsset data = item.UserData;

            AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(data), args.newName);
            item.displayName = data.name;
        }
Exemple #3
0
        protected virtual TimelineLitesTreeView BuildAssetsListTreeView()
        {
            TimelineLitesTreeView projecListTreeView = new TimelineLitesTreeView(TreeViewState, searchText, this);

            // 查找所有使用此类的ScriptableObjects
            string[] guids = AssetDatabase.FindAssets("t:" + TimelineLiteAssetType);

            for (int i = 0; i < guids.Length; i++)
            {
                string                        assetPath         = AssetDatabase.GUIDToAssetPath(guids[i]);
                TimelineLiteAsset             asset             = AssetDatabase.LoadAssetAtPath <TimelineLiteAsset>(assetPath);
                TimelineLiteAssetTreeViewItem assetTreeViewItem = new TimelineLiteAssetTreeViewItem(asset);
                projecListTreeView.AddItem(asset.GetType().Name, assetTreeViewItem);
            }
            return(projecListTreeView);
        }
Exemple #4
0
        protected override void SingleClickedItem(int id)
        {
            base.SingleClickedItem(id);
            TimelineLiteAssetTreeViewItem item = FindItem(id, rootItem) as TimelineLiteAssetTreeViewItem;

            if (item == null)
            {
                return;
            }
            TimelineLiteAsset data = item.UserData;

            if (data != null && UnityEditor.Timeline.TimelineEditor.inspectedAsset != data)
            {
                AssetDatabase.OpenAsset(data);
                Window.Focus();
            }
        }
Exemple #5
0
        public virtual void BuildAssetContextMenu(IList <int> selection, GenericMenu genericMenu)
        {
            if (selection.Count > 0)
            {
                if (selection.Count == 1)
                {
                    TimelineLiteAssetTreeViewItem item = projecListTreeView.FindItem(selection[0]) as TimelineLiteAssetTreeViewItem;
                    if (item != null)
                    {
                        TimelineLiteAsset data = item.UserData;
                        BuildSingleAssetItemMenu(data, genericMenu);
                    }
                }
                else
                {
                    genericMenu.AddItem(new GUIContent("批量另存为SO"), false, () => SaveSOSelectionAs(selection));
                }

                genericMenu.AddItem(new GUIContent("删除所选"), false, () => DeleteSelection(selection));
            }
        }
Exemple #6
0
        protected override void SelectionChanged(IList <int> selectedIds)
        {
            base.SelectionChanged(selectedIds);
            if (selectedIds.Count <= 0)
            {
                return;
            }
            TimelineLiteAssetTreeViewItem item = FindItem(selectedIds[0], rootItem) as TimelineLiteAssetTreeViewItem;

            if (item == null)
            {
                return;
            }
            TimelineLiteAsset data = item.UserData;

            if (data != null && UnityEditor.Timeline.TimelineEditor.timelineAsset != data)
            {
                AssetDatabase.OpenAsset(data);
                Window.Focus();
            }
        }
Exemple #7
0
        protected override void RowGUI(RowGUIArgs args)
        {
            TimelineLiteAssetTreeViewItem assetItem = args.item as TimelineLiteAssetTreeViewItem;

            if (assetItem == null)
            {
                base.RowGUI(args);
                return;
            }
            if (args.isRenaming)
            {
                return;
            }
            TimelineLiteAsset asset = assetItem.UserData;

            Rect rect = args.rowRect;

            rect.x     = 20;
            rect.width = args.rowRect.width - 20;
            GUI.Label(rect, asset.name);

            rect.x     = args.rowRect.width - 25;
            rect.width = 25;
            if (!EditorApplication.isPlaying || TimelineLiteEditorWindow.Playable == null)
            {
                EditorGUI.BeginDisabledGroup(true);
            }

            if (GUI.Button(rect, playIcon, (GUIStyle)"toolbarbutton"))
            {
                TimelineLiteEditorWindow.Playable.Play(
                    Activator.CreateInstance(asset.TargetObjectType, asset.Extract()) as ITimelineLiteObject);
                Repaint();
            }

            if (!EditorApplication.isPlaying || TimelineLiteEditorWindow.Playable == null)
            {
                EditorGUI.EndDisabledGroup();
            }
        }
Exemple #8
0
        private void DeleteSelection(IList <int> _selection)
        {
            if (EditorUtility.DisplayDialog("警告", "你确定要删除所选文件吗?", "删除", "取消"))
            {
                List <TimelineLiteAsset> datas = new List <TimelineLiteAsset>();
                foreach (var id in _selection)
                {
                    TimelineLiteAssetTreeViewItem item = projecListTreeView.FindItem(id) as TimelineLiteAssetTreeViewItem;
                    if (item == null)
                    {
                        continue;
                    }

                    datas.Add(item.UserData);
                }

                foreach (var data in datas)
                {
                    AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(data));
                }
                projecListTreeView.SetSelection(new List <int>());
            }
        }
Exemple #9
0
        /// <summary> SO </summary>
        private void SaveSOSelectionAs(IList <int> _selection)
        {
            string path = EditorUtility.OpenFolderPanel("批量另存为", Application.dataPath, "");

            if (!string.IsNullOrEmpty(path))
            {
                path = path.Replace(Application.dataPath, "Assets");
                foreach (var id in _selection)
                {
                    TimelineLiteAssetTreeViewItem item = projecListTreeView.FindItem(id) as TimelineLiteAssetTreeViewItem;
                    if (item == null)
                    {
                        continue;
                    }
                    TimelineLiteAsset data = item.UserData;

                    data.previousPath = path + "/" + data.name + "_SO";
                    EditorUtility.SetDirty(data);

                    TimelineLiteSO so = AssetDatabase.LoadAssetAtPath <TimelineLiteSO>(data.previousPath + ".asset");
                    if (so != null)
                    {
                        so.TimelineLiteObjectData = data.Extract();
                        EditorUtility.SetDirty(so);
                    }
                    else
                    {
                        so = ScriptableObject.CreateInstance(data.TargetSOType) as TimelineLiteSO;
                        so.TimelineLiteObjectData = data.Extract();
                        AssetDatabase.CreateAsset(so, data.previousPath + ".asset");
                    }
                }

                AssetDatabase.SaveAssets();
            }
        }