private void CleanupLimboMinions() { KPrefabID component = GetComponent <KPrefabID>(); if (component.InstanceID == -1) { DebugUtil.LogWarningArgs("Minion with an invalid kpid! Attempting to recover...", name); if ((UnityEngine.Object)KPrefabIDTracker.Get().GetInstance(component.InstanceID) != (UnityEngine.Object)null) { KPrefabIDTracker.Get().Unregister(component); } component.InstanceID = KPrefabID.GetUniqueID(); KPrefabIDTracker.Get().Register(component); DebugUtil.LogWarningArgs("Restored as:", component.InstanceID); } if (component.conflicted) { DebugUtil.LogWarningArgs("Minion with a conflicted kpid! Attempting to recover... ", component.InstanceID, name); if ((UnityEngine.Object)KPrefabIDTracker.Get().GetInstance(component.InstanceID) != (UnityEngine.Object)null) { KPrefabIDTracker.Get().Unregister(component); } component.InstanceID = KPrefabID.GetUniqueID(); KPrefabIDTracker.Get().Register(component); DebugUtil.LogWarningArgs("Restored as:", component.InstanceID); } assignableProxy.Get().SetTarget(this, base.gameObject); }
public static GameObject KInstantiate(GameObject original, Vector3 position, Quaternion rotation, GameObject parent = null, string name = null, bool initialize_id = true, int gameLayer = 0) { if (App.IsExiting) { return(null); } GameObject gameObject = null; if ((UnityEngine.Object)original == (UnityEngine.Object)null) { DebugUtil.LogWarningArgs("Missing prefab"); } if ((UnityEngine.Object)gameObject == (UnityEngine.Object)null) { if ((UnityEngine.Object)original.GetComponent <RectTransform>() != (UnityEngine.Object)null && (UnityEngine.Object)parent != (UnityEngine.Object)null) { gameObject = UnityEngine.Object.Instantiate(original, position, rotation); gameObject.transform.SetParent(parent.transform, true); } else { Transform parent2 = null; if ((UnityEngine.Object)parent != (UnityEngine.Object)null) { parent2 = parent.transform; } gameObject = UnityEngine.Object.Instantiate(original, position, rotation, parent2); } if (gameLayer != 0) { gameObject.SetLayerRecursively(gameLayer); } } if (name != null) { gameObject.name = name; } else { gameObject.name = original.name; } KPrefabID component = gameObject.GetComponent <KPrefabID>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { if (initialize_id) { component.InstanceID = KPrefabID.GetUniqueID(); KPrefabIDTracker.Get().Register(component); } KPrefabID component2 = original.GetComponent <KPrefabID>(); component.CopyTags(component2); component.CopyInitFunctions(component2); component.RunInstantiateFn(); } return(gameObject); }