1
NGUI 3 Support / Re: Nested soft clip Panels in Flashplayer
« on: October 15, 2014, 12:38:22 PM »
For that bug, yes that's all. If you truly want Flash to compile though...
In UIWidget change onRender to:
Doing "mOnRender != value" will get converted to roughly !(func1.Equals(func2)) in flash. However flash does not support ".Equals()" in this case. While Unity incorrectly converts .Equals()/!= on C# functions, it correctly converts ==. So the workaround is simply "!(mOnRender == value)".
In UILabel change GetWordAtCharacterIndex (int characterIndex) to:
LastIndexOfAny and IndexOfAny are not supported in flash (or only certain parameters are supported, I forget). So you just have to manually implement them yourself.
After those two fixes, 3.7.4 compiles for me in Flash.
In UIWidget change onRender to:
- public UIDrawCall.OnRenderCallback onRender
- {
- get
- {
- return mOnRender;
- }
- set
- {
- if (!(mOnRender == value))
- {
- #if !UNITY_FLASH
- if (drawCall != null && drawCall.onRender != null && mOnRender != null)
- drawCall.onRender -= mOnRender;
- #endif
- mOnRender = value;
- if (drawCall != null) drawCall.onRender += value;
- }
- }
- }
Doing "mOnRender != value" will get converted to roughly !(func1.Equals(func2)) in flash. However flash does not support ".Equals()" in this case. While Unity incorrectly converts .Equals()/!= on C# functions, it correctly converts ==. So the workaround is simply "!(mOnRender == value)".
In UILabel change GetWordAtCharacterIndex (int characterIndex) to:
- public string GetWordAtCharacterIndex (int characterIndex)
- {
- if (characterIndex != -1 && characterIndex < mText.Length)
- {
- int wordStart = LastIndexOfAny(mText, new char[] { ' ', '\n' }, characterIndex) + 1;//mText.LastIndexOfAny(new char[] {' ', '\n'}, characterIndex) + 1;
- int wordEnd = IndexOfAny(mText, new char[] { ' ', '\n', ',', '.' }, characterIndex);//mText.IndexOfAny(new char[] { ' ', '\n', ',', '.' }, characterIndex);
- if (wordEnd == -1) wordEnd = mText.Length;
- if (wordStart != wordEnd)
- {
- int len = wordEnd - wordStart;
- if (len > 0)
- {
- string word = mText.Substring(wordStart, len);
- return NGUIText.StripSymbols(word);
- }
- }
- }
- return null;
- }
- public int LastIndexOfAny(string input, char[] any, int start)
- {
- if (start >= 0 && input.Length > 0 && any.Length > 0 && start < input.Length)
- {
- for (int w = start; w >= 0; w--)
- {
- for (int r = 0; r < any.Length; r++)
- {
- if (any[r] == input[w])
- {
- return w;
- }
- }
- }
- }
- return -1;
- }
- public int IndexOfAny(string input, char[] any, int start)
- {
- if (start >= 0 && input.Length > 0 && any.Length > 0 && start < input.Length)
- {
- for (int w = start; w < input.Length; w++)
- {
- for (int r = 0; r < any.Length; r++)
- {
- if (any[r] == input[w])
- {
- return w;
- }
- }
- }
- }
- return -1;
- }
LastIndexOfAny and IndexOfAny are not supported in flash (or only certain parameters are supported, I forget). So you just have to manually implement them yourself.
After those two fixes, 3.7.4 compiles for me in Flash.
