public override void SavecolliderData() { if (this.theObjectWillBeEdited != null && this.mCollider2D != null) { if (!this.MColliderDataSupporter.colliderDataDic.ContainsKey(this.MB2S_CircleColliderDataStructure.id)) { B2S_CircleColliderDataStructure b2SCircleColliderDataStructure = new B2S_CircleColliderDataStructure(); b2SCircleColliderDataStructure.id = MB2S_CircleColliderDataStructure.id; b2SCircleColliderDataStructure.finalOffset.X = MB2S_CircleColliderDataStructure.finalOffset.X; b2SCircleColliderDataStructure.finalOffset.Y = MB2S_CircleColliderDataStructure.finalOffset.Y; b2SCircleColliderDataStructure.isSensor = MB2S_CircleColliderDataStructure.isSensor; b2SCircleColliderDataStructure.b2SColliderType = MB2S_CircleColliderDataStructure.b2SColliderType; b2SCircleColliderDataStructure.radius = MB2S_CircleColliderDataStructure.radius; this.MColliderDataSupporter.colliderDataDic.Add(this.MB2S_CircleColliderDataStructure.id, b2SCircleColliderDataStructure); } else { this.MColliderDataSupporter.colliderDataDic[this.MB2S_CircleColliderDataStructure.id] = this.MB2S_CircleColliderDataStructure; } } using (FileStream file = File.Create($"{this.ColliderDataSavePath}/{this.ColliderDataFileName}.bytes")) { BsonSerializer.Serialize(new BsonBinaryWriter(file), this.MColliderDataSupporter); } }
public override void OnUpdate() { if (CachedGameObject != theObjectWillBeEdited) { if (theObjectWillBeEdited != null) { CachedGameObject = theObjectWillBeEdited; } this.ResetData(); return; } if (theObjectWillBeEdited == null) { this.ResetData(); return; } if (this.MB2S_CircleColliderDataStructure.id == 0) { if (this.MColliderNameAndIdInflectSupporter.colliderNameAndIdInflectDic.TryGetValue(this.theObjectWillBeEdited.name, out this.MB2S_CircleColliderDataStructure.id)) { Debug.Log($"自动设置圆形碰撞体ID成功,ID为{MB2S_CircleColliderDataStructure.id}"); } if (this.MColliderDataSupporter.colliderDataDic.ContainsKey(this.MB2S_CircleColliderDataStructure.id)) { this.MB2S_CircleColliderDataStructure = (B2S_CircleColliderDataStructure)this.MColliderDataSupporter.colliderDataDic[this.MB2S_CircleColliderDataStructure.id]; } } if (mCollider2D == null) { mCollider2D = theObjectWillBeEdited.GetComponent <CircleCollider2D>(); if (mCollider2D == null) { this.canDraw = false; } } }