Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 MissingL_tter · Aug 26, 2017 at 01:57 PM · buildoptimizationcompilername

Is there some reference for things Unity excludes from an actual build?

For example, if I instantiate an object and then change the name of it in the hierarchy (ie changing Object.name) does this need to be removed in a production version?

If I wanted to remove " (clone)" from the name of an instantiated object this would require me to parse, split and reassign a string. It can make things much prettier when working in the editor but is completely unnecessary in a production build.

Do I have to remove this or will Unity recognize that changing the hierarchical name of an object is meaningless to the build and ignore it?

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
0
Best Answer

Answer by Xarbrough · Aug 26, 2017 at 10:53 PM

You don't have to remove the name change from the final build. It will simply have no meaning outside of what you define it to be. This means, the compiler will not ignore it, it will simple be there like you did it in the editor. Unity doesn't care about the object's name, so if you don't do anything with the name, other than cleaning up the hierarchy in the editor, you can wrap the name assignments in #if UNITY_EDITOR preprocessor statements, to get rid of them in the build.

Other than that, the title is a bit misleading, if my answer was the only part concerned. Beyond the name topic, there is no list of things Unity excludes by default, except all assets, which are not referenced by a scene, AssetBundle or were placed inside of the Resources folder. Script files are always included, except of course Editor scripts and code which is within #if UNITY_EDITOR or other statements, that are not true in release mode (like DEBUG). The Unity API doesn't filter anything out automatically. The only special thing I can think of is the EditorOnly tag for GameObjects, which are automatically removed on build.

Comment
Add comment · Show 1 · 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 MissingL_tter · Aug 26, 2017 at 11:56 PM 0
Share

Perhaps my title was a bit misleading, I apologize. I was reading about Unity excluding unused assets from the binary and general build policies and I was wondering if there was a reference for what Unity actually does during the build process.

That's when I thought about the various things you can do programmatically that have no bearing on the game itself.

avatar image
0

Answer by Bunny83 · Aug 26, 2017 at 02:37 PM

Your question is a bit confusing. However it seems that you used "Instantiate" in some sort of editor code, which you shouldn't, at least when dealing with prefabs. To create a prefab instance during edit mode you should use the PrefabUtility: PrefabUtility.InstantiatePrefab. This will actually preserve the prefab connection.

Prefabs are a pure editor feature. At runtime there are just gameobjects. There are GameObjects serialized into a scene and there are GameObjects which aren't in a scene (the former prefabs). Any change to properties on a gameobject instance in the scene is actually stored inside the scene itself.

At runtime you can't even tell from which prefab a certain object came from. A scene is finally just composed of GameObjects, nothing more. The prefab itself isn't even included in the build when you do not have an actual reference to it in a variable. So having instances of a prefab in a scene does not make the prefab being included in the build.

Prefabs are a pure organisatorical feature of the editor. Prefabs do not save any space in a scene. So having 100 duplicates of an object in the scene or having 100 prefab instances of the same object in a scene makes no difference. The objects are actually stored inside the scene.

So to answer your question: No, it makes no difference when you change the name of objects in the scene. Actually shortening the object names will actually save a few bytes of memory ^^

Comment
Add comment · Show 1 · 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 MissingL_tter · Aug 26, 2017 at 10:18 PM 0
Share

I don't understand how my question was confusing at all. I am actually extremely confused by your answer.

I use instantiate to create a GameObject. For example:

 GameObject foo = Instantiate(bar);

This will create a GameObject in the scene presumably called "foo(Clone)" if the prefab was named foo in the inspector.

If I get tired of looking at the word "Clone" I could do something like this

 foo.name = foo.name.Split('(')[0];

This will remove the "(Clone)" in the name of the GameObject in the hierarchy.

This was just an example of something you could do programmatically that does not affect the build in any way. $$anonymous$$y question is should this be removed in a production build or does the compiler effectively ignore it?

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

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

Related Questions

Distribute terrain in zones 3 Answers

How do you optimize your fonts? 1 Answer

Unity compiles assets from previous builds into an empty scene? 2 Answers

What happen to unused mesh component? 0 Answers

Compiler errors in unreferenced scripts 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