/// <summary> /// Adapt sprite scaling according to mesh size and user's wanted size /// </summary> private void SetFurni2DSize() { var s = m_currentFurniture.Size; var ms = m_currentFurniture.MeshSize; var sOnMs = new Vector3(s.x / ms.x, s.y / ms.y, s.z / ms.z); m_currentFurniture.associated2DObject.transform.localScale = VectorFunctions.Switch3D2D(sOnMs); m_currentFurniture.AdjustSpriteSize(); }
/// <summary> /// Force a furniture to rebuild gameobjects (scene data) and adjust the transforms /// </summary> /// <param name="f">Furniture data</param> private void RebuildFurniture(Furniture f) { f.RebuildSceneData(); if (f.IsCustom) { f.associated3DObject = ImportManager.Instance.GetGameObjectFromCustomObject(new CustomFurniture { Path = f.CustomPath, Name = f.Name }); f.associated3DObject.transform.parent = parent3D; AddCollider(f.associated3DObject); f.associated2DObject = Instantiate(backUpFurniture2DTop, parent2DTop); } else { // 3D f.associated3DObject = Instantiate(f.associated3DObject, parent3D); // 2D if (f.associated2DObject) { f.associated2DObject = Instantiate(f.associated2DObject, parent2DTop); } else { f.associated2DObject = Instantiate(backUpFurniture2DTop, parent2DTop); } } var s = f.Size; var ms = f.MeshSize; f.associated3DObject.transform.position = f.Position; f.associated3DObject.transform.localEulerAngles = f.EulerAngles; f.associated3DObject.transform.localScale = new Vector3(s.x / ms.x, s.y / ms.y, s.z / ms.z); f.associated3DObject.SetLayerRecursively((int)ErgoLayers.ThreeD); //f.associated3DObject.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; f.associated2DObject.transform.position = VectorFunctions .Switch3D2D(f .Position); // VectorFunctions.GetExactPositionFrom3DObject(f.associated2DObject, f.associated3DObject, f.Position); f.associated2DObject.transform.localEulerAngles = f.EulerAngles.y * Vector3.forward * -1f; f.associated2DObject.transform.localScale = VectorFunctions.Switch3D2D(new Vector3( f.Size.x / f.MeshSize.x, f.Size.y / f.MeshSize.y, f.Size.z / f.MeshSize.z )); f.associated2DObject.SetLayerRecursively((int)ErgoLayers.Top); f.associated3DObject.tag = "Furniture"; f.associated2DObject.tag = "Furniture"; InitFurnitureText(f); f.AdjustSpriteSize(); }