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 /
avatar image
0
Question by qwert12345 · Sep 16, 2014 at 07:13 PM · iosbuildserializationdebug

Binnary Formatter working nicely in editor - but I have crashing after scene load paramteras on both iOS and Android device

Hi guys,

We appreciate your help as we are stuck in middle of nowhere. Usually all things we find on this more than usefull forum, but right now - we read for last 2 weeks, our budget for project are going up - we breaking a costs and have finished very large project until very end and STUCK...yes stuck because of some errors which can find it out :( We are so depressed, we doing every day until 5am - stripping code trying to find solutions but no way and there is nothing on internet about this errors.

Firstly we have 2 classes - 1 arrays of vehicles with parametears (bhp, weight...) and 2nd playerInfo class. We have standard Binnary formater - with whom we have problem already of missing / before file name - but right now as we implement Mono.Reflect on iOS and use preowned parameters scene works ok on mobile. But if I create class of cars JIT and save it and back from show room to garage...guess what it bringing me for 2 weeks same errors - he freeze iphone5 device (up to then runs smoothly) and Xcode bring me bunch of treads and this is always standard - also Android log give me all the time Null reference exceptions as something which I get it from car-script are not right - or array passing maximum no. I'm not sure - what is about - we have XML for multilanguage -but its works - we have tested and confirmed that loading - saving scene working (or maybe part of it) here is vehicle class we have for every car( when I preset it it works fine): using UnityEngine; using System.Collections; using System.Collections.Generic;

 [System.Serializable]
 public class Vehicles  {
 
      
  
     private int carModel;
     private int tier;
 
     private float bhp;
     private float weight;
     private float grip;
     private float gearbox;
     private float brakes;
     private    float steering;
  
     private int stageBrakes;
     private int stageEngine;
     private int stageGearBox;
     private int stageSteering;
     private int stageNOS;
     private int stageTurbo;
     private int stageTyre;
     private int stageBody;
 
     private float rating;
     
 
     public Vehicles (int carModel, int tier, float bhp, float weight, float grip, float gearbox, float brakes, float steering)
     {
          
         Bhp=bhp;
         Weight=weight;
         Grip=grip;
         Gearbox=gearbox;
         Brakes=brakes;
         Steering=steering;
         CarModel=carModel;
         Tier = tier;
         //postaviti sve levele na 1 pri kupovini kola
         stageBrakes=1;
         stageEngine=1;
         stageGearBox=1;
         stageSteering=1;
         stageNOS=1;
         stageTurbo=1;
         stageTyre=1;
         stageBody=1;
         rating=0;
 
 
     }
 
 
     public int  Tier
     {
         get
         {
             return tier;
         }
         set
         {
             tier = value;
         }
     }
 
 
     public float  Rating  //rating sistem
     {
         get
         {
             rating = bhp/5+steering/70+brakes/80+weight/33+gearbox/40;
             return rating;
         }
         set
         {
             rating = value;
         }
     }
 
     public float  Gearbox
     {
         get
         {
             return gearbox;
         }
         set
         {
             gearbox = value;
         }
     }
 
 
     public int  StageBody
     {
         get
         {
             return stageBody;
         }
         set
         {
             stageBody = value;
         }
     }
     public int  StageTyre
     {
         get
         {
             return stageTyre;
         }
         set
         {
             stageTyre = value;
         }
     }
 
     public int  StageTurbo
     {
         get
         {
             return stageTurbo;
         }
         set
         {
             stageTurbo = value;
         }
     }
 
     public int  StageNOS
     {
         get
         {
             return stageNOS;
         }
         set
         {
             stageNOS = value;
         }
     }
 
     public int  StageSteering
     {
         get
         {
             return stageSteering;
         }
         set
         {
             stageSteering = value;
         }
     }
 
 
     public int  StageGearBox
     {
         get
         {
             return stageGearBox;
         }
         set
         {
             stageGearBox = value;
         }
     }
 
     public int  StageEngine
     {
         get
         {
             return stageEngine;
         }
         set
         {
             stageEngine = value;
         }
     }
 
 
 
     public int  StageBrakes
     {
         get
         {
             return stageBrakes;
         }
         set
         {
             stageBrakes = value;
         }
     }
 
 
     public int  CarModel
     {
         get
         {
             return carModel;
         }
         set
         {
             carModel = value;
         }
     }
 
 
  
     public float  Bhp
     {
         get
         {
             return bhp;
         }
         set
         {
             bhp = value;
         }
     }
     
     public float  Weight
     {
         get
         {
             return weight;
         }
         set
         {
             weight = value;
         }
     }
 
     public float  Grip
     {
         get
         {
             return grip;
         }
         set
         {
             grip = value;
         }
     }
 
     public float  Brakes
     {
         get
         {
             return brakes;
         }
         set
         {
             brakes = value;
         }
     }
 
 
     public float  Steering
     {
         get
         {
             return steering;
         }
         set
         {
             steering = value;
         }
     }
     
 
 
 
 
 
 
 
 }

here is seconds part binnary formater we use for that:

     void SaveCarData() {
         var b = new BinaryFormatter();
         var f = File.Create(Application.persistentDataPath + imeFajlaWTRData );
         for (int i = 1; i <= brojMojihVozila; i++)
             b.Serialize(f, mojaVozila[i]);
 
         f.Close();
     }
 
     void LoadSavedCarData()
     {
         //LOAD ako je vec otvarano
         if(File.Exists(Application.persistentDataPath + imeFajlaWTRData ))    {
             var b = new BinaryFormatter();
             var f = File.Open(Application.persistentDataPath + imeFajlaWTRData , FileMode.Open);        
             **for (int i = 1; i <= brojMojihVozila; i++)
                 mojaVozila[i] = (Vehicles) b.Deserialize(f);**
             f.Close();
  
         }

just to mention that I start usage of vehicles from 1 - so 1st array was never initialized - does it matter on mobile? (I realized that I do not test with that option setup).

Guy, we really appreaciate if you find a time, I know you have job to do's but please if you have similar issue we will not spent weeks after anyhow hard work for this kind of stuff.

All the best and thanks!

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 Graham-Dunnett ♦♦ · Sep 16, 2014 at 09:00 PM 0
Share

Do you get any message written into the console? Have you tried symbolicating the code, so the call stacks make more sense?

avatar image qwert12345 · Sep 17, 2014 at 08:02 PM 0
Share

Hi Graham, I just have this

1 ArgumentNullException: Argument cannot be null.

Parameter name: obj

at System.Runtime.Serialization.ObjectIDGenerator.GetId (System.Object obj, System.Boolean& firstTime) [0x00000] in :0

at $$anonymous$$ain$$anonymous$$enu1.SaveCarData () [0x00000] in :0

at $$anonymous$$ain$$anonymous$$enu1.OnGUI () [0x00000] in :0

2 ArgumentNullException: Argument cannot be null.

Parameter name: obj

at System.Runtime.Serialization.ObjectIDGenerator.GetId (System.Object obj, System.Boolean& firstTime) [0x00000] in :0

at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph) [0x00000] in :0

at $$anonymous$$ain$$anonymous$$enu1.SaveCarData () [0x00000] in :0

at $$anonymous$$ain$$anonymous$$enu1.OnGUI () [0x00000] in :0

3 IOException: Sharing violation on path /var/mobile/Applications/2BA371E4-AC97-4FF3-9318-C6A656008FF2/Documents/333eeee3.wtr

(this file is wtr file for saving car data and savings happening after buying and getting back to 1st scene

main issue which I find is that:

at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteQueuedObjects

this is what I usually get (10x in one xcode running):

IOException: Sharing violation on path /var/mobile/Applications/2BA371E4-AC97-4FF3-9318-C6A656008FF2/Documents/333eeee3.wtr

at System.IO.FileStream..ctor (System.String path, File$$anonymous$$ode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in :0

at System.IO.FileStream..ctor (System.String path, File$$anonymous$$ode mode, FileAccess access, FileShare share, Int32 bufferSize) [0x00000] in :0

at System.IO.File.Create (System.String path, Int32 bufferSize) [0x00000] in :0

at System.IO.File.Create (System.String path) [0x00000] in :0

at $$anonymous$$ain$$anonymous$$enu1.SaveCarData () [0x00000] in :0

at $$anonymous$$ain$$anonymous$$enu1.OnGUI () [0x00000] in :0

and CarSavedData() is saving method from:

 void SaveCarData() {
         var b = new BinaryFormatter();
         var f = File.Create(Application.persistentDataPath + imeFajlaWTRData );
         for (int i = 1; i <= broj$$anonymous$$ojihVozila; i++)
             b.Serialize(f, mojaVozila[i]);
  
         f.Close();
     }
 

Appreciate your help!

PS. Also which I think maybe caused that error is as I do saving of array and maybe it crash on mobile:

for (int i = 1; i <= broj$$anonymous$$ojihVozila; i++) b.Serialize(f, mojaVozila[i]);

Just to confirm that everythings working nicely in editor and when I put preowned cars (not initialized in buying) adn games load all that data and selected player and runs game- but as soon as it back to the garage it NRE (null ref.exception).

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unity IOS recommended specs? Should I buy a faster machine? Or What machine are you running for Unity + IOS Pro? 1 Answer

Distribute terrain in zones 3 Answers

Play web game through mobile device 1 Answer

iOS Builder error “Could not find or use auto-linked framework” 0 Answers

Unity iOS: Customize Xcode project generation 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