Exemplo n.º 1
0
 private void SetNavigationOfThePageItem(Transform trans)
 {
     for (int i = 0; i < trans.childCount; i++)
     {
         var mySelectable = trans.GetChild(i).GetComponent <MySelectable>();
         if (Direction == E_Direct.Horizontal)
         {
             MySelectable left  = null;
             MySelectable right = null;
             if (i > 0)
             {
                 left = trans.GetChild(i - 1).GetComponent <MySelectable>();
             }
             if (i < trans.childCount - 1)
             {
                 right = trans.GetChild(i + 1).GetComponent <MySelectable>();
             }
             Util.SetNavigation(mySelectable, null, null, left, right);
         }
         else
         {
             MySelectable up   = null;
             MySelectable down = null;
             if (i > 0)
             {
                 up = trans.GetChild(i - 1).GetComponent <MySelectable>();
             }
             if (i < trans.childCount - 1)
             {
                 down = trans.GetChild(i + 1).GetComponent <MySelectable>();
             }
             Util.SetNavigation(mySelectable, up, down, null, null);
         }
     }
 }
    private void Awake()
    {
        selectable = GetComponent <MySelectable>();

        selectable.onSelect   += OnSelect;
        selectable.onNormal   += OnNormal;
        selectable.onInactive += OnNormal;
        selectable.onHide     += OnNormal;

        var sharedmaterials = new List <Material>();

        objectRenderer.GetSharedMaterials(sharedmaterials);

        foreach (var mat in sharedmaterials)
        {
            mat.SetTexture("_EmissionMap", Texture2D.blackTexture);
            mat.EnableKeyword("_EMISSION");
        }


        Assert.IsNotNull(selectable);
        Assert.IsNotNull(objectRenderer);
        if (highlightTex == null)
        {
            highlightTex = Texture2D.whiteTexture;                          // dummy white texture
        }
        //Assert.IsNotNull(highlightTex);
    }
    public bool Register(MySelectable selectable)
    {
        var reg = registeredSelectables.Add(selectable);

        selectable.DoSetState(initialState);
        return(reg);
    }
Exemplo n.º 4
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     MySelectable.DeselectAll(new BaseEventData(EventSystem.current));
     selectionBoxImage.gameObject.SetActive(true);
     startPosition = eventData.position;
     selectionRect = new Rect();
 }
Exemplo n.º 5
0
    void Awake()
    {
        Signals.Get <FreeExplorationSignal>().AddListener(SetFreeExploration);
        selectable = GetComponent <MySelectable>();
        screenspacePOIContainer = FindObjectOfType <ScreenspacePOIContainer>();

        Assert.IsNotNull(screenspacePOIContainer);
    }
Exemplo n.º 6
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     if (!Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl))
     {
         MySelectable.DeselectAll(new BaseEventData(EventSystem.current));
     }
     selectionBoxImage.gameObject.SetActive(true);
     startPosition = eventData.position;
     selectionRect = new Rect();
 }
Exemplo n.º 7
0
    /// <summary>
    /// 设置导航模式
    /// </summary>
    /// <param name="mySelectable"></param>
    /// <param name="mode"></param>
    public static void SetNavigationMode(MySelectable mySelectable, Navigation.Mode mode)
    {
        if (!mySelectable)
        {
            return;
        }
        var navigation = mySelectable.navigation;

        navigation.mode         = mode;
        mySelectable.navigation = navigation;
    }
Exemplo n.º 8
0
    /// <summary>
    /// 设置 down 键导航
    /// </summary>
    /// <param name="mySelectable"></param>
    /// <param name="down"></param>
    public static void SetDownNavigation(MySelectable mySelectable, MySelectable down)
    {
        if (!mySelectable)
        {
            return;
        }
        var navigation = mySelectable.navigation;

        navigation.mode         = Navigation.Mode.Explicit;
        navigation.selectOnDown = down;
        mySelectable.navigation = navigation;
    }
Exemplo n.º 9
0
    /// <summary>
    /// 设置 left 键导航
    /// </summary>
    /// <param name="mySelectable"></param>
    /// <param name="left"></param>
    public static void SetLeftNavigation(MySelectable mySelectable, MySelectable left)
    {
        if (!mySelectable)
        {
            return;
        }
        var navigation = mySelectable.navigation;

        navigation.mode         = Navigation.Mode.Explicit;
        navigation.selectOnLeft = left;
        mySelectable.navigation = navigation;
    }
Exemplo n.º 10
0
    /// <summary>
    /// 设置 right 键导航
    /// </summary>
    /// <param name="mySelectable"></param>
    /// <param name="right"></param>
    public static void SetRightNavigation(MySelectable mySelectable, MySelectable right)
    {
        if (!mySelectable)
        {
            return;
        }
        var navigation = mySelectable.navigation;

        navigation.mode          = Navigation.Mode.Explicit;
        navigation.selectOnRight = right;
        mySelectable.navigation  = navigation;
    }
Exemplo n.º 11
0
    /// <summary>
    /// 设置 up 键导航
    /// </summary>
    /// <param name="mySelectable"></param>
    /// <param name="up"></param>
    public static void SetUpNavigation(MySelectable mySelectable, MySelectable up)
    {
        if (!mySelectable)
        {
            return;
        }
        var navigation = mySelectable.navigation;

        navigation.mode         = Navigation.Mode.Explicit;
        navigation.selectOnUp   = up;
        mySelectable.navigation = navigation;
    }
    private void Awake()
    {
        originalParent = transform.parent;

        selectable = GetComponent <MySelectable>();

        selectable.onSelect   += OnSelect;
        selectable.onNormal   += OnNormal;
        selectable.onInactive += OnInactive;

        //childrenRenderer = GetComponentsInChildren<Renderer>();
        childrenRenderer = GetComponentsInChildren <Renderer>();//.ToList().Where(t => t.transform.GetComponent<KeepTransparent>() == null).ToArray();//material.GetFloat("") != (int)StandardShaderUtils.BlendMode.Fade).ToArray();
    }
Exemplo n.º 13
0
    private void ChangeSelectedObject(int pos)
    {
        if (selected != null)
        {
            selected.OnMoveAway();
        }

        selected    = childSelectableObjects[pos];
        selectedNum = pos;
        if (selected != null)
        {
            selected.OnMoveTo();
        }
    }
Exemplo n.º 14
0
    /// <summary>
    /// 设置导航
    /// </summary>
    /// <param name="mySelectable"></param>
    /// <param name="up"></param>
    /// <param name="down"></param>
    /// <param name="left"></param>
    /// <param name="right"></param>
    public static void SetNavigation(MySelectable mySelectable, MySelectable up, MySelectable down, MySelectable left, MySelectable right)
    {
        if (!mySelectable)
        {
            return;
        }
        var navigation = mySelectable.navigation;

        navigation.mode          = Navigation.Mode.Explicit;
        navigation.selectOnUp    = up;
        navigation.selectOnDown  = down;
        navigation.selectOnLeft  = left;
        navigation.selectOnRight = right;
        mySelectable.navigation  = navigation;
    }
Exemplo n.º 15
0
    private void ChangeSelectedObject(int pos)
    {
        if (selected != null)
        {
            selected.OnMoveAway();
        }
        if (selectableObjects.Length > 0)
        {
            selected    = selectableObjects[pos];
            selectedNum = pos;
        }

        if (selected != null)
        {
            selected.OnMoveTo();
        }
    }
    public void Select(MySelectable selectable)
    {
        foreach (var s in registeredSelectables)
        {
            if (s != selectable)
            {
                s.DoSetState(MySelectable.SelectableState.Inactive);
            }
        }

        if (selectable != null)
        {
            selectable.DoSetState(MySelectable.SelectableState.Selected);
        }

        initialState = MySelectable.SelectableState.Inactive;
    }
Exemplo n.º 17
0
    private void Awake()
    {
        selectable = GetComponent <MySelectable>();
        if (selectable == null)
        {
            selectable = GetComponentInParent <MySelectable>();
        }

        system = GetComponent <SelectableSystem>();

        selectable.onSelect   += OnSelectableStateChange;
        selectable.onNormal   += OnSelectableStateChange;
        selectable.onInactive += OnSelectableStateChange;
        selectable.onHide     += OnSelectableStateChange;

        system.initialState = MySelectable.SelectableState.Hidden;

        Signals.Get <ShowSelectableSubsystemsSignal>().AddListener(OnShowSignal);
    }
Exemplo n.º 18
0
    public void setToggle(MySelectable setMe)
    {
        int  ID       = setMe.GetInstanceID();
        bool turnMeOn = !setMe.Selected;

        Debug.Log($"MyToggleGroup toggled {setMe.gameObject.name}, turning it on {turnMeOn}\n");
        foreach (MySelectable button in toggles)
        {
            if (button.GetInstanceID() == ID)
            {
                button.Selected = turnMeOn;
                Debug.Log($"{button.gameObject.name} selected {turnMeOn}\n");
            }
            else if (turnMeOn)
            {
                Debug.Log($"{button.gameObject.name} UNselected\n");
                button.Selected = false;
            }
        }
    }
Exemplo n.º 19
0
 public void OnSceneChange(Scene scene, LoadSceneMode mode)
 {
     selected = null;
 }
 public bool Unregister(MySelectable selectable)
 {
     return(registeredSelectables.Remove(selectable));
 }