Deselect

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Reverted edits by Joseph05408 (Talk); changed back to last version by Andrewp)
Line 23: Line 23:
 
}
 
}
 
</csharp>
 
</csharp>
 +
 +
==Unity Javascript - DeselectAll.js==
 +
<javascript>
 +
// using UnityEngine; and using UnityEditor are ommited because
 +
// in Unity Javascript (from now js) they are set by default.
 +
 +
//public class DeselectAll : ScriptableObject
 +
// public is set by default in js, the colon : in c# corresponds to extends keyword in js
 +
class DeselectAll extends ScriptableObject
 +
{
 +
// [MenuItem ("Custom/Deselect All _a")] instead of [] js uses the @
 +
// "Custom/Deselect All defines the structure in the Menu, while _a defines the hotkey (a)
 +
// we changed the hotkey in #d which means Shift+d
 +
    @MenuItem ("Custom/Deselect All #d")
 +
 +
// static void DoDeselect() changes in static function DoDeselect
 +
// keyword void is not supported in js. To declare a method in a class
 +
// we must use the function keyword.
 +
    static  function DoDeselect()
 +
    {
 +
        Selection.objects = new UnityEngine.Object[0];
 +
    }
 +
}
 +
</javascript>

Revision as of 12:36, 6 December 2009

Author: Jonathan Czeck (aarku)

Contents

Description

This editor script sets the current selection to nothing. It deselects.

Usage

Place this script in YourProject/Assets/Editor and a menu item will automatically appear in the Custom menu after it is compiled.

C# - DeselectAll.cs

<csharp>using UnityEngine; using UnityEditor;

public class DeselectAll : ScriptableObject {

   [MenuItem ("Custom/Deselect All _a")]
   static void DoDeselect()
   {
       Selection.objects = new UnityEngine.Object[0];
   }

} </csharp>

Unity Javascript - DeselectAll.js

<javascript> // using UnityEngine; and using UnityEditor are ommited because // in Unity Javascript (from now js) they are set by default.

//public class DeselectAll : ScriptableObject // public is set by default in js, the colon : in c# corresponds to extends keyword in js

class DeselectAll extends ScriptableObject

{ // [MenuItem ("Custom/Deselect All _a")] instead of [] js uses the @ // "Custom/Deselect All defines the structure in the Menu, while _a defines the hotkey (a) // we changed the hotkey in #d which means Shift+d

   @MenuItem ("Custom/Deselect All #d")

// static void DoDeselect() changes in static function DoDeselect // keyword void is not supported in js. To declare a method in a class // we must use the function keyword.

   static  function DoDeselect()
   {
       Selection.objects = new UnityEngine.Object[0];
   }

} </javascript>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox