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 /
avatar image
0
Question by aclee · Nov 02, 2014 at 02:51 PM · error

varification error in editor script

hi, i am making a simple editor script that will take a heightmap and turn it in to a cubic terrain, but when trying to use the editor window i get this error: VerificationException: Error verifying CubeLand:OnGUI (): Compare instruction applyed to ill formed stack (Complex x Int32) at 0x0040 System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

this is the script: #pragma strict class CubeLand extends EditorWindow{

     var texture:Texture2D;
     var obj:GameObject;
     var sizeX:int = 100;
     var sizeZ:int = 100;
     var maxHeight:int;
     
     @MenuItem ("Window/CubeLand")
     
     static function ShowWindow(){
         EditorWindow.GetWindow (CubeLand);
     }
     
     function OnGUI () {
         texture = EditorGUI.ObjectField(Rect(3, 3, Screen.width, 100), "HeightMap", texture, Texture2D, true) as Texture2D;
         if(texture == !null){
             sizeX = EditorGUI.IntSlider(Rect(3, 106, Screen.width, 15), "X Size", sizeX, 100, texture.width);
             sizeZ = EditorGUI.IntSlider(Rect(3, 124, Screen.width, 15), "Z Size", sizeZ, 100, texture.height);
         }
         
         if(GUI.Button(Rect(0, Screen.height - Screen.height/10, Screen.width, Screen.height/10), "Generate")){
             if(texture == null){
                 EditorUtility.DisplayDialog("You forgot somthing!", "You forgot to enter a texture, to proceed you must enter a texture that has a heighter reseolution of 100x100", "OK, I'll add a texture", "Cancel");
             }else if(texture.width <= 100 || texture.height <= 100){
                 EditorUtility.DisplayDialog("You forgot somthing!", "You enterd a texture under the minumom resolution (100x100, please emter a new texture)", "OK, Ill, enter a differant texture", "Cancel");
             }
         }
     }
 }
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 ExtremePowers · Nov 02, 2014 at 03:49 PM

Is this what you are looking for?

 #pragma strict 
 class CubeLand extends EditorWindow {
 
     var texture:Texture2D;
     var cube : GameObject;
     var sizeX:int = 100;
     var sizeZ:int = 100;
     var maxHeight:int;
     var error : String;
      
     @MenuItem ("Window/CubeLand")
     static function ShowWindow() {
         EditorWindow.GetWindow(typeof(CubeLand));
     }
      
      function OnGUI () {
          GUILayout.Space(20);
          cube = EditorGUILayout.ObjectField("Cube", cube, GameObject, true) as GameObject;
          texture = EditorGUILayout.ObjectField("HeightMap", texture, Texture2D, true) as Texture2D;
          if(texture != null){
              GUILayout.Label("X: " + sizeX.ToString());
              sizeX = GUILayout.HorizontalSlider(sizeX, 100, texture.width);
              GUILayout.Label("Z: " + sizeZ.ToString());
              sizeZ = GUILayout.HorizontalSlider(sizeZ, 100, texture.height);
          }
          
          if(GUILayout.Button("Generate")) {
              if(texture == null){
                 error = "You forgot to enter a texture.";
             } else if(texture.width <= 100 || texture.height <= 100){
                 error = "The texture has to be atleast 100x100 pixels.";
             }
             if (String.IsNullOrEmpty(error)) {
                 for (var x = 0; x < sizeX; x++) {
                     for (var z = 0; z < sizeZ; z++) {
                         var X = Mathf.Floor(texture.width / sizeX);
                         var Z = Mathf.Floor(texture.height / sizeZ);
                         var height = texture.GetPixel(X,Z).a * maxHeight;
                         height = Mathf.Floor(height);
                         GameObject.Instantiate(cube, Vector3(x,height,z), Quaternion.identity);
                     }
                 }
             }
          }
          GUILayout.Label(error);
      }
 }
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

27 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

Related Questions

Multiple Cars not working 1 Answer

MonoDevelope is not opening! 1 Answer

Targetting error please help 0 Answers

Need help calling a script to another keep getting errors 1 Answer

Out of Range Exception 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