Author Topic: Flash support is completely broken now  (Read 3631 times)

missingno

  • Guest
Flash support is completely broken now
« on: October 31, 2013, 11:23:09 AM »
I know Unity has stopped supporting Flash, but I still have a project to finish with it and I updated to NGUI 3 and now Flash is broken.

It doesn't even compile, I was able to get it to compile and run in the Editor by hacking around a few things using #if UNITY_FLASH statements, but now when trying to build I get errors about being unable to resolve T in NGUITools. Obviously T is and always has been used in NGUITools so I'm unsure as to what changed and why it suddenly doesn't work.

ArenMook or anyone else have any ideas ?

  1. Failed to convert type 'NGUITools': Failed to resolve T
  2. Mono.Cecil.ResolutionException: Failed to resolve T
  3.   at Unity.CecilTools.Extensions.ResolutionExtensions.Resolve[TypeReference,TypeDefinition] (Mono.Cecil.TypeReference reference, System.Func`2 resolve) [0x00000] in <filename unknown>:0
  4.   at Unity.CecilTools.Extensions.ResolutionExtensions.CheckedResolve (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
  5.   at Unity.CecilTools.Extensions.TypeReferenceExtensions.IsAssignableTo (Mono.Cecil.TypeReference typeRef, System.String typeName) [0x00000] in <filename unknown>:0
  6.   at cil2as.Extensions.TypeReferenceExtensions.IsDelegate (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
  7.   at cil2as.Decompiler.Transforms.OptimizeCasts.RequiresCastAs (ICSharpCode.NRefactory.CSharp.AstType type) [0x00000] in <filename unknown>:0
  8.   at cil2as.Decompiler.Transforms.OptimizeCasts.VisitCastExpression (ICSharpCode.NRefactory.CSharp.CastExpression castExpression, System.Object data) [0x00000] in <filename unknown>:0
  9.   at ICSharpCode.NRefactory.CSharp.CastExpression.AcceptVisitor[Object,Object] (IAstVisitor`2 visitor, System.Object data) [0x00000] in <filename unknown>:0
  10.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitChildren (ICSharpCode.NRefactory.CSharp.AstNode node, System.Object data) [0x00000] in <filename unknown>:0
  11.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitVariableInitializer (ICSharpCode.NRefactory.CSharp.VariableInitializer variableInitializer, System.Object data) [0x00000] in <filename unknown>:0
  12.   at ICSharpCode.NRefactory.CSharp.VariableInitializer.AcceptVisitor[Object,Object] (IAstVisitor`2 visitor, System.Object data) [0x00000] in <filename unknown>:0
  13.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitChildren (ICSharpCode.NRefactory.CSharp.AstNode node, System.Object data) [0x00000] in <filename unknown>:0
  14.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitVariableDeclarationStatement (ICSharpCode.NRefactory.CSharp.VariableDeclarationStatement variableDeclarationStatement, System.Object data) [0x00000] in <filename unknown>:0
  15.   at ICSharpCode.NRefactory.CSharp.VariableDeclarationStatement.AcceptVisitor[Object,Object] (IAstVisitor`2 visitor, System.Object data) [0x00000] in <filename unknown>:0
  16.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitChildren (ICSharpCode.NRefactory.CSharp.AstNode node, System.Object data) [0x00000] in <filename unknown>:0
  17.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitBlockStatement (ICSharpCode.NRefactory.CSharp.BlockStatement blockStatement, System.Object data) [0x00000] in <filename unknown>:0
  18.   at ICSharpCode.NRefactory.CSharp.BlockStatement.AcceptVisitor[Object,Object] (IAstVisitor`2 visitor, System.Object data) [0x00000] in <filename unknown>:0
  19.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitChildren (ICSharpCode.NRefactory.CSharp.AstNode node, System.Object data) [0x00000] in <filename unknown>:0
  20.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitForStatement (ICSharpCode.NRefactory.CSharp.ForStatement forStatement, System.Object data) [0x00000] in <filename unknown>:0
  21.   at ICSharpCode.NRefactory.CSharp.ForStatement.AcceptVisitor[Object,Object] (IAstVisitor`2 visitor, System.Object data) [0x00000] in <filename unknown>:0
  22.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitChildren (ICSharpCode.NRefactory.CSharp.AstNode node, System.Object data) [0x00000] in <filename unknown>:0
  23.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitBlockStatement (ICSharpCode.NRefactory.CSharp.BlockStatement blockStatement, System.Object data) [0x00000] in <filename unknown>:0
  24.   at ICSharpCode.NRefactory.CSharp.BlockStatement.AcceptVisitor[Object,Object] (IAstVisitor`2 visitor, System.Object data) [0x00000] in <filename unknown>:0
  25.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitChildren (ICSharpCode.NRefactory.CSharp.AstNode node, System.Object data) [0x00000] in <filename unknown>:0
  26.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitMethodDeclaration (ICSharpCode.NRefactory.CSharp.MethodDeclaration methodDeclaration, System.Object data) [0x00000] in <filename unknown>:0
  27.   at ICSharpCode.NRefactory.CSharp.MethodDeclaration.AcceptVisitor[Object,Object] (IAstVisitor`2 visitor, System.Object data) [0x00000] in <filename unknown>:0
  28.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitChildren (ICSharpCode.NRefactory.CSharp.AstNode node, System.Object data) [0x00000] in <filename unknown>:0
  29.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitTypeDeclaration (ICSharpCode.NRefactory.CSharp.TypeDeclaration typeDeclaration, System.Object data) [0x00000] in <filename unknown>:0
  30.   at ICSharpCode.NRefactory.CSharp.TypeDeclaration.AcceptVisitor[Object,Object] (IAstVisitor`2 visitor, System.Object data) [0x00000] in <filename unknown>:0
  31.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitChildren (ICSharpCode.NRefactory.CSharp.AstNode node, System.Object data) [0x00000] in <filename unknown>:0
  32.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitNamespaceDeclaration (ICSharpCode.NRefactory.CSharp.NamespaceDeclaration namespaceDeclaration, System.Object data) [0x00000] in <filename unknown>:0
  33.   at ICSharpCode.NRefactory.CSharp.NamespaceDeclaration.AcceptVisitor[Object,Object] (IAstVisitor`2 visitor, System.Object data) [0x00000] in <filename unknown>:0
  34.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitChildren (ICSharpCode.NRefactory.CSharp.AstNode node, System.Object data) [0x00000] in <filename unknown>:0
  35.   at ICSharpCode.NRefactory.CSharp.DepthFirstAstVisitor`2[System.Object,System.Object].VisitCompilationUnit (ICSharpCode.NRefactory.CSharp.CompilationUnit unit, System.Object data) [0x00000] in <filename unknown>:0
  36.   at ICSharpCode.NRefactory.CSharp.CompilationUnit.AcceptVisitor[Object,Object] (IAstVisitor`2 visitor, System.Object data) [0x00000] in <filename unknown>:0
  37.   at cil2as.Decompiler.Transforms.DepthFirstAstTransform.Run (ICSharpCode.NRefactory.CSharp.AstNode node) [0x00000] in <filename unknown>:0
  38.   at cil2as.Decompiler.EcmaScriptAstBuilder.ApplyTransforms (ICSharpCode.NRefactory.CSharp.AstNode node, IEnumerable`1 pipeline) [0x00000] in <filename unknown>:0
  39.   at cil2as.Decompiler.EcmaScriptAstBuilder.ApplyTransformationPipelineTo (ICSharpCode.NRefactory.CSharp.AstNode node) [0x00000] in <filename unknown>:0
  40.   at cil2as.Decompiler.EcmaScriptAstBuilder.AstFor (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
  41.   at cil2as.EcmaScriptGenerator.AstFor (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
  42.   at cil2as.EcmaScriptGenerator.Decompile (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
  43.   at cil2as.EcmaScriptGenerator.GenerateActionScriptCodeFor (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
  44.   at cil2as.AssemblyConverter.ConvertTypesToActionScript () [0x00000] in <filename unknown>:0
  45.  
  46.  

missingno

  • Guest
Re: Flash support is completely broken now
« Reply #1 on: November 04, 2013, 11:56:05 AM »
I've gotten some progress, I was able to solve the previous error by replacing one of the generic functions in NGUITools with multiple versions for each type that was needed.

However now I am getting the following in EventDelegate anywhere either .Target or .Method is used:

  1. /Temp/StagingArea/Data/ConvertedDotNetCode/global/EventDelegate.as(81): col: 153 Error: Access of possibly undefined property Method through a reference with static type Function.
  1. /Temp/StagingArea/Data/ConvertedDotNetCode/global/EventDelegate.as(81): col: 153 Error: Access of possibly undefined property Target through a reference with static type Function.

Is anyone able to help me ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Flash support is completely broken now
« Reply #2 on: November 04, 2013, 11:58:34 AM »
Reflection is not supported in Flash, which is why there is no reflection support defined up at the top of the file for flash platforms. Sounds like I need to do another pass with the flash platform targeted though.

missingno

  • Guest
Re: Flash support is completely broken now
« Reply #3 on: November 04, 2013, 12:03:37 PM »
thanks for the quick response, any idea on a time frame for that ?

I'm on a deadline and I need to have a Flash build. I've just been trying to make workarounds for flash the last couple days hoping to at least get it running and this is the last step. I tried just simply commenting out the .Target and .Method references and it then compiles, builds and runs (albeit with a few oddities, likely due to not setting some things in EventDelegate, but the point was to see if any other problems appeared).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Flash support is completely broken now
« Reply #4 on: November 04, 2013, 12:09:12 PM »
Try this file.

missingno

  • Guest
Re: Flash support is completely broken now
« Reply #5 on: November 04, 2013, 12:16:10 PM »
almost, only getting the following now:

  1. /EventDelegate.as(89): col: 22 Error: Call to a possibly undefined method Object_Equals_Object through a reference with static type Function.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Flash support is completely broken now
« Reply #6 on: November 04, 2013, 12:19:32 PM »
Line 89 is a bracket for me. Which code is it referring to?

missingno

  • Guest
Re: Flash support is completely broken now
« Reply #7 on: November 04, 2013, 12:22:35 PM »
It's line 89 in the converted AS code, in the C# code it is line 114 (i believe).

Lines 111 - 120 in C#
  1.                 if (obj is Callback)
  2.                 {
  3.                         Callback callback = obj as Callback;
  4.                         if (callback.Equals(mCachedCallback)) return true;
  5. #if REFLECTION_SUPPORT
  6.                         return (mTarget == callback.Target && string.Equals(mMethodName, GetMethodName(callback)));
  7. #else
  8.                         return false;
  9. #endif
  10.                 }
converts to lines 87 - 90 in AS:
  1. if ($obj is Function) {
  2.         var $callback: Function = $obj as Function;
  3.         return $callback.Object_Equals_Object(this.EventDelegate$mCachedCallback$);
  4. }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Flash support is completely broken now
« Reply #8 on: November 04, 2013, 12:27:50 PM »
Ah, another fail on the Flash side stemming from the shoddy code conversion. Try this function.
  1.         public override bool Equals (object obj)
  2.         {
  3.                 if (obj == null)
  4.                 {
  5.                         return !isValid;
  6.                 }
  7.  
  8.                 if (obj is Callback)
  9.                 {
  10.                         Callback callback = obj as Callback;
  11. #if UNITY_FLASH
  12.                         return (callback == mCachedCallback);
  13. #elif REFLECTION_SUPPORT
  14.                         if (callback.Equals(mCachedCallback)) return true;
  15.                         return (mTarget == callback.Target && string.Equals(mMethodName, GetMethodName(callback)));
  16. #else
  17.                         return callback.Equals(mCachedCallback);
  18. #endif
  19.                 }
  20.                
  21.                 if (obj is EventDelegate)
  22.                 {
  23.                         EventDelegate del = obj as EventDelegate;
  24.                         return (mTarget == del.mTarget && string.Equals(mMethodName, del.mMethodName));
  25.                 }
  26.                 return false;
  27.         }

missingno

  • Guest
Re: Flash support is completely broken now
« Reply #9 on: November 04, 2013, 12:38:27 PM »
That did it :) Thank's for the very quick and active work on this.

Now that it's building I can get to work on finding and fixing the problems that don't seem to make any logical sense when using unity flash ...