Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 BillDNA · Dec 02, 2021 at 11:20 PM · testing

Is it possible to assign a text asset property in the editor for testing?

So i have a .json save file of the game right before it errored and so i want to be able to run testing agains that save file so i can debug the code with out having to run the whole game. I would like to be able to assign the textAsset in the editor like one dose for game objects and scriptable objects. Not sure how this is possible with my current understanding of how Unity so serialization.

So here would be the code.

     public TextAsset intailGameData;
     protected GameModel intialGameModel;
     protected GameModel finalGameModel;
 
     protected void BuildInitialGameData() {
         if(intailGameData == null) {
             Debug.LogError("No Game Data Provided");
             return;
         }
         intialGameModel = BaseModel.loadSaveData<GameModel>(intailGameData.bytes);
     }
 
 

And in the editor window when i select the test file I would like to be able to drag and drop the save file.

I know i can load the file using the specific path to the file but thats not a very clean.

Any ideas on how to achieve something like this? or even some good search terms to get me closer to an answer.

Thanks,

Comment
Add comment · Show 3
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 Hellium · Dec 02, 2021 at 11:54 PM 0
Share

I'm not sure to understand what you are trying to do.

Do you want to call BuildInitialGameData or do you want to set the value of intailGameData without running the game? How do you assign it at runtime?

avatar image BillDNA Hellium · Dec 03, 2021 at 12:53 AM 0
Share

I wan't to be able to set that TextAsset in the editor without having to load the file using something Like File.ReadAllBytes(path), not sure if that clarifies anythings. As far as how i load game data at run time the code follows a MVC architecture and so I'm just trying to test the model data and some controller methods that manipulate the model, so i can separate data bugs from visual bugs.

avatar image Hellium BillDNA · Dec 03, 2021 at 12:57 AM 0
Share

So I guess the code snippet you've provided is not part of a MonoBehaviour?

You might be interested in Unit Testing to test your code.

To load an asset in the editor, you can rely on the AssetDatabase class.

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

171 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

Related Questions

Unable to see NUnit Assert message output 1 Answer

Editor test runner makes unity hang 1 Answer

I am developing a automatic record replay system for testing.How can i access EventSystem from one Monobehaviour class to another class 0 Answers

In Unity3d test scripts, how to call a static function from another class? -2 Answers

Unfortunately, (GameName) has stopped (report ,ok) 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