Exemple #1
0
        private void ActivateCanvas(CanvasBehaviourBase prevCanvas, CanvasBehaviourBase afterCanvas)
        {
            var indexOfPrev            = canvasList.IndexOf(prevCanvas);
            var indexOfAfter           = canvasList.IndexOf(afterCanvas);
            int countFromCentralToEdge = numberToDisplay / 2;
            var loopTimes = Mathf.Min(numberToDisplay, Mathf.Abs(indexOfAfter - indexOfPrev));

            for (int i = 0; i < loopTimes; i++)
            {
                if (indexOfPrev < indexOfAfter)
                {
                    if (indexOfPrev - countFromCentralToEdge >= 0)
                    {
                        canvasList[indexOfPrev - countFromCentralToEdge + i].gameObject.SetActive(false);
                    }
                    if (indexOfAfter + countFromCentralToEdge < canvasList.Count)
                    {
                        canvasList[indexOfAfter + countFromCentralToEdge - i].gameObject.SetActive(true);
                    }
                }
                else if (indexOfPrev > indexOfAfter)
                {
                    if (indexOfPrev + countFromCentralToEdge < canvasList.Count)
                    {
                        canvasList[indexOfPrev + countFromCentralToEdge - i].gameObject.SetActive(false);
                    }
                    if (indexOfAfter - countFromCentralToEdge >= 0)
                    {
                        canvasList[indexOfAfter - countFromCentralToEdge + i].gameObject.SetActive(true);
                    }
                }
            }
        }
Exemple #2
0
 public void OnSet()
 {
     if (parentScroll == null)
     {
         return;
     }
     parentScroll.SelectCanvas(this);
     SelectedCanvas = this;
     GetComponent <IGlowable>()?.Glow();
 }
Exemple #3
0
        public bool Exist(CanvasBehaviourBase canvas)
        {
            foreach (var item in canvasList)
            {
                if (canvas == item)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #4
0
        private void TransitCenterCanvas()
        {
            if (prevCenterCanvas == CenterCanvas)
            {
                return;
            }

            var afterCanvas = CenterCanvas;

            ActivateCanvas(prevCenterCanvas, afterCanvas);
            prevCenterCanvas           = afterCanvas;
            centerPosition[actionAxis] = 0f;
        }
Exemple #5
0
        public static bool Open(CanvasScroll scroll, CanvasBehaviourBase directoryCanvas, CanvasBehaviourBase fileCanvas, string path)
        {
            var directoryList = System.IO.Directory.GetDirectories(path);
            var fileList      = System.IO.Directory.GetFiles(path);

            if (directoryList.Length == 0 && fileList.Length == 0)
            {
                return(false);
            }

            foreach (var directoryPath in directoryList)
            {
                var directoryName      = new DirectoryInfo(directoryPath).Name;
                var instantiatedCanvas = scroll.AddCanvas(directoryCanvas.gameObject, directoryName);
                instantiatedCanvas.GetComponent <CanvasBehaviourBase>().SetParentScroll(scroll);
                var directory = instantiatedCanvas.AddComponent <Directory>();
                directory.Initialize(path, directoryName);
            }

            foreach (var filePath in fileList)
            {
                var fileName  = new FileInfo(filePath).Name;
                var array     = fileName.Split('.');
                var extension = array[array.Length - 1];
                if (!File.CanOpen(extension))
                {
                    continue;
                }

                var instantiatedCanvas = scroll.AddCanvas(fileCanvas.gameObject, fileName);
                instantiatedCanvas.GetComponent <CanvasBehaviourBase>().SetParentScroll(scroll);
                var file = instantiatedCanvas.AddComponent <File>();
                file.Initialize(path, fileName);
            }

            return(true);
        }
Exemple #6
0
 public bool Open(CanvasScroll scroll, CanvasBehaviourBase directoryCanvas, CanvasBehaviourBase fileCanvas)
 {
     return(Open(scroll, directoryCanvas, fileCanvas, DirectoryPath));
 }
Exemple #7
0
 public void SelectCanvas(CanvasBehaviourBase canvas)
 {
     SelectedCanvas = canvas;
 }