public override void OnUpdate() { if (CachedGameObject != theObjectWillBeEdited) { if (theObjectWillBeEdited != null) { CachedGameObject = theObjectWillBeEdited; } ResetData(); return; } if (theObjectWillBeEdited == null) { ResetData(); CachedGameObject = null; return; } if (mCollider2D == null) { mCollider2D = theObjectWillBeEdited.GetComponent <PolygonCollider2D>(); if (mCollider2D == null) { this.canDraw = false; } } if (this.MB2S_PolygonColliderDataStructure.id == 0) { this.MColliderNameAndIdInflectSupporter.colliderNameAndIdInflectDic.TryGetValue(this.theObjectWillBeEdited.name, out this.MB2S_PolygonColliderDataStructure.id); if (this.MColliderDataSupporter.colliderDataDic.ContainsKey(this.MB2S_PolygonColliderDataStructure.id)) { this.MB2S_PolygonColliderDataStructure = (B2S_PolygonColliderDataStructure)this.MColliderDataSupporter.colliderDataDic[this.MB2S_PolygonColliderDataStructure.id]; } } }
public override void SavecolliderData() { if (this.theObjectWillBeEdited != null && this.mCollider2D != null) { if (!this.MColliderDataSupporter.colliderDataDic.ContainsKey(this.MB2S_PolygonColliderDataStructure.id)) { B2S_PolygonColliderDataStructure temp = new B2S_PolygonColliderDataStructure(); temp.id = MB2S_PolygonColliderDataStructure.id; temp.finalOffset.X = MB2S_PolygonColliderDataStructure.finalOffset.X; temp.finalOffset.Y = MB2S_PolygonColliderDataStructure.finalOffset.Y; temp.isSensor = MB2S_PolygonColliderDataStructure.isSensor; temp.b2SColliderType = MB2S_PolygonColliderDataStructure.b2SColliderType; for (int i = 0; i < this.MB2S_PolygonColliderDataStructure.finalPoints.Count; i++) { temp.finalPoints.Add(new List <Vector2>()); for (int j = 0; j < this.MB2S_PolygonColliderDataStructure.finalPoints[i].Count; j++) { Vector2 costumVector2 = new Vector2(this.MB2S_PolygonColliderDataStructure.finalPoints[i][j].X, this.MB2S_PolygonColliderDataStructure.finalPoints[i][j].Y); temp.finalPoints[i].Add(costumVector2); } } temp.pointCount = this.MB2S_PolygonColliderDataStructure.pointCount; this.MColliderDataSupporter.colliderDataDic.Add(this.MB2S_PolygonColliderDataStructure.id, temp); } else { this.MColliderDataSupporter.colliderDataDic[this.MB2S_PolygonColliderDataStructure.id] = this.MB2S_PolygonColliderDataStructure; } } using (FileStream file = File.Create($"{this.ColliderDataSavePath}/{this.ColliderDataFileName}.bytes")) { BsonSerializer.Serialize(new BsonBinaryWriter(file), this.MColliderDataSupporter); } }