Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Loading image from Assets via script doesn't work after build

Discussion in 'VR' started by Sokratisk, Dec 5, 2022.

  1. Sokratisk

    Sokratisk

    Joined:
    Feb 13, 2020
    Posts:
    3
    So I have this VR app with a canvas in the world.

    I have a raw image inside the canvas and when activated I load a picture from Streaming Assets, this works great in the engine but when I build it and run it in Oculus 2, the pictures just wont load, like nothing is happening.

    I have a similar code for some text and this works great.

    Here's my code on how I load the image.

    Code (CSharp):
    1.     public void ImagesButton()
    2.     {
    3.         try
    4.         {
    5.             string pathToPictures = Application.streamingAssetsPath + "/" + GetName() + "/Pictures/";
    6.             imagesFiles = Directory.GetFiles(pathToPictures, "*.jpg", SearchOption.AllDirectories);
    7.             IEnumerator coroutine = LoadImageIE(imagesFiles[0]);
    8.             StartCoroutine(coroutine);
    9.         }
    10.         catch
    11.         {
    12.             Debug.Log("no images folder");
    13.         }
    14.        
    15.         currentImage = 0; //reset flag
    16.     }
    Code (CSharp):
    1.     private IEnumerator LoadImageIE(string imagePath)
    2.     {
    3.         UnityWebRequest request = UnityWebRequestTexture.GetTexture(imagePath);
    4.  
    5.         yield return request.SendWebRequest();
    6.  
    7.         try
    8.         {
    9.             canvasForDisplays.transform.GetChild(2).gameObject.transform.GetChild(0).gameObject.GetComponent<RawImage>().texture = DownloadHandlerTexture.GetContent(request);
    10.              canvasForDisplays.transform.GetChild(2).gameObject.SetActive(true);
    11.         }
    12.         catch
    13.         {
    14.             Debug.Log("no image file");
    15.         }
    16.     }
    In the image are the settings of the canvas and the raw image object.
    unity.png
     
  2. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    Can you post a log of the failure?
     
  3. Sokratisk

    Sokratisk

    Joined:
    Feb 13, 2020
    Posts:
    3
    I am not sure on how to run it on debug mode on oculus to get a log
     
  4. happynewyeasrz

    happynewyeasrz

    Joined:
    Dec 7, 2022
    Posts:
    1
    The beginning of another year is generally a reason for festivity. Individuals all around the world participate in celebrations to stamp the event. One of the most famous ways of celebrating is by sharing Blissful New Year pictures with loved ones.happy new year gifts On the off chance that you're searching for some Cheerful New Year 2023 pictures to share, we take care of you. We've assembled an assortment of the best Blissful New Year 2023 photographs from around the web. So whether you're searching for something bubbly or essentially need to share some seasonal joy, make certain to look at our assortment of Cheerful New Year pictures.
     
  5. Sokratisk

    Sokratisk

    Joined:
    Feb 13, 2020
    Posts:
    3
    So I moved the pictures out of "Pictures" folder and it works, no idea why...