GetHashCode() public method

public GetHashCode ( ) : int
return int
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            DragAndDropVisualMode visualMode = DragAndDropVisualMode.None;

            var draggedIDs = DragAndDrop.GetGenericData("BuildPlayerSceneTreeViewItem") as List <int>;

            if (draggedIDs != null && draggedIDs.Count > 0)
            {
                visualMode = DragAndDropVisualMode.Move;
                if (args.performDrop)
                {
                    int newIndex = FindDropAtIndex(args);

                    var result   = new List <TreeViewItem>();
                    int toInsert = 0;
                    foreach (var item in rootItem.children)
                    {
                        if (toInsert == newIndex)
                        {
                            foreach (var id in draggedIDs)
                            {
                                result.Add(FindItem(id, rootItem));
                            }
                        }
                        toInsert++;
                        if (!draggedIDs.Contains(item.id))
                        {
                            result.Add(item);
                        }
                    }

                    if (result.Count < rootItem.children.Count) //must be appending.
                    {
                        foreach (var id in draggedIDs)
                        {
                            result.Add(FindItem(id, rootItem));
                        }
                    }
                    rootItem.children          = result;
                    EditorBuildSettings.scenes = GetSceneList();
                    ReloadAndSelect(draggedIDs);
                    Repaint();
                }
            }
            else if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0)
            {
                visualMode = DragAndDropVisualMode.Copy;
                if (args.performDrop)
                {
                    var scenes      = new List <EditorBuildSettingsScene>(EditorBuildSettings.scenes);
                    var scenesToAdd = new List <EditorBuildSettingsScene>();
                    var selection   = new List <int>();

                    foreach (var path in DragAndDrop.paths)
                    {
                        if (AssetDatabase.GetMainAssetTypeAtPath(path) == typeof(SceneAsset))
                        {
                            var guid = new GUID(AssetDatabase.AssetPathToGUID(path));
                            selection.Add(guid.GetHashCode());

                            bool unique = true;
                            foreach (var scene in scenes)
                            {
                                if (scene.path == path)
                                {
                                    unique = false;
                                    break;
                                }
                            }
                            if (unique)
                            {
                                scenesToAdd.Add(new EditorBuildSettingsScene(path, true));
                            }
                        }
                    }


                    int newIndex = FindDropAtIndex(args);
                    scenes.InsertRange(newIndex, scenesToAdd);
                    EditorBuildSettings.scenes = scenes.ToArray();
                    ReloadAndSelect(selection);
                    Repaint();
                }
            }
            return(visualMode);
        }
Esempio n. 2
0
        protected override DragAndDropVisualMode HandleDragAndDrop(TreeView.DragAndDropArgs args)
        {
            DragAndDropVisualMode result = DragAndDropVisualMode.None;
            List <int>            list   = DragAndDrop.GetGenericData("BuildPlayerSceneTreeViewItem") as List <int>;

            if (list != null && list.Count > 0)
            {
                result = DragAndDropVisualMode.Move;
                if (args.performDrop)
                {
                    int num = this.FindDropAtIndex(args);
                    List <TreeViewItem> list2 = new List <TreeViewItem>();
                    int num2 = 0;
                    foreach (TreeViewItem current in base.rootItem.children)
                    {
                        if (num2 == num)
                        {
                            foreach (int current2 in list)
                            {
                                list2.Add(base.FindItem(current2, base.rootItem));
                            }
                        }
                        num2++;
                        if (!list.Contains(current.id))
                        {
                            list2.Add(current);
                        }
                    }
                    if (list2.Count < base.rootItem.children.Count)
                    {
                        foreach (int current3 in list)
                        {
                            list2.Add(base.FindItem(current3, base.rootItem));
                        }
                    }
                    base.rootItem.children     = list2;
                    EditorBuildSettings.scenes = this.GetSceneList();
                    this.ReloadAndSelect(list);
                    base.Repaint();
                }
            }
            else if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0)
            {
                result = DragAndDropVisualMode.Copy;
                if (args.performDrop)
                {
                    List <EditorBuildSettingsScene> list3 = new List <EditorBuildSettingsScene>(EditorBuildSettings.scenes);
                    List <EditorBuildSettingsScene> list4 = new List <EditorBuildSettingsScene>();
                    List <int> list5 = new List <int>();
                    string[]   paths = DragAndDrop.paths;
                    for (int i = 0; i < paths.Length; i++)
                    {
                        string text = paths[i];
                        if (AssetDatabase.GetMainAssetTypeAtPath(text) == typeof(SceneAsset))
                        {
                            GUID gUID = new GUID(AssetDatabase.AssetPathToGUID(text));
                            list5.Add(gUID.GetHashCode());
                            bool flag = true;
                            foreach (EditorBuildSettingsScene current4 in list3)
                            {
                                if (current4.path == text)
                                {
                                    flag = false;
                                    break;
                                }
                            }
                            if (flag)
                            {
                                list4.Add(new EditorBuildSettingsScene(text, true));
                            }
                        }
                    }
                    int index = this.FindDropAtIndex(args);
                    list3.InsertRange(index, list4);
                    EditorBuildSettings.scenes = list3.ToArray();
                    this.ReloadAndSelect(list5);
                    base.Repaint();
                }
            }
            return(result);
        }
 /// <summary>
 /// Custom hashcode generation.
 /// </summary>
 /// <returns>Int value representing the hash value.</returns>
 public override int GetHashCode()
 {
     return((name ?? string.Empty).GetHashCode() ^ m_GUID.GetHashCode());
 }