学习笔记 - yty/yty.github.io GitHub Wiki

Unity自身

如果为Rtt赋值

1这是最早摸索的方法,很笨

  public RenderTexture rt0;
  public Texture2D initTex = new Texture2D(rt0.width, rt0.height, TextureFormat.ARGB32, false);

        for (int i = 0; i < rt0.width; i++)
        {
            for (int j = 0; j < rt0.height; j++)
            {
                initTex.SetPixel(i, j, new Color(0.5f, 0.5f, 0.5f, 0.5f));
            }
        }
        initTex.Apply();

        Graphics.Blit(initTex, rt0);

2后来模式的方法,正规

RenderTexture.active = _bufferPrev;
GL.Clear(true, true, Color.grey);
RenderTexture.active = null;

VR

Vr在频繁切换vr模式和非vr模式时steam总为空的问题

需要给所有的SteamVR.instanc加!=null的判断,并且不能只是设置VRSettings.enabled,还需要设置同步设置SteamVR.enabled。

如何获取人是否带了vr头盔的实现

用自带的事件感觉很不好用,最后还是用的实时获取。 SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceUserInteractionStarted).Listen(OnUserStartedChanged); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceUserInteractionEnded).Listen(OnUserEndedChanged);