VR环形、弧形菜单当处于视野一边时,前面的元素显示正常,但是处于另一边时显示则是透明的

      VR环形、弧形菜单在开发中经常用到,当处于视野一边时,前面的元素显示正常,但是处于另一边时显示则是透明的。这是由于Unity对场景对象渲染机制是采用由上到下,由外到里的顺序。所以当我们的UI做好了后,下面子元素的顺序就确定了,导致以上现象的发生。

      避免这种现象的方法也很简单,就是先判断UI菜单中心位置是位于玩家的左边还是右边,判断完毕再根据具体情况来确定子对象的顺序。下面上代码:

/// <summary>
        /// 改变指定游戏对象下面的子对象顺序
        /// </summary>
        /// <param name="Objs">指定对象的子对象数组</param>
        public static void ChangeChildrenOrder(GameObject[] Objs)
        {
            if (Objs != null && Objs.Length > 0)
            {
                for (int i = 0; i < Objs.Length; i++)
                {
                    Objs[i].transform.SetSiblingIndex(Objs.Length - 1 - i);
                }
            }
        }

之所以用静态方法,是因为我把这个方法作为了一个公用的工具方法。

2016.12.08更新的1.8版: The only true curved user interface system on asset store. Based on uGUI canvas for best compatibility. Interact with your curved canvas using ✔ Mouse ✔ Gaze ✔ Vive Controllers ✔ Oculus Touch ✔ Daydream Controller +Your own control method. Just pass Ray for input direction and a Bool for button state to CurvedUI Input Module and it will handle the rest. All with 10-seconds setup. An all-in-one VR interface package designed for the new Unity GUI system. Bends the Canvas in world space, allowing the player to view and interact with it from any angle. Create intricate designs, while still using the same uGUI workflow you're used to! Enrich your VR project with UI that will fully immerse your players. Get that Minority Report feel with curved, interactive screens. Features ✔ Easy set-up - takes less than 10 seconds! ✔ 180 degree Cylindrical mapping to wrap your interface around the player. ✔ Ring mapping to instantly create circular shapes from ordinary assets. ✔ Semisphere mapping for that space helmet feel. ✔ Perfect for Rift, GearVR, Vive, Cardboard and any other VR headset. ✔ Great in 2D ✔ Out-of-the-box Gaze Controller. ✔ World Space Mouse Controller included. ✔ Ray Controller for all your handheld pointing device needs. ✔ Dedicated Vive support. ✔ Dedicated Oculus Touch support. ✔ Fully interactive from any angle. ✔ Optimized to reduce poly count. ✔ Works on mobile. ✔ Works in Unity Personal Edition. ✔ Comes with a broad selection of small code snippets to let you get the most out of added functionalities.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值