Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by iCreatio · Nov 22, 2016 at 11:42 AM · scripting problemtexturetexture2dresources.loadterraindata

Resources.Load() don't loads texture in standalone build, when in unityeditor it does

Hello everyone, I have a problem with my project, when I built a .exe for standalone game it works different than in unityeditor. In unity editor it works as it have to, it loads all textures correctly, but in standalone build it don't work correctly.

Application: Map browser - creating a map from lots of .JPGs witch are sorted by speciffed name. Creating a terrain, creating terraindata with loaded texture, in unity editor it works perfectly, all textures are at thier places, but in standalone build some textures are ok, but almost half of them are at wrong places and some of them are disorted.

My question is :why Resources.Load() loads wrong texture in .exe standalone, when in unityeditor it works great?? In unity editor it loads correct texture, but in standalone game it often loads a texture even from a different folder !! ( folders are in resources folder) For example: Resources/xxx/xxxyyyy​;

Resources/zzz/zzzcccc; Resources/zzz/zzzkkk​; where xxx and zzz are folders name and a part of texture file name which is in this folder, xxxyyyy, zzzcccc and zzzkkk are textures names

Code:

 for (int i = 0; i < ilosc; i++) {
             Terrain_data_list.Add (new List<TerrainData> ());
             Terrains_list.Add (new List<GameObject> ());
             for (int j = 0; j < ilosc *1.5f; j++) {
          
                Terrain_data_list[i].Add ( new TerrainData());
                 Terrain_data_list[i][j].heightmapResolution = 1;
                 Terrain_data_list[i][j].size = new Vector3 (15, 1, 15);
                 Terrain_data_list[i][j].baseMapResolution =256;
                 SplatPrototype[] tekstura= new SplatPrototype [1];
                 tekstura [0] = new SplatPrototype ();
                 string path = kamera_sterowanie.skalowanie + @"/" + kamera_sterowanie.skalowanie + indeks_na_tekst(Oblicz_indeks(poczatek) + j + i * ilosc_kolumn);
  
                 tekstura [0].texture = Resources.Load (path) as Texture2D;
              
                 Terrain_data_list[i][j].splatPrototypes = tekstura;
  
                 Terrains_list[i].Add(new GameObject("teren "+i.ToString()+"x"+j.ToString()));
  
                 Terrains_list[i][j].AddComponent<Terrain>();
                 Terrains_list[i][j].gameObject.GetComponent<Terrain>().terrainData = Terrain_data_list[i][j];
              
                 Terrains_list[i][j].transform.position = new Vector3 (-ilosc/2*Rozmiar + j*Rozmiar, wysokosc_terenu, -ilosc/2*Rozmiar + i*Rozmiar);
              
             }
  
         }

where function Oblicz_indeks() calculates which file ( part of it's name) should be loaded and indeks_na_tekst() converts file index (name) to string. Kamera_sterowanie_skalowanie is a name of a direcotry where texture is and its first letters of texture name, for example: i have texture named xxxyyyy which is in directory xxx, where xxx is scale of the map and yyyy is a name which determines the location of texture (map fragment)(in latitude and longitude coordinates)

in a logfile i have a message: failed to get pixels of splat texture.

Im changed texture type to advenced and then checked the parmameter: Write/Read enabled, but Now the textures are just white and in logfile is message: TerrainData is missing splat texture 0.

I have created a delvelop build and attached it to visal studio what i have discovered is that a name (path) to the file that i want to load is correct, but unity don't find it and the result is NULL. Maybe unity trying to find it in wrong Resources folder or for some reason unity can't create a texture from a loaded file, but i think it shouldn't be null in that case? How can I get the path of resources folder that Im trying to load textures from? Soo the problem is in Resources.Load().

After use Application.dataPath Im know the resources folder is in applicationdata folder, but i cant look inside that, beacuse its a .asset file, and i can't examine a textures.

Strage is that it have loaded a textures (wrong and disorted, but anyway loaded it) but after i changed textture type to advenced and enabled Read/Write, application don't load (find?) the textures. In unityeditor it works great but in build it can't find/load the textures.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hexagonius · Nov 22, 2016 at 09:23 PM 0
Share

can you post a result of the whole path creation process? the string passed to load

avatar image iCreatio · Nov 24, 2016 at 03:16 PM 0
Share

Path is ok, the string named path which I put to Resources.Load() is : "500/50000123A011" I have a folder "500" in Resources folder, and in this folder (500) there is a file 50000123A011.png and its correct file i want to load. After use of Resources.Load(path), where path string is correct I get null as a result

avatar image iCreatio · Dec 01, 2016 at 09:08 AM 0
Share

UPTADED

I have loaded textures by creating it from bytes loaded from a .JPG file:

 sciezka2 = Application.dataPath;
                     string sciezka = kamera_sterowanie.skalowanie + @"\" + kamera_sterowanie.skalowanie + indeks_na_tekst(Oblicz_indeks(poczatek) + j + i * ilosc_kolumn);
                     byte[] dane_z_pliku;
                     //tekstura [0].texture = Resources.Load (sciezka) as Texture2D;
                     if (File.Exists(sciezka2 + "/Resources/" + sciezka + ".JPG"))
                     {
                         dane_z_pliku = File.ReadAllBytes(sciezka2 + "/Resources/" + sciezka + ".JPG");
                         tekstura[0].texture = new Texture2D(2, 2);
                         tekstura[0].texture.LoadImage(dane_z_pliku);
                     }
                     else if (File.Exists(sciezka2 + "/Resources/pusty.JPG"))
                     {
                         dane_z_pliku = File.ReadAllBytes(sciezka2 + "/Resources/pusty.JPG");
                         tekstura[0].texture = new Texture2D(2, 2);
                         tekstura[0].texture.LoadImage(dane_z_pliku);
                     }
                     Debug.Log("Loading texture: " + sciezka + "   textura: ", tekstura[0].texture);
                  
                     Dane_terenu_wiersze[i][j].splatPrototypes = tekstura;
      
                     Teren_wiersze[i].Add(new GameObject("teren "+i.ToString()+"x"+j.ToString()));
      
                     Teren_wiersze[i][j].AddComponent<Terrain>();
                     Teren_wiersze[i][j].gameObject.GetComponent<Terrain>().terrainData = Dane_terenu_wiersze[i][j];
                  
                     Teren_wiersze[i][j].transform.position = new Vector3 (-ilosc/2*Rozmiar + j*Rozmiar, wysokosc_terenu, -ilosc/2*Rozmiar + i*Rozmiar);

Anyway its still not solved, and im having the same problem when trying to load terraindata..

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Eric5h5 · Dec 01, 2016 at 12:55 PM

Presumably you have >4GB of data, which isn't supported in builds with Resources.Load, since there's no actual Resources folder as such in that case, but everything is combined into a file. (Using 64 bit doesn't help.) Use AssetBundles instead.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ZhengzhongSun · Jul 01, 2019 at 01:35 AM 0
Share

So 4GB is the maximum resources limitation in Unity? Is it a personal test results or Unity claim it in documents? Thank you!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

animating terrain texture question 1 Answer

Why the gui texture is not in the middle of the screen and how can i change the texture size ? 1 Answer

SetPixels32 called with invalid number if pixels in the array 0 Answers

Resources.Load Problem 1 Answer

Texture2D Array Appears Grainy 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges