/// <summary> /// Callback for a model Importation. /// Called on successful load. /// </summary> /// <param name="asset">Current asset</param> /// <param name="result">Result of the Importation</param> public void ImportAssetCallback(PolyAsset asset, PolyStatusOr <PolyImportResult> result) { if (!result.Ok) { return; } ColliderMaker.GenerateOn(result.Value.gameObject, true); Transform obj = result.Value.gameObject.transform; obj.position = currentlyLoading.position.get(); obj.rotation = Quaternion.Euler(currentlyLoading.eulerRotation.get()); obj.localScale = currentlyLoading.scale.get() / data.PlayerScale.x / ObjectToPlayerRatio; obj.SetParent(objectParent.transform); LoadNext(); }
/// <summary> /// Add a specific object to the Building Scene/Panel. /// </summary> /// <param name="parent">Specific object parent object</param> public void AddObject(GameObject parent) { GameObject child = parent.transform.GetChild(0).gameObject; if (child != null) { // Duplicate first found Child (as targetted object) GameObject obj = Instantiate(child, Vector3.zero, Quaternion.Euler(0, 0, 0), SceneContainer.transform); obj.transform.localScale /= obj.transform.lossyScale.x; // Modify its composure Destroy(obj.GetComponent <Rotate>()); obj.AddComponent <ObjectModel>().key = PolygonLoader.latestKey; ColliderMaker.GenerateOn(obj); obj.AddComponent <ObjectTransformer>().panel = buildPanel; // Remove the current object from parent if (parent.transform.childCount > 0) { Destroy(parent.transform.GetChild(0).gameObject); } } }