Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 impurekind · May 26, 2019 at 12:52 PM · scripting problemassetsupdating

Updating Unity stuff is overwriting scripts I've previously edited?

OK, I don't really get how to work around this: I have various asset packages and stuff in my game that I was told to add when setting it up for VR and stuff, such as an Oculus Player Controller and a normal Player Controller, and I've edited a couple of the scripts that came in the Oculus assets package and Standard Assets package to get some stuff working the way I wanted (don't remember what ones), but now I'm being told I need to update the Oculus Packages and the like to get VR working again in my game (it broke with the latest build), which is overwriting those scripts I'd changed.

So how to I update things like the Oculus Utilities and Standard Assets when I'm told I need to get the latest version for to make VR work properly with the latest Unity builds and whatever but not overwrite the scripts in there that I've already changed for my game?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Bunny83 · May 26, 2019 at 03:22 PM

Just don't edit anything from an external package. The folders are called Standard Assets for a reason. Assets receive a unique assetID when they are created for the first time. This asset id identifies that asset anytime no matter where it is moved within your project as long as the meta file moves with it. When the meta file is lost or you duplicate an asset, the newly imported asset will get a new assetID.


Of course if you changed an asset that you didn't create and replace the files with updated files from the original source, your changes will be gone.


If you want to change / extend / alter an asset from a package you usually have two options:

  • Create a copy of the asset in your own assets. That way it will get a new asset ID and from now on is seperate from the original asset. Of course updates to that particular asset won't affect your copy (but that's what you wanted anyways)

  • The second option, if we talk about scripts, is to create a derived class in your normal assets that has the script from the package as base class. Now you can extend / alter your derived class as you wish. Since it's a seperate asset it's safe from any package imports. However not every class can be changed the way you want since the original author didn't think about extendability so you might need to copy large parts from the original script to actually change the behaviour. This solution also has another issue: If the original author did some "breaking changes" to the original script you may need to adjust / fix those issues in your derived class.


So the most reliable way is to duplicate the asset you want to change / modify. Though even then when it depends on other assets the functionality can break when you update those dependencies. So it's never a guarantee that you don't have to do some adjustments.

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 impurekind · May 26, 2019 at 04:15 PM 1
Share

But if I say copied the Player Controller script for the PlayerController object so I could modify it without affecting the original script, wouldn't I have to change its name? And if that's the case then what about all the code in any other scripts that point to it, wouldn't they then break because the name of the script they are pointing to has changed and I'd have to go into those scripts and change where they are pointing, and indeed make copies of those scripts and change their names so they also aren't replaced whenever I update that stuff from Oculus/Unity, and so on. And if I didn't make any of the original scripts or the scripts they're pointing to then it seems a bit of a way to go about things, a way which is pretty confusing and intimidating to me as a beginner coder. And I have no idea what the following means or how to go about doing it: "is to create a derived class in your normal assets that has the script from the package as base class"

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

187 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 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 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

Assets turning red and built-in classes not being recognized 0 Answers

TextMeshPro shows another Input Field above Keyboard Layout 1 Answer

Ref to Texture Missing when Creating Sprite by Script during Asset Postprocessing 1 Answer

How to Assets > Reimport in C#?, 0 Answers

How to detect asset changes in a script? 1 Answer


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