Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 vozer · Aug 09, 2015 at 06:05 PM · javascripteditormeshquack

Script failing, mesh spray, "quack" is not generic

I am trying to do a mesh spray custom editor, but keep hitting two problems with EditoGuiLayout.objectfield and the "quack" is not a generic function

     class MyWindow extends EditorWindow {
 
 var particleOne;
 var selmesh ;
  
  
     @MenuItem ("Window/My Window")
     
       static function Init () {
          // Get existing open window or if none, make a new one:        
          var window : MyWindow  = ScriptableObject.CreateInstance.<MyWindow>();
  
          window.Show();
      }
 
     function OnGUI () {
 
 GUILayout.Label ("spawnonmesh", EditorStyles.boldLabel);
 
 particleOne = EditorGUI.ObjectField(new Rect(3,3,position.width - 6, 20),"sprayobject",particleOne,typeof(GameObject));
 selmesh = EditorGUI.ObjectField(new Rect(3,3,position.width - 6, 20),"Blablabla",selmesh,typeof(GameObject));
  
  if( GUILayout.Button ("apply")){
  
    RandomAdd();
   
    }
 
     }
     
      
  var pointa:Vector3=Vector3.zero;
  var pointb:Vector3=Vector3.zero;
  var pointc:Vector3=Vector3.zero;
 
 function RandomAdd () {
 
 
      var baseVertices : Vector3[];
      var mesh : Mesh = selmesh.GetComponent.<MeshFilter>().mesh;
      
       for(var f:int=0; f<particleOne.Length; f++){
      
      for(var i:int= 0; i < mesh.triangles.Length; i += 3){
      var rndA = Random.value;
      var rndB = Random.value;
      var rndC = Random.value;
      pointa = mesh.vertices[mesh.triangles[i + 0]];
      pointb = mesh.vertices[mesh.triangles[i + 1]];
      pointc = mesh.vertices[mesh.triangles[i + 2]];
 var rndTriPoint = (rndA * pointa + rndB * pointb + rndC * pointc) / (rndA + rndB + rndC) ;
      Instantiate (particleOne[f], rndTriPoint, Quaternion.identity);
      }
      
      }
 }
 
 }
 
  


I am confused...

Apparently this part is "quack"

      var mesh : Mesh = selmesh.GetComponent.<MeshFilter>().mesh;
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 Eric5h5 · Aug 09, 2015 at 11:18 PM

You didn't type your variables:

 var particleOne;
 var selmesh;

Either add a type explicitly, or add it implicitly by supplying a value.

Comment
Add comment · Show 1 · 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 vozer · Aug 10, 2015 at 10:41 AM 0
Share

thx! this 2 answers did the trick.

but i now have another problem.

"$$anonymous$$ Identifier serialized Object". I am trying to show an array in my custom editorwindow and understand, that this is done with findproperty.

But somehow after all explanations i don´t quite get it.

Help would be much appreciated.

 #pragma strict
 
 public class $$anonymous$$yWindow extends EditorWindow {
 
 var particleOne : GameObject[];
 var selmesh : GameObject;
 var scrollPosition : Vector2;
 
 
 ;
 
     @$$anonymous$$enuItem ("Window/$$anonymous$$y Window")
     
       static function Init () {
          // Get existing open window or if none, make a new one:        
          var window : $$anonymous$$yWindow  = ScriptableObject.CreateInstance.<$$anonymous$$yWindow>();
  
          window.Show();
      }
 
     function OnGUI () {
     
    
      
  scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
  
  var damageProp: SerializedProperty;
  
 damageProp = serializedObject.FindProperty("particleOne");
 
 serializedObject.Update();
 
 EditorGUILayout.PropertyField( damageProp, new GUIContent("bushes"));
 
 serializedObject.Apply$$anonymous$$odifiedProperties();
 
 
 selmesh = EditorGUI.ObjectField(new Rect(3,3,position.width - 6, 20),"Blablabla",selmesh,typeof(GameObject));
  
 GUILayout.Label ("spawnonmesh", EditorStyles.boldLabel);
  
  if( GUILayout.Button ("apply")){
  
    RandomAdd();
   
    }
 
  EditorGUILayout.EndScrollView();
  
     }
     
     
 
      
  var pointa:Vector3=Vector3.zero;
  var pointb:Vector3=Vector3.zero;
  var pointc:Vector3=Vector3.zero;
 
 function RandomAdd () {
 
 
      var baseVertices : Vector3[];
 
            var mesh : $$anonymous$$esh = selmesh.gameObject.GetComponent($$anonymous$$eshFilter).mesh;
 
       
       for(var f:int=0; f<particleOne.Length; f++){
      
      for(var i:int= 0; i < mesh.triangles.Length; i += 3){
      var rndA = Random.value;
      var rndB = Random.value;
      var rndC = Random.value;
      pointa = mesh.vertices[mesh.triangles[i + 0]];
      pointb = mesh.vertices[mesh.triangles[i + 1]];
      pointc = mesh.vertices[mesh.triangles[i + 2]];
 var rndTriPoint = (rndA * pointa + rndB * pointb + rndC * pointc) / (rndA + rndB + rndC) ;
      Instantiate (particleOne[f], rndTriPoint, Quaternion.identity);
      }
      
      }
 }
 
 }
 
  

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Changing Mesh Vertex Colors in editor 0 Answers

Importing A*Pathfinding plugin issue 1 Answer

Is there any way to reset the default meshes? 3 Answers

EditorScripting in Javascript 0 Answers

Custom Inspector data serialization in JavaScript 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