Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by ArturasLTU-RUS · Oct 16, 2013 at 03:09 AM · errorboolmodelimporter

help with error CS0029: Cannot implicitly convert type `bool'

hey If anyone can help I would really appreciate so the problem is:

error CS0029: Cannot implicitly convert type bool' to UnityEditor.ModelImporterClipAnimation[]'

this is the line were the error is :

ModelImporter modelImporter = ModelImporter.GetAtPath(assetPath) as ModelImporter; modelImporter.clipAnimations = true; modelImporter.generateAnimations = ModelImporterGenerateAnimations.InRoot;

this is the whole function:

void ProcessAnimations(GameObject DestinationAsset, string objectName, XmlDocument doc, int total) { Debug.Log("Starting animation split process..."); string assetPath = AssetDatabase.GetAssetPath(DestinationAsset);

     if (assetPath.Contains(objectName))
     {
         ModelImporter modelImporter = ModelImporter.GetAtPath(assetPath) as ModelImporter;
         modelImporter.clipAnimations = true;
         modelImporter.generateAnimations = ModelImporterGenerateAnimations.InRoot;

         // Set the number of animations here
         int numAnimations = total;
         ModelImporterClipAnimation[] animations = new ModelImporterClipAnimation[numAnimations];

         XmlNodeList list = doc.GetElementsByTagName("Data");
         int i = 0;
         foreach (XmlNode node in list)
         {
             XmlAttributeCollection child = node.Attributes;
             string name = "";
             int sf = 0;
             int ef = 0;

             foreach (XmlNode nd in child)
             {
                 if (nd.Name == "name")
                     name = nd.Value;
                 if (nd.Name == "startFrame")
                     sf = int.Parse(nd.Value.Replace("f", ""));
                 if (nd.Name == "endFrame")
                     ef = int.Parse(nd.Value.Replace("f", ""));
             }

             bool loop = false;
             string nm = name.ToLower();

             if (nm.Contains("idle") || nm.Contains("walk") || nm.Contains("sprint") || nm.Contains("run") || nm.Contains("strafe"))
                 loop = true;

             animations[i] = SetClipAnimationNew(nm, sf, ef, loop);
             i++;
         }

         modelImporter.clipAnimations = animations;

         Object asset = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject));
         EditorUtility.SetDirty(asset);
         AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);  
     }
 }

 private ModelImporterClipAnimation SetClipAnimationNew(string name, int firstFrame, int lastFrame, bool loop)
 {
     ModelImporterClipAnimation mica = new ModelImporterClipAnimation();
     mica.name = name;
     mica.firstFrame = firstFrame;
     mica.lastFrame = lastFrame;
     mica.loop = loop;

     if (loop)
         mica.wrapMode = WrapMode.Loop;
     else
         mica.wrapMode = WrapMode.Once;

     return mica;
 }

}

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
1

Answer by robertbu · Oct 16, 2013 at 07:05 AM

Your issue is on line 4:

  modelImporter.clipAnimations = true;

'clipAnimations' is not a boolean value. It is defined as 'ModelImporterClipAnimation[]'.

http://docs.unity3d.com/Documentation/ScriptReference/ModelImporter-clipAnimations.html

Comment
Add comment · Show 6 · 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
avatar image ArturasLTU-RUS · Oct 16, 2013 at 09:27 PM 0
Share

hey mate so could you tell me what to do?

avatar image flaviusxvii · Oct 16, 2013 at 09:51 PM 0
Share

Stop trying to assign a boolean to a non-boolean variable.

avatar image ArturasLTU-RUS · Oct 16, 2013 at 10:00 PM 0
Share

I mean could you help me rewrite the script that is above?

avatar image robertbu · Oct 16, 2013 at 10:03 PM 0
Share

As a guess, try commenting the line out. I did not take the time to understand all the code here, but '.clipAnimations' is assigned on line 40, and nothing in the function accesses it before line 40.

avatar image ArturasLTU-RUS · Oct 16, 2013 at 10:15 PM 0
Share

didn't help :/ maybe should I give a whole script ? I really need this for my college project :/

Show more comments

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

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Convert type `float' to `bool', Load 1 Answer

Get Component Error 0 Answers

Cannot implicitly convert type 'float' to 'bool' 3 Answers

Bool script error 1 Answer

Unit stops responding when i import models. WHY??? 2 Answers


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