/// <summary> /// 设置动态物体的唯一ID(同时设置UniqueID和objectID) /// </summary> /// <param name="obj"></param> /// <param name="inStorage">是否将生成的DataModel添加到存储系统中</param> /// <returns></returns> public static int SetId(GameObject obj, bool inStorage = true) { DataModelBehaviour data = obj.GetComponent <DataModelBehaviour>(); if (data == null) { Debug.Log("当前gameobject未挂载DataModelBehaviour"); return(0); } else { int id = Instance[indexOffect]; data.DataEntity.objectID = id; data.GetComponent <UniqueID>().UniqueId = Instance[indexOffect]; //下一id indexOffect += 1; if (inStorage) { RestoreSystem.AddDataModel(id, data); } return(id); } }
/// <summary> /// 设置动态物体的唯一ID(同时设置UniqueID和objectID) /// </summary> /// <param name="obj"></param> /// <param name="inStorage">是否将生成的DataModel添加到存储系统中</param> /// <returns></returns> public static int SetId(DataModelBehaviour obj, bool inStorage = true) { if (obj == null) { Debug.Log("当前DataModelBehaviour为空"); return(0); } else { int id = Instance[indexOffect]; obj.DataEntity.objectID = id; obj.GetComponent <UniqueID>().UniqueId = id; //下一id indexOffect += 1; if (inStorage) { RestoreSystem.AddDataModel(id, obj); } return(id); } }