Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 nyonge · Oct 11, 2014 at 10:56 PM · gameobjecteditorspawnnewempty game object

Make New GameObject From Menu Spawn At Zero

Is there any way to make the "Create Empty" GameObject option in the menu (GameObject > Create Empty) spawn the new GameObject at 0,0,0 world space?

Right now it tends to spawn at some irritatingly arbitrary value, 3.3574,4.907523, that sorta thing.

Thanks!

Comment
Add comment · Show 2
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 AcroQube · Sep 21, 2019 at 12:35 PM 0
Share

Does anyone know why it doesn't spawn empty game objects at 0,0,0? It is not hard to type 0,0,0 and to make one on top of hierarchy and then copy it, but it should really spawn them at 0,0,0 or at parent's location...

avatar image Santifocus AcroQube · Sep 21, 2019 at 05:22 PM 1
Share

If im not mistaken it spawns at your inspector screen middle with a certain depth, you dont have to type 0,0,0 just RightClick on Transform -> Click Reset => Position = 0,0,0 Rotation = 0,0,0 Scalation = 1,1,1

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Hellium · Sep 21, 2019 at 09:11 PM

A gameObject created using the GameObject > Create Empty will spawn in the middle of the Scene view. If you want the object to spawn at 0, 0, 0, the scene camera must point at the center of the world.


But, since, Unity is extensible, you can also create your own "Create Empty" menu item thanks to a simple script put in an Editor folder:

 using UnityEngine;
 using UnityEditor;
 
 public class CreateEmptyMenu
 {
     [MenuItem("GameObject/Create Centered Empty #%&n", priority = 0 )]
     public static void CreateEmpty()
     {
         GameObject empty = new GameObject("GameObject");
         Undo.RegisterCreatedObjectUndo( empty, "Create new empty" );
         Selection.objects = new Object[] { empty };
     }
 }

Comment
Add comment · Show 3 · 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 Hunanbean · Nov 17, 2020 at 08:27 AM 0
Share

Thank you for the script. It works perfectly. $$anonymous$$y question as someone new to C# is, where in that code does it define to spawn a 0,0,0? or is it the lack of defined coordinates that make it default to 0,0,0?

avatar image Hellium Hunanbean · Nov 17, 2020 at 08:39 AM 0
Share

When created, the gameObject also gets a Transform component attached. The default position & rotation or the Transform are respectively the default value of Vector3 ( (0,0,0)) and the default value of a Quaternion. ( (0, 0, 0, 1) = (0, 0, 0) in euler angles))


If you want to force the position of the newly created object:

      GameObject empty = new GameObject("GameObject");
      empty.transform.position = new Vector3(x, y, z);
avatar image Hunanbean Hellium · Nov 17, 2020 at 06:43 PM 0
Share

That makes perfect sense. Thank you!

avatar image
1

Answer by djexstas9 · Mar 04 at 12:55 PM

Actually you can go to Edit -> Preferences -> Scene View and enable the "Create Objects At Origin" toggle. That's it, now your empty objects are created at the scene (0,0,0)

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
avatar image
0

Answer by bubzy · Oct 11, 2014 at 11:29 PM

I dont think so but maybe you could expand the editor and make your own function, is it really a hassle to type 0,0,0 in the inspector though? :)

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
avatar image
0

Answer by MrSoad · Oct 11, 2014 at 11:47 PM

Make one, move it to (0,0,0) give it a name like "1" to keep it at the top of the hierarchy window. Now just duplicate it whenever you need a new one(leaving the original for your next duplication). It's what I do, if you find a better way let me know.

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

35 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Help? Im trying to get my zombie prefab to spawn, but stop them spawning after a set spawn limit. 1 Answer

Setting a [SerializeField] GameObject in code 1 Answer

c# destroy gameobject on 0 hp 2 Answers

Adding to GameObject context menu WITHOUT [MenuItem(...)] 1 Answer

using Contains(gameObject) to find and destroy a gameObject from a list 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