//使用同一个攻击定义盒 void LoadBoxDef(int idx) { idx = 0; TextAsset asset = Resources.Load <TextAsset>("boxdef0"); if (asset == null) { return; } MemoryStream ms = new MemoryStream(asset.bytes); List <BoxColliderDef> boxdef = Serializer.Deserialize <List <BoxColliderDef> >(ms); for (int i = 0; i < bo.Count; i++) { for (int j = 0; j < boxdef.Count; j++) { if (boxdef[j].name == bo[i].name) { BoxCollider bodef = bo[i].gameObject.AddComponent <BoxCollider>(); bodef.center = boxdef[j].center; bodef.size = boxdef[j].size; bodef.isTrigger = true; bodef.enabled = true; owner.AddHitBox(bodef);//受击盒.固定的 bo[i].gameObject.layer = LayerMask.NameToLayer("Bone"); } } } }