private IEnumerator processDecoration(DecorationLayoutData decoration, PrefabContentKey contentKey) { PrefabCacheTracker.PrefabRequest prefabRequest = prefabCacheTracker.Acquire(contentKey); while (!prefabRequest.IsComplete) { yield return(null); } yield return(new WaitForEndOfFrame()); while (loadOrder.Peek() != decoration.Id.GetFullPath()) { yield return(null); } string idFromQueue = loadOrder.Dequeue(); Assert.IsTrue(idFromQueue == decoration.Id.GetFullPath()); if (prefabRequest != null && prefabRequest.Prefab != null) { bool flag = true; Transform transform = Container.Find(decoration.Id.ParentPath); if (transform == null) { if (string.IsNullOrEmpty(decoration.Id.ParentPath)) { transform = Container; } else { Log.LogErrorFormatted(this, "Invalid path of decoration. Removing from layout: {0}", decoration.Id.GetFullPath()); layout.RemoveDecoration(decoration, deleteChildren: true); flag = false; } } if (flag) { GameObject gameObject = UnityEngine.Object.Instantiate(prefabRequest.Prefab, transform, worldPositionStays: false); SplittableObject component = gameObject.GetComponent <SplittableObject>(); Vector3 localScale = gameObject.transform.localScale; if (component != null) { gameObject = component.ExtractSingleItem(); gameObject.transform.SetParent(transform, worldPositionStays: false); } configurePartneredObject(decoration, gameObject); gameObject.transform.localPosition = decoration.Position; gameObject.transform.localRotation = decoration.Rotation; gameObject.name = decoration.Id.Name; gameObject.transform.localScale = decoration.UniformScale * localScale; prefabCacheTracker.SetCache(gameObject, prefabRequest.ContentKey); } } else { Log.LogErrorFormatted(this, "Something went wrong loading {0}.", contentKey.Key); prefabCacheTracker.Release(contentKey); } checkForLoadComplete(); }
private void onNewObjectLoaded(GameObject prefab, PrefabCacheTracker.PrefabRequest request, Vector3 worldPosition, Quaternion rotation, Vector3 scale, DecorationLayoutData data, bool setManipulationInputStateToDrag) { if (prefab == null) { Log.LogErrorFormatted(this, "Prefab was null"); return; } GameObject gameObject = UnityEngine.Object.Instantiate(prefab, sceneLayoutContainer); if (gameObject == null) { Log.LogErrorFormatted(this, "Instantiate returned a null game object for prefab {0}", prefab); return; } isNewObject = true; prefabCacheTracker.SetCache(gameObject, request.ContentKey); gameObject.transform.position = worldPosition; gameObject.transform.rotation = rotation; gameObject.transform.localScale = scale; ManipulatableObject arg = addObjectManipulator(gameObject, data); ObjectManipulationInputController.SelectState setSelectStateTo = ((!setManipulationInputStateToDrag) ? ObjectManipulationInputController.SelectState.Active : ObjectManipulationInputController.SelectState.Drag); if (ObjectManipulationInputController != null) { ObjectManipulationInputController.SelectNewObject(gameObject, setSelectStateTo); } SplittableObject component = gameObject.GetComponent <SplittableObject>(); if (component != null) { if (SceneLayoutData.LayoutCount >= SceneLayoutData.MaxLayoutItems - 2) { UnityEngine.Object.Destroy(gameObject); ResetAfterMaxReached(); } else { component.SetObjectManipulationController(ObjectManipulationInputController); component.ChildrenSplit += onSplittableObjectChildrenSplit; } } selectedObjectStartingId = null; this.NewObjectCreated.InvokeSafe(arg); }