Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Loading jpg textures works until i put it into ARCore project...

Discussion in 'ARCore' started by bryancolvindev, Nov 4, 2017.

  1. bryancolvindev

    bryancolvindev

    Joined:
    Nov 4, 2017
    Posts:
    1
    I have a test where I'm just roughly loading in a new texture to a material, and i can load up a new texture on update or a much slower timer and it works great!

    UNTIL I try it in ARCore HelloAR example.

    This code works in a separate project that has nothing to do with ARCore / HelloAR example.
    Code (csharp):
    1.  
    2.         string filePath = "/storage/emulated/0/DCIM/test/media/Testjpg/Clip0014.00"+_frameID+".jpg";
    3.  
    4.         if (System.IO.File.Exists (filePath))
    5.         {
    6.             //this is just a graphical Debug.Log I made for runtime
    7.             updateLogText ("file exists filePath["+filePath+"]");
    8.  
    9.  
    10.  
    11.  
    12.  
    13.  
    14.             if (_currentMainTexture != null) {
    15.                 Texture2D.DestroyImmediate(_currentMainTexture, true);
    16.             }
    17.  
    18.  
    19.             var bytes = System.IO.File.ReadAllBytes(filePath);
    20.             _currentMainTexture = new Texture2D(1,1);
    21.             _currentMainTexture.LoadImage(bytes);
    22.             frontPlane.mainTexture = _currentMainTexture;
    23.  
    24.  
    25.             _frameID++;
    26.         }
    27.         else
    28.         {
    29.             updateLogText("nope! filePath["+filePath+"]");
    30.         }
    31.  
    32.  
    33.  

    I can create a bunch of 3d objects that share that _currentMainTexture and they all update regardless of where they are.


    I tried just taking that same concept/code into the HelloAR project. So I added planes with that specific material thats being updated TO the andy prefab and applied to all prefabs. But in this variation it just stays a grey flat plane. No graphic being loaded in like the same exact code did in the OTHER project.

    upload_2017-11-3_18-48-59.png




    My log text is showing that the file exists and should be updating the material, but alas it stays grey..

    This seems like either I need to learn something about how unity c# scope works, or there's some render settings that change the way this is functioning....


    Can any one point me in the right direction? Much appreciated!






    Update:
    I even copied the andy prefab and materials into the project that DOES work, and it does infact update in that project. So there's again something about scope, or render settings I'm not understanding...

    Thanks in advance for any pointers!