Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by rambramdt · Oct 02, 2011 at 03:09 PM · javascripterrorcompile

JScript problem

hi,

I have a weird problem. I sometimes need to import Blender Shape keys into Unity, and I always used MetaMorph developed by Foolish Frost without problem. In one recent project, however, I got tons of compiling errors. I finally got around by modifying an old project with a working MetaMorph script into the new one. But the problem kept gnaw at me and I feel uneasy not knowing what's wrong. I included both the error messages from one function and the corresponding function definition below. Hopefully someone can tell me what's wrong.

Jason

-----CompilerOutput:-stderr---------- -----EndCompilerOutput--------------- - Finished compile Library/ScriptAssemblies/Assembly-UnityScript-firstpass.dll Assets/Standard Assets/Scripts/MetaMorph.js(311,74): BCE0019: 'length' is not a member of 'Object'.

(Filename: Assets/Standard Assets/Scripts/MetaMorph.js Line: 311)

Assets/Standard Assets/Scripts/MetaMorph.js(313,96): BCE0048: Type 'Object' does not support slicing.

(Filename: Assets/Standard Assets/Scripts/MetaMorph.js Line: 313)

Assets/Standard Assets/Scripts/MetaMorph.js(318,98): BCE0048: Type 'Object' does not support slicing.

(Filename: Assets/Standard Assets/Scripts/MetaMorph.js Line: 318)

Assets/Standard Assets/Scripts/MetaMorph.js(329,70): BCE0004: Ambiguous reference 'parseFloat': UnityScript.Lang.UnityBuiltins.parseFloat(double), UnityScript.Lang.UnityBuiltins.parseFloat(int), UnityScript.Lang.UnityBuiltins.parseFloat(String), UnityScript.Lang.UnityBuiltins.parseFloat(float).

(Filename: Assets/Standard Assets/Scripts/MetaMorph.js Line: 329)

Assets/Standard Assets/Scripts/MetaMorph.js(331,97): BCE0048: Type 'Object' does not support slicing.

(Filename: Assets/Standard Assets/Scripts/MetaMorph.js Line: 331)

Assets/Standard Assets/Scripts/MetaMorph.js(336,101): BCE0004: Ambiguous reference 'parseFloat': UnityScript.Lang.UnityBuiltins.parseFloat(double), UnityScript.Lang.UnityBuiltins.parseFloat(int), UnityScript.Lang.UnityBuiltins.parseFloat(String), UnityScript.Lang.UnityBuiltins.parseFloat(float).

(Filename: Assets/Standard Assets/Scripts/MetaMorph.js Line: 336)

Assets/Standard Assets/Scripts/MetaMorph.js(369,66): BCE0048: Type 'Object' does not support slicing.

 function ReadAnimationFile(datafile : TextAsset) : Array
 {
     // This read blender 3d ShapeKeys that have been exported with the diffmap.
     // It's a good idea for each animation to contained in it's own file under it's own name.
     Report("Loading Animation Recording: " + datafile.name, 2);
     var Animation_Array = new Array();
     //var Total_String = datafile.text;
         
     var Total_Array = new Array();
     Total_Array = datafile.text.Split("\n"[0]);
     
     var line : int;
     for ( line = 0 ; line<Total_Array.length ; line=line+1 )
     {
         var Line_String : String = Total_Array[line];
         
         // parse out all the crap.
         var boo = Regex.Match(Line_String,"(\\[|\\])");
         if (boo.Success)
         {
             Line_String = Regex.Replace(Line_String,"(\n|\r|\f)","");
             Line_String = Regex.Replace(Line_String,"(\\[|\\])","");
             Line_String = Regex.Replace(Line_String,"\\s*(,)\\s*","|");
             Line_String = Regex.Replace(Line_String,"'","");
             
             var Line_Array = new Array();
             Line_Array = Line_String.Split("|"[0]);
             
             var item : int;
             
             // We really want the floating point numbers to be stored as floating points, and not strings...
             if (Animation_Array.length == 0)
             {
                 Animation_Array.Add(Line_Array);
                 
                 var Line_Array2 = new Array();
                 for ( item = 0 ; item<Animation_Array[0].length ; item=item+1 ) // Line 311
                 {
                     var Found : int = FindName( Diff_Maps, [Animation_Array[0][item]] ); // Line 313
                     if ( Found != -1)
                     {
                         Line_Array2.Add(Found); // Writing line two, the diff map indexes.  Faster than name lookups per frame.
                     } else {
                         Report("ERROR: Morph not found" + Animation_Array[0][item], 0); // Line 318
                         Debug.Break();
                     }
                 }
                 Animation_Array.Add(Line_Array2);
                 
             }
             else
             {
                 for ( item = 0 ; item<Line_Array.length ; item=item+1 )
                 {
                     Line_Array[item] = parseFloat(Line_Array[item]); // Line 329
                     
                     var Found2 : int = FindName( Diff_Maps, [Animation_Array[0][item]] ); // Line 331
                     if ( Found2 != -1)
                     {
                         if (Animation_Array.length == 2 && Diff_Maps[Found2].DM_Multiplier == 0)
                         {
                             Diff_Maps[Found2].DM_Multiplier = parseFloat(Line_Array[item]); // Line 336
                         }
                     }
                 }
                 Animation_Array.Add(Line_Array);
             }
         }
     }
     
     return Animation_Array;
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by SilverTabby · Oct 02, 2011 at 09:52 PM

All of the error messages you posted are really the same problem appearing in different forms. The problem is that the standard array class doesn't return an array, an animation, a String, a number, or anything really usable. It returns a generic Object. The only thing the program knows about this object that it's a packet of data in Unity. Not terribly useful.

Here's my recomendations:

  • DON'T use the Array() class if you can avoid it. I've never gotten it to work. ever. Use standard "built-in" arrays.

  • Declare the contents of your arrays explicitly.

For example, if you want to work with a 2-d Array of Strings, try this:

     var myArray : String[,] = new String[4,2];
     myArray[0,1] = "A string";
 
     for(var X : int = 0; X < myArray.Length(0); X++)
         for(var Y: int = 0; Y < myArray.Length(1); Y++)
         {
             myArray[X,Y] = "(" + X + ", " + Y + ")";
             Debug.Log(myArray[X,Y]);
         }

If you replace Every instance of the Array() class with a builtInArray[], then your problems should go away.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Cannot use Static var/ Unknown Idientifier 1 Answer

Javascript Compile error 2 Answers

BCE0005: Unknown identifier: 'spriteRenderer'. 2 Answers

What's this error? 1 Answer

Help with the code 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges