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 jbergs · Feb 09, 2019 at 07:56 PM · error messagecomponent

LOD Error on Unity's own Example script

I get two errors in 2018.3 from Unitys own example script in the LODGroup.SetLODs page..

LODGroup.SetLODs

The errors I get are: 1: 'LOD' does not contain a constructor that takes 2 arguments 2: Cannot convert from 'LOD[]' to 'UnityEngine.LOD[]'

Any thoughts on why? I searched a bunch and can't seem to find a solution.

 using UnityEngine;
 using System.Collections;
 
 public class LODExample : MonoBehaviour
 {
     public LODGroup group;
 
     void Start()
     {
         // Programmatically create a LOD group and add LOD levels.
         // Create a GUI that allows for forcing a specific LOD level.
         group = gameObject.AddComponent<LODGroup>();
 
         // Add 4 LOD levels
         LOD[] lods = new LOD[4];
         for (int i = 0; i < 4; i++)
         {
             PrimitiveType primType = PrimitiveType.Cube;
             switch (i)
             {
                 case 1:
                     primType = PrimitiveType.Capsule;
                     break;
                 case 2:
                     primType = PrimitiveType.Sphere;
                     break;
                 case 3:
                     primType = PrimitiveType.Cylinder;
                     break;
             }
             GameObject go = GameObject.CreatePrimitive(primType);
             go.transform.parent = gameObject.transform;
             Renderer[] renderers = new Renderer[1];
             renderers[0] = go.GetComponent<Renderer>();
             lods[i] = new LOD(1.0F / (i + 1), renderers);
         }
         group.SetLODs(lods);
         group.RecalculateBounds();
     }
 
     void OnGUI()
     {
         if (GUILayout.Button("Enable / Disable"))
             group.enabled = !group.enabled;
 
         if (GUILayout.Button("Default"))
             group.ForceLOD(-1);
 
         if (GUILayout.Button("Force 0"))
             group.ForceLOD(0);
 
         if (GUILayout.Button("Force 1"))
             group.ForceLOD(1);
 
         if (GUILayout.Button("Force 2"))
             group.ForceLOD(2);
 
         if (GUILayout.Button("Force 3"))
             group.ForceLOD(3);
 
         if (GUILayout.Button("Force 4"))
             group.ForceLOD(4);
 
         if (GUILayout.Button("Force 5"))
             group.ForceLOD(5);
 
         if (GUILayout.Button("Force 6"))
             group.ForceLOD(6);
     }
 }




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
Best Answer

Answer by xxmariofer · Feb 09, 2019 at 09:48 PM

well thats extrange, can you change

 LOD[] lods = new LOD[4];

to

 UnityEngine.LOD[] lods = new UnityEngine.LOD[4];

in case any class is giving conflict? whats your unity version?

Comment
Add comment · Show 4 · 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 jbergs · Feb 09, 2019 at 10:28 PM 0
Share

Hey, thanks for your reply, your answer did get rid of one of the errors. So thank you. I’m using Unity 2018.3.3f1.

The second error is still there which is “'LOD' does not contain a constructor that takes 2 arguments”. This is strange to me because according to the docs it does take 2 arguments?

avatar image xxmariofer jbergs · Feb 09, 2019 at 10:32 PM 0
Share

but is an error when the game is running? are you 100% sure you dont have a LOD class overriding the unityengine class?

avatar image jbergs xxmariofer · Feb 09, 2019 at 11:52 PM 0
Share

Well, that was it!! I had this other LOD script that was interfering. Thank you, I was scratching my head for a while there!

BTW - I've been a member since 2014, and I've only posted several questions over the years, you're the first to ever reply to me. So I mean it when I say I greatly appreciate your help!

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

102 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 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 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 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 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 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 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

2D Animation does not start 1 Answer

Unity can't see any scripts 0 Answers

Why am I getting this error ? 2 Answers

What's the best way to access a component that isn't pre-defined? 1 Answer

Can I make reference/assocation to another component as variable? 0 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