Ok, I figured out the last bits. For the sake another newbie comes this way I will post the solution here.
Btw. the step by step tutorials are a great help how to get a grasp on how things are setup in nGUI. Too bad I was like 50 times on the nGUI page and never noticed them. I just though they were another unity web player examples. It would save me a lot of pain and make a much better start impression if I knew from the start that they exist.
- So I used the NGUI > Open the UI Wizard this time, it creates the UI Root > Camera etc. hierarchy and voila no need to set up camera culling masks and layers etc.
- Also the jpg and png needs to be power of two to work with the 'Make Pixel Perfect' correctly. Otherwise they were still blurry as they were stretched. Maybe it's enough to specify the exact size when creating the Texture2D? Does anybody know a different solution then preparing the images in power of two dimensions?
- To avoid white edges on the result, the jpgs must be prepared correctly. One way how to do it is to use the free Flaming Pear plugins, specifically Solidify. As a side effect they compress much better than with the white background.
Then I use this code to load and display the art pixel perfect, in best quality, with smallest install and download size. The only cost of this method is vRAM cost, but it my game I display only a couple of these at once.
void Start () {
//load the prepared image data
TextAsset colortxt;
TextAsset alphatxt;
Texture2D colorjpg
= new Texture2D
(4,
4); Texture2D alphapng
= new Texture2D
(4,
4);
colortxt = Resources.Load("1024cloak01") as TextAsset;
alphatxt = Resources.Load ("1024cloak01A") as TextAsset;
colorjpg.LoadImage(colortxt.bytes);
alphapng.LoadImage(alphatxt.bytes);
//load the prepared Shader asset
Shader rgbplusa;
rgbplusa = Shader.Find("RGBplusA");
//use NGUI to display the image pixel-perfect, make use of the camera setup created with NGUI > Open the UI Wizard
UITexture perfect = NGUITools.AddWidget<UITexture>(GameObject.Find ("Panel"));
perfect
.material = new Material
(rgbplusa
); perfect.material.SetTexture("_MainTex", colorjpg);
perfect.material.SetTexture("_Mask", alphapng);
perfect.MakePixelPerfect();
}