Deselect

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<javascript>" to "<syntaxhighlight lang="javascript">")
m (Text replace - "</javascript>" to "</syntaxhighlight>")
 
Line 46: Line 46:
 
     }
 
     }
 
}
 
}
</javascript>
+
</syntaxhighlight>

Latest revision as of 20:52, 10 January 2012

Author: Jonathan Czeck (aarku)

Contents

[edit] Description

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

[edit] Usage

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

[edit] C# - DeselectAll.cs

using UnityEngine;
using UnityEditor;
 
public class DeselectAll : ScriptableObject
{
    [MenuItem ("Custom/Deselect All _a")]
    static void DoDeselect()
    {
        Selection.objects = new UnityEngine.Object[0];
    }
}

[edit] Unity Javascript - DeselectAll.js

// 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];
    }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox