Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Darkness on January 15, 2014, 03:37:29 AM
-
I'm getting into adding my character's model into a window so that the player can see what she looks like in gear. Much like how it's done in WoW. How is this done? I tried looking it up, but I'm not sure what it's called. My UI is 2D at the moment, but I figure there should be a way to add a 3D object to a window.
Any assistance would be greatly appreciated.
-
NGUI is just using Unity game objects, so you may be able to do that. Try adding Unity mesh and render components to the NGUI element you want to contain the object (you can use an empty widget). Or write a simple bit of code to position the 3D object at the 2D component's location.
-
Yeah just position the 3D model between your 2D panel and the camera
-
I would set up an off-screen camera rendering to a render texture, and would then draw this render texture using UITexture as any other NGUI widget.
-
*EDIT:*
Alright, I got the render to texture to work. However, what do I need to do with materials and shaders? I tried to change the unlit/transparent color shader that was attached, because my model is transparent and doesn't show up correctly. What is the point of the material? Does changing this require a material? I won't play with it until anymore until I find out more. Messing around with UITexture keeps messing things up, so I need to know more about it.
Either way, works great as far as getting the image in the right spot and all that. Took all of 10 minutes. Gotta love that. :)
-
Setting a material instead of a shader just gives you more flexibility, in case there is more than one texture that needs to be used (like a bump map for example).
-
Setting a material instead of a shader just gives you more flexibility, in case there is more than one texture that needs to be used (like a bump map for example).
I figured as much. However, it keeps giving me an error. It won't allow for any shader to be added. Only the unlit ones that you include work. Even with my own material. My character needs to be lit at all times and there aren't any shaders that work and they have to have Softclip as well. Any idea how I can fix this? My character is simply transparent and I can't do anything about it.
-
Which shader are you referring to? Unity can't render things to a render texture properly that use textures with alpha in them. It's a well known issue with Unity that was never fixed. Even if you're using a solid shader, if the texture happens to have an alpha channel, and if the channel is not used, it still writes the alpha to the render texture, thus messing everything up.
-
Which shader are you referring to? Unity can't render things to a render texture properly that use textures with alpha in them. It's a well known issue with Unity that was never fixed. Even if you're using a solid shader, if the texture happens to have an alpha channel, and if the channel is not used, it still writes the alpha to the render texture, thus messing everything up.
The shader that comes with NGUI. It's called Unlit/Premultiplied Colored (Softclip). This is the closest I can get having a rendered texture that is not transparent. I've tried other shaders and they just make everything look strange. Either way, when I try any other shaders it gives an error and says "softclip must be enabled" or something like that. Not sure how to fix it and if it's an NGUI problem or not.
-
"Unlit/Premultiplied Colored (Soft Clip)" shader is meant for clipped panels. You shouldn't be choosing it yourself. NGUI automatically chooses it when needed. "Unlit/Premultiplied Colored" shader should be used instead.
-
"Unlit/Premultiplied Colored (Soft Clip)" shader is meant for clipped panels. You shouldn't be choosing it yourself. NGUI automatically chooses it when needed. "Unlit/Premultiplied Colored" shader should be used instead.
That's the thing, though. The others give an error when used. Not sure why, but they do. So I can't even choose many shaders that actually work. The error says it must use Softclip. Is that something to do with the way NGUI handles these things?
-
If you get an error then you likely moved the shaders from their default location inside the Resources folder. NGUI can't load shaders that aren't in the Resources folder.
-
If you get an error then you likely moved the shaders from their default location inside the Resources folder. NGUI can't load shaders that aren't in the Resources folder.
Hey, AM. I haven't been able to tackle this issue until today, but I looked at the location of those shaders and they're in the correct folder. I even deleted the NGUI directory and imported it again and got the same problem. I used all of the shaders in the folder and only the transparent ones work, even though all of them are in the folder. The error isn't fixed. Here it is again.
Unlit/Texture doesn't have a clipped shader version for SoftClip
UnityEngine.Debug:LogError(Object)
UIDrawCall:CreateMaterial() (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:310)
UIDrawCall:RebuildMaterial() (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:325)
UIDrawCall:UpdateMaterials() (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:347)
UIDrawCall:Set(BetterList`1, BetterList`1, BetterList`1, BetterList`1, BetterList`1) (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:482)
UIPanel:SubmitDrawCall(UIDrawCall) (at Assets/NGUI/Scripts/UI/UIPanel.cs:1056)
UIPanel:FillAllDrawCalls() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1013)
UIPanel:UpdateSelf() (at Assets/NGUI/Scripts/UI/UIPanel.cs:953)
UIPanel:LateUpdate() (at Assets/NGUI/Scripts/UI/UIPanel.cs:907)
I just want to get a shader that works which isn't transparent.
-
Unlit/Texture? That shader shouldn't be used. It doesn't have a version of it that supports clipping.
Change it to be Unlit/Transparent Colored.
-
Unlit/Texture? That shader shouldn't be used. It doesn't have a version of it that supports clipping.
Change it to be Unlit/Transparent Colored.
That shader makes it so that the character can barely be seen. Either the character is transparent, or barely visable. None of which looks right. So I guess my question now is what can I do to get the character to show up in the window and look normal? Transparent looks wrong because the characters is...well, transparent. I need solid and lit up so the player can see it properly.
-
Then you should create a custom shader to handle clipping. Unlit/Texture is not lit up either. Transparent takes alpha into consideration. Texture shader does not. That's the only difference. Look at another shader such as "Unlit/Transparent Colored (SofClip)" and compare it to "Unlit/Transparent Colored" to see how clipping is implemented.