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 kici · Mar 11, 2011 at 12:57 AM · erroreditoreditor-scriptingconvert

Unity Editor Custom script

Alright, I wanna make my custom script in the Editor, but I'm not sure how to finish it, Check out the script there's 1 thing that isnt working properly, and the other i dont know how to do.

The thing that doesnt work im guessing it must be an unity bug, the shortcut doesn't work (im on windows) if i do crtl+c but it works if i do the same with my capslock on, (even thou its a small letter), so if someone can explain why this is... also, the other thing i dont know, is how to select the item i have just created in the Hirearchy, thanks.

using UnityEditor;

using UnityEngine;

class ResetObject : MonoBehaviour {

// Add menu named "Do Something" to the main menu // and give it a shortcut (ctrl-o on Windows, cmd-o on OS X). [MenuItem("kici/New GameObject %c")] static void NewObject() { new GameObject("kici");

 // Debug.Log("Perform operation");

}

}

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by chief1234 · Mar 11, 2011 at 01:19 AM

Your shortcut issue looks like a bug to me.

To select your new object you just need:

static void NewObject() {

 GameObject newObject = new GameObject("kici");

 Selection.activeGameObject = newObject;

 // use this to highlight the object in the hierarchy
 EditorGUIUtility.PingObject(newObject);

}

Comment
Add comment · Show 5 · 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 kici · Mar 11, 2011 at 09:50 AM 0
Share

how does the shortcut look like a bug ? whats the propery way, i even tried only wiht "k" and "$$anonymous$$" they both work (only if caps lock is on..?

avatar image chief1234 · Mar 11, 2011 at 08:41 PM 0
Share

I meant a bug with unity. Have you tried out any of the other shortcut options? I'm sure you've seen this page: http://unity3d.com/support/documentation/ScriptReference/$$anonymous$$enuItem.html I can't see why yours isn't working.

avatar image kici · Mar 11, 2011 at 10:54 PM 0
Share

yes i have... well that sux i dont have time to report another bug again, since they didnt even reply to my last one :S (RPC's didnt sent to the client LOL);;; thx i'll give u the answer!

avatar image kici · Mar 11, 2011 at 10:55 PM 0
Share

This is the error i get:

Error 1 Cannot implicitly convert type 'UnityEngine.GameObject' to 'UnityEngine.Object[]'

on this line: Selection.objects = newObject;

avatar image chief1234 · Mar 14, 2011 at 05:56 PM 0
Share

Well, I usually use unityscript, so I'm not sure how to resolve that error - so I changed the code a bit ins$$anonymous$$d. Assigning the new gameObject to Selection.activeGameObject works just fine since you're only assigning one object anyway.

avatar image
0

Answer by Zogg · Dec 17, 2011 at 11:30 PM

If %c doesn't work, maybe you should try another shortcut. For me, some shortcuts work (%m, %g...), some don't (%c, %f...).

Looks definitely like a bug to me. Or maybe the ones that don't work are "reserved" by Unity for whatever purpose - but if this is the case this should be documented somewhere, I think.

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

1 Person is following this question.

avatar image

Related Questions

How to exclude "Selection & Handles" and other editor-specific code in builds? 2 Answers

How do I fix error code cs1056: Unexpected Character 1 Answer

Im having an issue with a custom editor script pausing the whole editor with the little applicaton.message? 1 Answer

Check for compilation errors in Editor Script 0 Answers

Why I get this Debug error: 'fileLength == processed' when calling CreatePrefab? 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