Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mathiassoeholm

Pages: [1] 2 3
1
NGUI 3 Support / Re: NGUI Lags behind Vive Controller
« on: August 13, 2016, 05:54:33 PM »
From the last post in this thread, it sounds like they're setting the position in OnPreCull.

http://forum.unity3d.com/threads/canvas-not-following-parent-properly-confirmed-fix-in-5-5.415946/

And apparently the same problem exists with Unity UI.

So since they're using OnPreCull, I guess changing the script execution order won't help since OnPreCull is always after LateUpdate.


2
NGUI 3 Support / Re: NGUI Lags behind Vive Controller
« on: August 13, 2016, 12:11:52 PM »
I'm sorry to revive an old topic, but I have the exact same problem.
I've tried changing the execution order as mentioned, but it doesn't change anything.

Here's a screenshot of my execution order:

3
NGUI 3 Support / Re: Text spacing, y u no float?
« on: October 17, 2014, 09:14:22 AM »
There should be a pull request now :-)

4
NGUI 3 Support / Re: Text spacing, y u no float?
« on: October 15, 2014, 07:52:33 AM »
@AGB Looks like you could really benefit from using float! :D

@ArenMook That actually makes perfect sense when I think about it. If you want, I can also look into it and have Nicki (moderator) send a pull request with my changes. We work at the same company.

5
NGUI 3 Support / Re: Text spacing, y u no float?
« on: October 14, 2014, 03:05:40 AM »
Thanks for the reply, I can see your point.

Yet it seems to be jumping several pixels, even with a pixel perfect label.
I made a demonstration:
https://dl.dropboxusercontent.com/u/4375689/Web/LabelSpacing/LabelSpacing.html

I would like to propose a solution for this, that would allow me to animate it using a floating point values.
You could have an option on UILabel for overriding text spacing using a float.
And then add extra x and y properties as floats to the label, that will be used instead of the integer ones, if this option is selected.

I realize that I might be the only person in the world with this problem, so it might not be worth the trouble for you.

6
NGUI 3 Support / Text spacing, y u no float?
« on: October 09, 2014, 08:36:14 AM »
Hey!

So I want to animate the text spacing of a label, to make it fold out, like an accordion.
This works, but it moves in visible steps, because text spacing is not set as floats but ints.

I managed to get around this by changing UILabel, so it exposes text spacing as a float.
It does use float when setting the text spacing internally anyway.

However, I really don't like having to change the NGUI source code, since I'll have to do it for every update.
I realize that you can't just change the spacing to float in the next NGUI, since it won't use the old serialized spacing that was saved as an int. Right?

Is there by any chance, a way that NGUI could add this functionality, without breaking anything?

Thanks!

7
NGUI 3 Support / Re: Kerning problem with bitmap font
« on: August 12, 2014, 02:16:44 AM »
I've sent an email to support at tasharen.com with the font.
It's an OTF btw.

8
NGUI 3 Support / Re: Kerning problem with bitmap font
« on: August 11, 2014, 02:47:11 AM »
I tried using the same font in Photoshop and Wordpad. They don't produce the same problem.
I also tried generating a bitmap font using Glyph Designer, and that didn't produce the problem either.
Here's another screenshot:



Top label uses the bitmap font generated by the Font Maker, middle is the bitmap font imported from Glyph Desginer and bottom is a dynamic font.

9
NGUI 3 Support / Kerning problem with bitmap font
« on: August 08, 2014, 08:26:51 AM »
I have a problem with the font kerning between the characters 6 and 1, in that order.
It only happens with the bitmap font I generated using the Font Maker.
A dynamic font, seems to work fine.


Bitmap font above, dynamic font below

I looked at the bitmap font prefab, and found where it save the kerning. It looks like this:

"kerning: 43000000ffffffff44000000f5ffffff4e000000fcffffff50000000f9ffffff51000000f9ffffff53000000ffffffff58000000f8ffffff"

Unfortunately, I have no idea of how to decipher that.
Any suggestions?

10
NGUI 3 Support / Bitmap font, numeric bug
« on: July 07, 2014, 07:57:33 AM »
Hello

Just discovered a small bug.
Setting a bitmap font to generate numeric chars will add 0 to the font twice.

I'm on NGUI 3.6.4b, so for all I know this might have been fixed in a newer version.
Just thought I'd report it anyway.


11
@Wisteso You're welcome! You really don't need to give me a gift for this, I'm just sharing something that I made for my own UI :-)

As Nicki points out, the extra camera is to give my 3D objects perspective.

12
I worked on something like this a few days ago, and got it working.
Here's my solution, the ClippedModel script sets the shader properties.

  1. Shader "UI/ClippedUnlitModel"
  2. {
  3.         Properties
  4.         {
  5.                 _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {}
  6.         }
  7.  
  8.         SubShader
  9.         {
  10.                 LOD 200
  11.  
  12.                 Tags
  13.                 {
  14.                         "Queue" = "Transparent"
  15.                         "IgnoreProjector" = "True"
  16.                         "RenderType" = "Transparent"
  17.                 }
  18.                
  19.                 Pass
  20.                 {
  21.                         Cull Off
  22.                         Lighting Off
  23.                         Offset -1, -1
  24.                         Fog { Mode Off }
  25.                         ColorMask RGB
  26.                         Blend SrcAlpha OneMinusSrcAlpha
  27.  
  28.                         CGPROGRAM
  29.                         #pragma vertex vert
  30.                         #pragma fragment frag
  31.  
  32.                         #include "UnityCG.cginc"
  33.  
  34.                         sampler2D _MainTex;
  35.                         float4 _PanelOffsetAndSharpness;
  36.                         float _PanelSizeX, _PanelSizeY;
  37.  
  38.                         struct appdata_t
  39.                         {
  40.                                 float4 vertex : POSITION;
  41.                                 half4 color : COLOR;
  42.                                 float2 texcoord : TEXCOORD0;
  43.                         };
  44.  
  45.                         struct v2f
  46.                         {
  47.                                 float4 vertex : POSITION;
  48.                                 half4 color : COLOR;
  49.                                 float2 texcoord : TEXCOORD0;
  50.                                 float2 posInPanel : TEXCOORD1;
  51.                         };
  52.  
  53.                         v2f vert (appdata_t v)
  54.                         {
  55.                                 v2f o;
  56.                                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  57.                                 o.color = v.color;
  58.                                 o.texcoord = v.texcoord;
  59.  
  60.                                 float2 clipSpace =  o.vertex.xy / o.vertex.w;
  61.  
  62.                                 // Normalize clip space
  63.                                 o.posInPanel = (clipSpace.xy + 1) * 0.5;
  64.  
  65.                                 // Adjust for panel offset
  66.                                 o.posInPanel.x  -= _PanelOffsetAndSharpness.x;
  67.                                 o.posInPanel.y  -= _PanelOffsetAndSharpness.y;
  68.  
  69.                                 // Adjust for panel size
  70.                                 o.posInPanel.x  *= (1 / _PanelSizeX);
  71.                                 o.posInPanel.y  *= (1 / _PanelSizeY);
  72.  
  73.                                 // Transform back to clip space
  74.                                 o.posInPanel *= 2;
  75.                                 o.posInPanel -= 1;
  76.  
  77.                                 return o;
  78.                         }
  79.  
  80.                         half4 frag (v2f IN) : COLOR
  81.                         {
  82.                                 // Softness factor
  83.                                 float2 factor = (float2(1.0, 1.0) - abs(IN.posInPanel)) * _PanelOffsetAndSharpness.zw;
  84.                        
  85.                                 // Sample the texture
  86.                                 half4 col = tex2D(_MainTex, IN.texcoord) * IN.color;
  87.                                 col.a *= clamp( min(factor.x, factor.y), 0.0, 1.0);
  88.  
  89.                                 return col;
  90.                         }
  91.                         ENDCG
  92.                 }
  93.         }
  94.        
  95.         SubShader
  96.         {
  97.                 LOD 100
  98.  
  99.                 Tags
  100.                 {
  101.                         "Queue" = "Transparent"
  102.                         "IgnoreProjector" = "True"
  103.                         "RenderType" = "Transparent"
  104.                 }
  105.                
  106.                 Pass
  107.                 {
  108.                         Cull Off
  109.                         Lighting Off
  110.                         ZWrite Off
  111.                         Fog { Mode Off }
  112.                         ColorMask RGB
  113.                         Blend SrcAlpha OneMinusSrcAlpha
  114.                         ColorMaterial AmbientAndDiffuse
  115.                        
  116.                         SetTexture [_MainTex]
  117.                         {
  118.                                 Combine Texture * Primary
  119.                         }
  120.                 }
  121.         }
  122. }
  123.  

  1. using UnityEngine;
  2.  
  3. [ExecuteInEditMode]
  4. public class ClippedModel : MonoBehaviour
  5. {
  6.         private UIPanel _panel;
  7.         private Material _material;
  8.  
  9.         private int _panelSizeXProperty;
  10.         private int _panelSizeYProperty;
  11.         private int _panelOffsetAndSharpnessProperty;
  12.  
  13.         private float _virtualScreenWidth;
  14.         private float _virtualScreenHeight;
  15.  
  16.         void Start()
  17.         {
  18.                 _panel = UIPanel.Find(transform);
  19.                 _material = !Application.isPlaying ? renderer.sharedMaterial : renderer.material;
  20.  
  21.                 _virtualScreenWidth = UIRoot.GetPixelSizeAdjustment(gameObject) * Screen.width;
  22.                 _virtualScreenHeight = UIRoot.GetPixelSizeAdjustment(gameObject) * Screen.height;
  23.  
  24.                 _panelSizeXProperty = Shader.PropertyToID("_PanelSizeX");
  25.                 _panelSizeYProperty = Shader.PropertyToID("_PanelSizeY");
  26.                 _panelOffsetAndSharpnessProperty = Shader.PropertyToID("_PanelOffsetAndSharpness");
  27.  
  28.                 Update();
  29.         }
  30.  
  31.         void Update()
  32.         {
  33.                 if (_panel.hasClipping)
  34.                 {
  35.                         var soft = _panel.clipSoftness;
  36.                         var sharpness = new Vector2(1000.0f, 1000.0f);
  37.                         if (soft.x > 0f)
  38.                         {
  39.                                 sharpness.x = _panel.baseClipRegion.z / soft.x;
  40.                         }
  41.                         if (soft.y > 0f)
  42.                         {
  43.                                 sharpness.y = _panel.baseClipRegion.w / soft.y;
  44.                         }
  45.  
  46.                         Vector4 panelOffsetAndSharpness;
  47.  
  48.                         // Get offset
  49.                         panelOffsetAndSharpness.x = ((_virtualScreenWidth * 0.5f + _panel.baseClipRegion.x) - (_panel.baseClipRegion.z * 0.5f)) / _virtualScreenWidth;
  50.                         panelOffsetAndSharpness.y = ((_virtualScreenHeight * 0.5f + _panel.baseClipRegion.y) - (_panel.baseClipRegion.w * 0.5f)) / _virtualScreenHeight;
  51.  
  52.                         // Get sharpness
  53.                         panelOffsetAndSharpness.z = sharpness.x;
  54.                         panelOffsetAndSharpness.w = sharpness.y;
  55.  
  56.                         // Set shader properties
  57.                         _material.SetFloat(_panelSizeXProperty, _panel.baseClipRegion.z / _virtualScreenWidth);
  58.                         _material.SetFloat(_panelSizeYProperty, _panel.baseClipRegion.w / _virtualScreenHeight);
  59.                         _material.SetVector(_panelOffsetAndSharpnessProperty, panelOffsetAndSharpness);
  60.                 }
  61.         }
  62. }
  63.  

The shader is based on one of the NGUI shaders.
I use a seperate camera to render my model with a higher depth than the UI camera.
I hope this can be helpful. If you have any feedback or improvements, let me know.
Also, it only works with clipping from a single panel.

13
NGUI 3 Support / Re: Anchors not updating when size change
« on: June 20, 2014, 02:21:51 AM »
Alright, I guess I'll have to manually update the anchors then

14
NGUI 3 Support / Anchors not updating when size change
« on: June 19, 2014, 08:26:14 AM »
I just updated from NGUI 3.6.0 to 3.6.4b.

Now I have several places where anchors need a frame before they refresh.
In the .gif below, the funny spiral-like icon is anchored to the label that says "1280" and set to OnUpdate.

That label is updated in the first frame, so it changes it size.
I'm guessing the anchor gets updated before the size is changed, and that's why it doesn't anchor to the right position until the next frame.

It works if I manually call UpdateAnchors, but that seems a bit like a hotfix.



Did anything change from 3.6.0 to 3.6.4 that could cause this?

15
NGUI 3 Support / Re: Nested alpha, feature or bug?
« on: May 01, 2014, 02:21:50 AM »
Got it.. Thanks! :-)

Pages: [1] 2 3