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
2
Question by mcdroid · May 05, 2011 at 01:49 AM · camerasceneview

turn off selection in the Scene View

I am making an editor to add, move and size particles as well as change particle color. So far I manage to detect particles close to the mouse position (although I have problem because Camera.current doesn't have the right aspect ratio)

when I click on a particle, I get the closest particle to the ray, simulating a raycast

the problem is I do that and it selects the particle systems and thus exits the Editor script. it's strange because I have a [CustomEditor(typeof(GameObject))] at the head of that editor class so it should keep that script running but it doesn't

anyone has an idea about that ?

using UnityEditor; using UnityEngine; using System.Collections; using System.Collections.Generic;

[CustomEditor(typeof(GameObject))]

public class FurEditor : Editor { bool edit;

 void OnSceneGUI ()
 {
     if (Selection.activeGameObject.GetComponent<Fur>())
     {
         Handles.BeginGUI ();
             var tmpColor = GUI.color;
             if (edit)
                 GUI.color = Color.red;
             if (GUILayout.Button ("Edit", GUILayout.Width (70)))
                 edit = !edit;
             GUI.color = tmpColor;
         Handles.EndGUI ();

         if (edit) {
             EditBalls (Selection.activeGameObject.GetComponent<Fur>());
         }

         if (GUI.changed || edit && Event.current.type == EventType.MouseMove)
             EditorUtility.SetDirty (target);    
     }
 }

 Transform selection;
 void EditBalls (Fur target)
 {
     Vector3 mousePosition = new Vector3 (Event.current.mousePosition.x, Event.current.mousePosition.y, 0);
     Ray ray = Camera.current.ScreenPointToRay (new Vector2( mousePosition.x, Screen.height - mousePosition.y));

     Handles.DrawLine(ray.origin, ray.origin + 10*ray.direction);

// if (Event.current.button == 0) // { List<Transform> ballsClicked = new List<Transform> (); foreach (Transform b in target.balls) { if (Helpers.DistanceToLine (ray, b.position) <= b.lossyScale.x * .1f) ballsClicked.Add (b); }

     if (ballsClicked.Count &gt; 0) {
         float depth = Mathf.Infinity;
         foreach (Transform b in ballsClicked) {
             Handles.DrawSolidDisc(b.position, Camera.current.transform.forward, .1f);
             if (Camera.current.transform.InverseTransformPoint (b.position).z &lt; depth) {
                 depth = Camera.current.transform.TransformPoint (b.position).z;
                 selection = b;
             }
         }
     } else
         selection = null;

// }

     if (selection) {
         Handles.BeginGUI ();
         GUILayout.Label (selection.position.ToString ());
         GUILayout.Label (ballsClicked.Count.ToString ());
         Handles.RadiusHandle (Quaternion.identity, selection.transform.position, selection.lossyScale.x);
         Handles.EndGUI ();
     }
 }


}

Comment
Add comment · Show 1
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 DoubleDouble · May 06, 2011 at 12:02 AM 0
Share

I am also looking to disable mouse selection in the editor view. I try to do raycasting to place objects onto a grid, but selection often messes things up. Let me know if you figure it out Joshua.

0 Replies

· Add your reply
  • Sort: 

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

No one has followed this question yet.

Related Questions

Camera not showing in scene view 0 Answers

default setting scene area 1 Answer

Scene View Camera does not rotate(Different issue than the usual...) 0 Answers

Setting the SceneView View Angle/Position? 1 Answer

Unity Scene View's right-click + WASD doesn't look 3D anymore? 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