Пример #1
0
        public static bool TryToSelectUnselectedItemCallback(Vector2 mousePosition, TimelinableSequenceBase sequence)
        {
            if (sequence == null || sequence.tracks.IsNullOrEmpty())
            {
                return(false);
            }
            TimelinableItemInfoBase selectNewUnselectedItemInfo = null;

            foreach (var track in sequence.tracks)
            {
                foreach (var itemInfo in track.itemInfoes)
                {
                    if (itemInfo.rect.Contains(mousePosition) && !itemInfo.isSelected)
                    {
                        selectNewUnselectedItemInfo            = itemInfo;
                        selectNewUnselectedItemInfo.isSelected = true;
                        break;
                    }
                }

                if (selectNewUnselectedItemInfo != null)
                {
                    break;
                }
            }

            if (!Event.current.control)
            {
                foreach (var track in sequence.tracks)
                {
                    foreach (var itemInfo in track.itemInfoes)
                    {
                        if (selectNewUnselectedItemInfo != itemInfo)
                        {
                            itemInfo.isSelected = false;
                        }
                    }
                }
            }


            if (selectNewUnselectedItemInfo != null)
            {
                return(true);
            }
            return(false);
        }
Пример #2
0
        public virtual void DrawGUISetting_ItemInfoLibrary()
        {
            Type itemInfoLibraryType = this.GetFieldInfo("_itemInfoLibrary").FieldType;

            using (new GUILayoutToggleAreaScope(itemInfoLibraryToggleTween, "Library", () =>
            {
                itemInfoLibrary = (TimelinableItemInfoLibraryBase)EditorGUILayout.ObjectField(itemInfoLibrary,
                                                                                              itemInfoLibraryType, false);
                if (GUILayout.Button("create", GUILayout.Width(64)))
                {
                    var path = EditorUtility.SaveFilePanel(
                        "保存文件到",
                        "",
                        string.Format("{0}.asset", itemInfoLibraryType.GetLastName()),
                        "asset");
                    if (!path.IsNullOrEmpty())
                    {
                        itemInfoLibrary =
                            typeof(ScriptableObjectUtil).InvokeGenericMethod <TimelinableItemInfoLibraryBase>(
                                "CreateAsset",
                                new Type[] { itemInfoLibraryType }, false, path);
                    }
                }

                using (new GUIEnabledScope(itemInfoLibrary != null))
                {
                    if (GUILayout.Button("save", GUILayout.Width(64)))
                    {
                        EditorUtility.SetDirty(itemInfoLibrary);
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();
                    }
                }
            }))
            {
                if (itemInfoLibrary == null || itemInfoLibrary.itemInfoes.IsNullOrEmpty())
                {
                    EditorGUILayout.HelpBox("Library is empty", MessageType.Warning);
                }
                else
                {
                    isItemInfoLibrarySorted = GUILayout.Toggle(isItemInfoLibrarySorted, "Sort", "button");
                    if (isItemInfoLibrarySorted)
                    {
                        Array.Sort(itemInfoLibrary.itemInfoes, (x, y) => x.name.AlphanumCompareTo(y.name));
                    }
                    List <int> toRemoveIndexList = new List <int>();
                    for (int i = 0; i < itemInfoLibrary.itemInfoes.Length; i++)
                    {
                        TimelinableItemInfoBase itemInfo = itemInfoLibrary.itemInfoes[i];
                        using (new GUILayoutBeginHorizontalScope())
                        {
                            if (GUILayout.Button(itemInfo.name))
                            {
                                var newItemInfo = itemInfo.GetType().CreateInstance <TimelinableItemInfoBase>();
                                newItemInfo.CopyFrom(itemInfo);
                                newItemInfo.time = curTime;
                                AddItemInfo(newItemInfo);
                            }

                            if (GUILayout.Button("-", GUILayout.Width(32)))
                            {
                                toRemoveIndexList.Add(i);
                            }
                        }
                    }

                    for (int i = toRemoveIndexList.Count - 1; i >= 0; i--)
                    {
                        itemInfoLibrary.RemoveItemInfo(itemInfoLibrary.itemInfoes[i]);
                    }
                }
            }
        }
Пример #3
0
        public int CompareTo(object other)
        {
            TimelinableItemInfoBase otherTimelinableItemInfo = other as TimelinableItemInfoBase;

            return(time.CompareTo(otherTimelinableItemInfo.time));
        }