Ejemplo n.º 1
0
    void Update()
    {
        if (StartSelectNullCheck)
        {
            StartSelectNullCheck = false;
            EventSystem.current.SetSelectedGameObject(null);
        }
        if (VerticalScrollScript != null)
        {
            ScrollIntoRatio   = VerticalScrollScript.ScrollIntoRatio;
            ScrollIntoInertia = VerticalScrollScript.ScrollIntoInertia;
        }
        if (SetScript == null)
        {
            return;
        }

        if (SetScript.FirstSet || SetScript.MappingMode || SetScript.WindowSituation != 0)
        {
            OperateItemsSetNonInteractable();
            if (SetScript.WindowSituation != 0 && SetScript.FirstSet != true)
            {
                ReturnSelectCheck = true;
            }
        }
        else
        {
            if (SetScript.CurrentryRestore)
            {
                OperateItemsSetSameSaveData();
            }
            else
            {
                OperateItemsSetNormal();
            }

            if (FirstSelectCheck)
            {
                EventSystem.current.SetSelectedGameObject(FirstSelectedMenuItem);
                FirstSelectCheck  = false;
                ReturnSelectCheck = false;
            }
            else if (ReturnSelectCheck)
            {
                if (PrevSelectedGO != null)
                {
                    EventSystem.current.SetSelectedGameObject(PrevSelectedGO);
                }
                else
                {
                    EventSystem.current.SetSelectedGameObject(FirstSelectedMenuItem);
                }
                ReturnSelectCheck = false;
            }
        }
        CurrentSelectedGO = EventSystem.current.currentSelectedGameObject;

        //選択状態の項目の位置がスクロール窓の範囲外になったら常に選択項目が範囲内にあるようにする処理
        if (VerticalScrollScript != null && VerticalScrollScript.UseVerticalScroll &&
            CurrentSelectedGO != null)
        {
            bool ComparisonNotReadyCheck = false;
            if (CurrentSelectedGO.transform.parent.parent.gameObject == MenuItemsGO)
            {
                if (CurrentSelectedGO.transform.parent.GetComponent <UGUIMenuItem>())
                {
                    CurrentItemNum = CurrentSelectedGO.transform.parent.GetComponent <UGUIMenuItem>().MenuNum;
                    if (CurrentItemNum == 0)
                    {
                        FromMostOverCheck = true;
                    }
                    else if (CurrentItemNum == (MenuItemButtonGOsAry.Length - 1))
                    {
                        FromMostUnderCheck = true;
                    }
                    else
                    {
                        FromMostOverCheck  = false;
                        FromMostUnderCheck = false;
                    }
                }
                else
                {
                    ComparisonNotReadyCheck = true;
                }
                if (transform.parent.GetComponent <RectTransform>() != null && ComparisonNotReadyCheck != true)
                {
                    transform.parent.GetComponent <RectTransform>().GetWorldCorners(ScrollRectCorners);
                }
                else
                {
                    ComparisonNotReadyCheck = true;
                }
                if (CurrentSelectedGO.GetComponent <RectTransform>() != null && ComparisonNotReadyCheck != true)
                {
                    CurrentSelectedGO.GetComponent <RectTransform>().GetWorldCorners(CurrentItemCorners);
                }
                else
                {
                    ComparisonNotReadyCheck = true;
                }
            }
            else
            {
                ComparisonNotReadyCheck = true;
                FromMostOverCheck       = false;
                FromMostUnderCheck      = false;
            }
            if (ComparisonNotReadyCheck != true)
            {
                bool CurrentItemOverOutsideCheck  = false;
                bool CurrentItemUnderOutsideCheck = false;
                if (CurrentSelectedGO.transform.parent.GetComponent <UGUIMenuItem>())
                {
                    CurrentItemOverOutsideCheck  = CurrentSelectedGO.transform.parent.GetComponent <UGUIMenuItem>().ScrollOverOutsideCheck;
                    CurrentItemUnderOutsideCheck = CurrentSelectedGO.transform.parent.GetComponent <UGUIMenuItem>().ScrollUnderOutsideCheck;
                }
                if (CurrentItemOverOutsideCheck || CurrentItemUnderOutsideCheck)
                {
                    if (SetScript.MappingMode)
                    {
                        SetScript.EscBehavior();
                    }
                    SetScript.InhibitMappingModeCheck = true;
                }
                if (CurrentItemOverOutsideCheck)
                {
                    if (CurrentItemNum == 0 && FromMostUnderCheck)
                    { //最下から最上へのループ的移動
                        FromMostUnderCheck = false;
                        EndToEndCheck      = true;
                        if (IsInvoking("IntoRectFalse"))
                        {
                            CancelInvoke("IntoRectFalse");
                        }
                        OverIntoRectCheck  = true;
                        UnderIntoRectCheck = false;
                    }
                    if (OverIntoRectCheck != true)
                    {
                        if (VerticalScrollScript.ScrollingNotify() != true) //スクロール中でないなら
                        {
                            if (IsInvoking("IntoRectFalse"))
                            {
                                CancelInvoke("IntoRectFalse");
                            }
                            OverIntoRectCheck  = true;
                            UnderIntoRectCheck = false;
                        }
                        else
                        {
                            if (CurrentItemNum < (MenuItemButtonGOsAry.Length - 1))
                            {
                                EventSystem.current.SetSelectedGameObject(MenuItemButtonGOsAry[CurrentItemNum + 1]);
                            }
                        }
                    }
                }
                else if (CurrentItemUnderOutsideCheck)
                {
                    if (CurrentItemNum == (MenuItemButtonGOsAry.Length - 1) && FromMostOverCheck)
                    { //最上から最下へのループ的移動
                        FromMostOverCheck = false;
                        EndToEndCheck     = true;
                        if (IsInvoking("IntoRectFalse"))
                        {
                            CancelInvoke("IntoRectFalse");
                        }
                        OverIntoRectCheck  = false;
                        UnderIntoRectCheck = true;
                    }
                    if (UnderIntoRectCheck != true)
                    {
                        if (VerticalScrollScript.ScrollingNotify() != true) //スクロール中でないなら
                        {
                            if (IsInvoking("IntoRectFalse"))
                            {
                                CancelInvoke("IntoRectFalse");
                            }
                            OverIntoRectCheck  = false;
                            UnderIntoRectCheck = true;
                        }
                        else
                        {
                            if (CurrentItemNum > 0)
                            {
                                EventSystem.current.SetSelectedGameObject(MenuItemButtonGOsAry[CurrentItemNum - 1]);
                            }
                        }
                    }
                }
                else
                {
                    if (VerticalScrollScript.ScrollingNotify())
                    {
                        VerticalScrollScript.ScrollingCheckFalse();
                        if (OverIntoRectCheck || UnderIntoRectCheck)
                        {
                            Invoke("IntoRectFalse", ScrollIntoInertia);
                        }
                    }
                    EndToEndCheck = false;
                }
            }

            if (OverIntoRectCheck || UnderIntoRectCheck)
            {
                Mapper.MoveDelayCall();
                SetScript.InhibitMappingModeCheck = true;
                if (OverIntoRectCheck)
                {
                    ScrollSpeedValue = (ScrollIntoRatio * 0.1f);
                }
                else if (UnderIntoRectCheck)
                {
                    ScrollSpeedValue = -(ScrollIntoRatio * 0.1f);
                }
                if (EndToEndCheck)
                {
                    if (MenuItemsGO.GetComponent <RectTransform>() != null && transform.parent.GetComponent <RectTransform>())
                    {
                        ScrollSpeedValue = ScrollSpeedValue * (MenuItemsGO.GetComponent <RectTransform>().rect.height / transform.parent.GetComponent <RectTransform>().rect.height) * 1.5f;
                    }
                    else
                    {
                        ScrollSpeedValue = ScrollSpeedValue * 2;
                    }
                }
                VerticalScrollScript.GetComponent <ScrollRect>().verticalNormalizedPosition = VerticalScrollScript.GetComponent <ScrollRect>().verticalNormalizedPosition + ScrollSpeedValue;
            }
        }

        if (SetScript.FirstSet)
        { //FirstSet中にカーソルオンでどこかが選択状態になった場合の挙動
            if (CurrentSelectedGO != null)
            {
                PrevSelectedGO     = CurrentSelectedGO;
                FirstSelectCheck   = false;
                SetScript.FirstSet = false;
            }
            return;
        }

        //無関係な場所をクリックしても非選択状態にならないように
        if (SetScript.WindowSituation == 0)
        {
            if (CurrentSelectedGO != null)
            {
                if (CurrentSelectedGO != this.gameObject)
                {
                    PrevSelectedGO = CurrentSelectedGO;
                }
            }
            else
            {
                if (PrevSelectedGO != null)
                {
                    EventSystem.current.SetSelectedGameObject(PrevSelectedGO);
                }
            }
        }

        if (CurrentSelectedGO != this.gameObject)
        {
            //PrevSelectedMenuItem の更新
            if (PrevSelectedGO != null && SetScript.OperateItemLine != true)
            {
                if (PrevSelectedGO.transform.parent.parent.gameObject.name == "InMapperMenuItems" &&
                    PrevSelectedGO.transform.parent.name.Length == 16 &&
                    PrevSelectedGO.transform.parent.name.IndexOf("MapperMenuItem") == 0)
                {
                    PrevSelectedMenuItem = PrevSelectedGO;
                }
            }
        }
        else
        {
            if (SetScript.OperateItemLine)
            {
                if (PrevSelectedMenuItem == null)
                {
                    if (FirstSelectedMenuItem != null)
                    {
                        PrevSelectedMenuItem = FirstSelectedMenuItem;
                    }
                    else
                    {
                        PrevSelectedMenuItem = transform.parent.Find("InMapperMenuItems/MapperMenuItem00/Button").gameObject;
                    }
                }
                if (PrevSelectedMenuItem == null)
                {
                    if (PrevSelectedGO != null)
                    {
                        EventSystem.current.SetSelectedGameObject(PrevSelectedGO);
                    }
                }
                else
                {
                    EventSystem.current.SetSelectedGameObject(PrevSelectedMenuItem);
                }
            }
            else
            {
                if (OperateItemsAry[0].GetComponent <Button>().interactable)
                {
                    EventSystem.current.SetSelectedGameObject(OperateItemsAry[0]);
                }
                else
                {
                    if (OperateItemsAry[2].GetComponent <Button>().interactable)
                    {
                        EventSystem.current.SetSelectedGameObject(OperateItemsAry[2]);
                    }
                    else
                    {
                        EventSystem.current.SetSelectedGameObject(PrevSelectedGO);
                    }
                }
            }
        }

        if (SetScript.CurrentryRestore)
        {
            if (CurrentSelectedGO == OperateItemsAry[0] ||
                CurrentSelectedGO == OperateItemsAry[1])
            {
                EventSystem.current.SetSelectedGameObject(OperateItemsAry[2]);
            }
        }
    }
Ejemplo n.º 2
0
    void Start()
    {
        if (SetScript == null)
        {
            SetScript = GetComponentInParent <jInputSettings>();
        }
        if (SetScript == null)
        {
            Debug.LogError("[jInput] jInputSettings script is Not Found!!");
        }
        MenuItemButtonGOsAry = new GameObject[SetScript.MenuItemHeadings.Length];
        OperateItemsAry      = new GameObject[4];
        FirstSelectCheck     = true;
        StartSelectNullCheck = true;
        FromMostOverCheck    = false;
        FromMostUnderCheck   = false;
        EndToEndCheck        = false;
        IntoRectFalse();

        if (MenuItemsGO != null)
        {
            for (int i = 0; i < MenuItemButtonGOsAry.Length; i++)
            {
                for (int j = 0; j < MenuItemsGO.transform.childCount; j++)
                {
                    string     TempFindName = null;
                    GameObject TempItem     = MenuItemsGO.transform.GetChild(j).gameObject;
                    if (0 <= i && i <= 9)
                    {
                        TempFindName = "MapperMenuItem0" + i;
                    }
                    else if (i >= 10)
                    {
                        TempFindName = "MapperMenuItem" + i;
                    }
                    if (TempItem.name == TempFindName)
                    {
                        if (TempItem.transform.Find("Button"))
                        {
                            MenuItemButtonGOsAry[i] = TempItem.transform.Find("Button").gameObject;
                        }
                    }
                }
            }
        }
        else
        {
            Debug.LogError("[jInput] Error!! OperateItemsGO is Not Found!!");
        }
        if (MenuItemButtonGOsAry[0] != null)
        {
            FirstSelectedMenuItem = MenuItemButtonGOsAry[0];
        }
        else
        {
            FirstSelectedMenuItem = transform.parent.Find("InMapperMenuItems/MapperMenuItem00/Button").gameObject;
        }
        if (FirstSelectedMenuItem != null)
        {
            PrevSelectedMenuItem = FirstSelectedMenuItem;
        }
        else
        {
            Debug.LogError("[jInput] Error!! Button in MapperMenuItem00 is Not Found!!");
        }

        if (OperateItemsGO != null)
        {
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < OperateItemsGO.transform.childCount; j++)
                {
                    GameObject TempItem = OperateItemsGO.transform.GetChild(j).gameObject;
                    if (TempItem.name == "MapperOperateItem0" + i)
                    {
                        OperateItemsAry[i] = TempItem;
                        break;
                    }
                }
                if (0 <= i && i < 3)
                {
                    if (OperateItemsAry[i] == null)
                    {
                        Debug.LogError("[jInput] Error!! MapperOperateItem0" + i + " is Not Found!!");
                    }
                }
            }
            OperateItemsSetNonInteractable();
        }
        else
        {
            Debug.LogError("[jInput] Error!! OperateItemsGO is Not Found!!");
        }
        if (transform.GetComponentInParent <UGUIMenuVerticalScroll>())
        {
            VerticalScrollScript = transform.GetComponentInParent <UGUIMenuVerticalScroll>();
            VerticalScrollScript.GetComponent <ScrollRect>().verticalNormalizedPosition = 1;
        }
    }
Ejemplo n.º 3
0
    void Start()
    {
        if (SetScript == null)
        {
            SetScript = GetComponentInParent <jInputSettings>();
        }
        if (SetScript == null)
        {
            Debug.LogError("[jInput] jInputSettings script is Not Found!!");
        }
        NameCheck = gameObject.name.IndexOf("MapperMenuItem");
        if (NameCheck != 0 || gameObject.name.Length != 16)
        {
            Debug.LogError("[jInput] Error!! To be necessary MapperMenuItem Object naming 'MapperMenuItem'+ serial number of double figures 00 to 30.");
        }
        else
        {
            MenuNumString = gameObject.name.Substring(gameObject.name.Length - 2, 2);
            MenuNum       = int.Parse(MenuNumString);
        }

        if (AlertMarkGO == null)
        {
            if (transform.Find("AlertMark"))
            {
                AlertMarkGO = transform.Find("AlertMark").gameObject;
            }
        }
        if (AlertMarkGO != null)
        {
            if (AlertMarkGO.GetComponent <Image>())
            {
                ThisAlertMarkBaseColor = AlertMarkGO.GetComponent <Image>().color;
            }
            #if (UNITY_EDITOR)
            if (EditorApplication.isPlaying || EditorApplication.isPaused)
            #endif
            AlertMarkGO.SetActive(false);
        }
        else
        {
            Debug.LogError("[jInput] Error!! AlertMark gameObject in " + this.gameObject.name + " is Not Found!");
        }

        if (ThisButtonGO == null)
        {
            ThisButtonGO = transform.Find("Button").gameObject;
        }
        if (ThisButtonGO == null)
        {
            Debug.LogError("[jInput] Error!! Button in " + this.gameObject.name + " is Not Found!");
        }
        else
        {
            if (ThisButtonGO.transform.Find("Text"))
            {
                if (ThisButtonGO.transform.Find("Text").GetComponent <Text>())
                {
                    InputText = ThisButtonGO.transform.Find("Text").GetComponent <Text>();
                }
                if (ThisButtonGO.transform.Find("Text").GetComponent <UGUIButtonTextColor>())
                {
                    ButtonTextColorScript = ThisButtonGO.transform.Find("Text").GetComponent <UGUIButtonTextColor>();
                }
            }
            if (InputText == null)
            {
                Debug.LogError("[jInput] Error!! InputText in " + this.gameObject.name + " is Not Found!");
            }
            if (ThisButtonGO.GetComponent <Image>())
            {
                ThisButtonImageCpnt = ThisButtonGO.GetComponent <Image>();
            }
            if (ThisButtonImageCpnt == null)
            {
                Debug.LogError("[jInput] Error!! Image Component with Button in " + this.gameObject.name + " is Not Found!");
            }
            else
            {
                ThisButtonBaseColor = ThisButtonImageCpnt.color;
            }
        }
        if (transform.Find("HeadingText") != null && transform.Find("HeadingText").GetComponent <Text>() != null)
        {
            ThisHeadingTextCpnt  = transform.Find("HeadingText").GetComponent <Text>();
            ThisHeadingBaseColor = ThisHeadingTextCpnt.color;
        }
        if (ThisHeadingTextCpnt == null)
        {
            Debug.LogError("[jInput] Error!! ThisHeadingTextCpnt in " + this.gameObject.name + " is Not Found!");
        }
        if (VerticalScrollScript == null && GetComponentInParent <UGUIMenuVerticalScroll>())
        {
            VerticalScrollScript = GetComponentInParent <UGUIMenuVerticalScroll>();
        }
        if (VerticalScrollScript != null && VerticalScrollScript.UseVerticalScroll)
        {
            UseScrollCheck      = true;
            ScrollRangeRectTrns = VerticalScrollScript.GetComponent <RectTransform>();
        }
        else
        {
            UseScrollCheck = false;
        }

        #if (UNITY_EDITOR)
        if (EditorApplication.isPlaying || EditorApplication.isPaused)
        {
            #endif
        HeadingTextPour();
        //スクロール範囲外で透明~半透明のitemがキー設定窓に移行した瞬間一瞬表示されてしまうので透明にしておく
        if (UseScrollCheck)
        {
            if (ThisButtonImageCpnt != null)
            {
                ThisButtonImageCpnt.color = Color.clear;
            }
            if (ThisHeadingTextCpnt != null)
            {
                ThisHeadingTextCpnt.color = Color.clear;
            }
            if (InputText != null)
            {
                InputText.color = Color.clear;
            }
        }
            #if (UNITY_EDITOR)
    }
        #endif
    }