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 /
  • Help Room /
avatar image
0
Question by oscarlundberg · Feb 09, 2016 at 02:14 PM · c#scripting problemloginaccountfilepath

Access a script with file path?

I have an Account system that creates a c# script in a database for every account. Now I'm trying to make a login system that can access the variables of an account script.

What I want to do is either reference the script at the target path

So that i can access the variables of the account script like: "ExampleScript.accountBalance"

Or if there is another way, like adding the target script as a component on the "player" game object.

I've tried googling and searching here but I can't find a way to load scripts from a path. Does anyone have any tips?

When i enter a username my script creates the following path

 string path1 = @"Assets/Database" + "/" + accountNameString +".cs"; 
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 corn · Feb 09, 2016 at 04:48 PM 0
Share

Sorry for this unhelpful comment, but I think you've got a serious design flaw there. If you only need to store some variables for each player, why don't you just serialize and save that data ? You could use PlayerPrefs for easily storing and retrieving player data.

Ex : you store data with PlayerPrefs.SetFloat(playerName + "balance", 17.2f); and retrieve it later this way :

 float GetAccountBalance(string playerName)
 {
     if (PlayerPrefs.Has$$anonymous$$ey(playerName + "balance"))
     {
         return PlayerPrefs.GetFloat(playerName + "balance");
     }
     return 0;
 }

Unless I'm completely missing the point, your idea is an overkill (and unfeasible ?) solution to a quite simple problem : storing data.

Hope that helps.

avatar image oscarlundberg corn · Feb 17, 2016 at 02:48 PM 0
Share

Thanks for the reply.. I'm very new to C# and program$$anonymous$$g in general so whatever I've done it's probably not very good... :D

But I just can't see how your solution saves data permanently, If i store data like that and then turn the game off, i will have lost my progress, right?

$$anonymous$$y intention was to save a few variables in an external database, such as: First Time Logging in, (To enable tutorial or tips) Email, Username, Password, In game currencies, items etc.

Within my "account scripts" there is only a variable declaration.

The way i save data right now, is by writing and rewriting lines in the variable declaration, so they are always saved permanently.

And to the original question: wanted to know how to load a script from a file path.

Like Resources.Load, but ins$$anonymous$$d of loading from resources, i want to load from any file path. I know I was a bit unclear the first post, but I hope this makes more sense...

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

My GameObject disappears when running this script. 0 Answers

The laser problems 0 Answers

Add 2D Skeleton to the Scene if Button was pressed 0 Answers

Integer arrays not comparing properly. 3 Answers

how do i take whats on one UI canvas and make it apear on another in real time(for a card game) 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