It works perfectly inside of Unity, but if i want to build and run( .exe or in the webplayer), things that would normally use those assets become white. Do you guys happen to have encountered this error? Thanks a lot for taking your time to help me!
EDIT : Materials that don’t have textures that change over time don’t encounter this issue, only the objects that use this material for which I change the texture every now and then.
EDIT : I usually export in the main folder of the project, is there a particular place where you have to export?
I always make a Build folder at the same level as Assets, and build into there.
Can’t you put your PNG’s into the Resources folder? Then you don’t need to prepend a path. Because that’s how Resources works: it loads from the Resources folder. If you want to load as you do here, you may instead want to use WWW and a file:// path, but that will be relative to a) Assets in the Editor, or b) the program_Data folder when built (runtime). And the PNG’s don’t auto-copy to your build _Data folder either. For that I use a script like this (put into Editor folder):
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System;
using System.IO;
using System.Collections.Generic;
public static class PostBuild
{
[PostProcessBuild]
static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
{
string path = Path.GetDirectoryName (pathToBuiltProject);
string exe = Path.GetFileNameWithoutExtension (pathToBuiltProject);
FileUtil.CopyFileOrDirectory ("Assets/Textures/colors.png", path+"/"+exe+"_Data/colors.png");
}
}