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 Nerull22 · Feb 08, 2017 at 07:42 AM · scriptableobjectassetdatabasesingletonduplicatescriptable object

Single Scriptable Object Asset

I'm looking to create a settings file. I'm curious if there is a way to create a single instance of this in the project. I currently have it so that only one can be created and if you try to create it again it just selects the one that has already been created. The only caveat is that you can still duplicate that asset and now you have two. Does anyone have any thoughts?

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
0

Answer by ASPePeX · Feb 08, 2017 at 08:29 AM

You could use a static class, accessible from everywhere and no need to attach to anything.

 public static class Config
 {
     public static int Score = 9001;
 }

Edit: Ahh, did miss the "file". I do it here (https://github.com/InformatischesQuartett/BlinkenTiles/blob/master/Assets/Scripts/Config.cs) by parsing a json config file. If you want it to be saved from within your game, you could just do it the other way around.

Another possibility would be PlayerPrefs: https://docs.unity3d.com/ScriptReference/PlayerPrefs.html

If you actually want an object holding your info in the scene, check out the Toolbox: http://wiki.unity3d.com/index.php/Toolbox

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 Nerull22 · Feb 08, 2017 at 04:51 PM 0
Share

I see what you're getting at, but I think each provides its own problem/hurdle that I'm trying to avoid if possible. So the issue with the static class is that then a programmer would need to modify these values. I'm trying to expose these settings with a custom inspector so that a designer can easily go in and tweak these values. The issue with Player Prefs is that they don't persist over source control, that's only on a local system, so that won't work in a real project. And toolbox I'm not so sure would work outside of a scene. This settings file is meant to be stored in the project, but yes in a scene, using a custom singleton for monobehaviours is a great option that I've used a few times in the past for various things.

Thank you for the response, I think you're in the ball park, and it was probably on me for not explaining what I was looking for carefully enough.

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

64 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

Related Questions

Instantiate ScriptableObject with a random asset from List 1 Answer

ScriptableObject not saving data to asset 2 Answers

Unity : Singleton ScriptableObjects resets after play 1 Answer

List keeps emptying itself 0 Answers

Why did the values i had set reset? 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