Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[bug?] texture assignment + SetEnabled = missing texture

Discussion in 'General Graphics' started by DistortionFactor, Dec 22, 2015.

  1. DistortionFactor

    DistortionFactor

    Joined:
    Nov 23, 2015
    Posts:
    8
    I am trying to dynamically assign a texture to an object, and the object is initially hidden. My problem is that the texture does not show, even though debugging says it was assigned correctly. If I start the game with my object enabled (via checkbox in Inspector), the texture successfully appears.

    Why does the texture appear fine if my object is initially enabled? Is this a bug? How can I work around this? I need to assign the texture at run-time, and I need the object to be hidden initially.

    I am using the Unlit Textured shader on a sphere primitive mesh.

    I am using Unity 5.3 on Windows 8.1 x64. The editor shows DX11 is active.
     
  2. ramy_d

    ramy_d

    Joined:
    Oct 12, 2014
    Posts:
    19
    try disabling and enabling the renderer component instead of the entire gameobject.
     
  3. DistortionFactor

    DistortionFactor

    Joined:
    Nov 23, 2015
    Posts:
    8
    @ramy_d : Good idea, worth a shot. I wonder if the underlying graphics drivers are the issue and the rendering code needs to be active before the texture assignment. Initializing with the Renderer component disabled may have the same impact as initializing with the entire GameObject disabled.

    I got what I wanted by using the camera's cullingMask and assigning only one of my scene's layer groups to be seen by the camera at a time.