Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

Unity Crash on Adding to List Array, bug?

$
0
0
Hey guys, I am creating a custom editor and I have a list array of custom class. What I want to do is empty that array and dump a new array into the original one. What I am doing: //serialize original list array IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("Assets/Resources/LevelGFX_" + currentLevelID.ToString() + ".bin", FileMode.Create, FileAccess.Write, FileShare.ReadWrite); formatter.Serialize(stream, test.Stages); stream.Close(); //retrieve previously serialized list array and insert into obj variable IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("Assets/Resources/LevelGFX_" + currentLevelID.ToString() + ".bin", FileMode.Open, FileAccess.Read, FileShare.Read); List obj = (List) formatter.Deserialize(stream); stream.Close(); //clear original array and insert obj array into orignal array foreach(CStage s in test.Stages.ToArray()) { test.Stages.Remove(s); } foreach(CStage s in obj) { test.Stages.Add(s); } Here is the CStage Class: using UnityEngine; using System.Collections; using System; [Serializable] public class CStage { public string StageName = "New Stage"; public float StartTime = 0F; public float EndTime = 150F; public float SpeedMin = 1F; public float SpeedMax = 2F; public float MinSize = 2F; public float MaxSize = 4F; public float speed = 1F; public float ZDepth = 5F; public float Frequency = 2F; public bool Sequential = false; public float SequentialFudge = 2F; public float RotationY = 0F; [NonSerialized()] public GameObject EntryModel; [NonSerialized()] public GameObject[] InbetweenModels = new GameObject[5]; [NonSerialized()] public GameObject ExitModel; public bool FlipRandomally = false; public bool RandomizeRotation = false; [NonSerialized()] public Color TintMin = Color.white; [NonSerialized()] public Color TintMax = Color.red; //pos [NonSerialized()] public Vector2 XminMax = new Vector2(-5F, 7F); [NonSerialized()] public Vector2 YminMax = new Vector2(-4F, 4F); [NonSerialized()] public Vector2 ZminMax = new Vector2(0F, 8F); //internal public bool selected = false; public int gridY = 0; public int buttonWidth = 100; public int buttonHeight = 60; public bool modelsFoldout = false; public bool additionalFoldout = false; public bool stopped = false; public float rendererx = 5F; //test public GUIStyle gstyle = new GUIStyle(); public bool colorSet = false; //state public enum stateM {Middle, Entry, End} public stateM state = stateM.Entry; } However this causes Unity to crash. Any ideas will be greatly appreciated!

Viewing all articles
Browse latest Browse all 2383

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>