-добавил фичу в редактор, авто создание карточек -26 шкафов, 5 столов и 1 стул, но там пизда центрам
This commit is contained in:
1 parent
11f626bd8b
commit
2fd7b76285
202 files changed
+11425
-254
No files matched your search
@@ -18,16 +18,30 @@ public class FurnitureObject : MonoBehaviour
|
||||
|
||||
private void CreateHighlightBox()
|
||||
{
|
||||
BoxCollider col = GetComponent<BoxCollider>();
|
||||
if (col == null) return;
|
||||
// Ищем ВСЕ коллайдеры на объекте
|
||||
BoxCollider[] colliders = GetComponents<BoxCollider>();
|
||||
if (colliders.Length == 0) return;
|
||||
|
||||
// Создаем "виртуальную коробку", которая охватит первый коллайдер
|
||||
Bounds totalBounds = new Bounds(colliders[0].center, colliders[0].size);
|
||||
|
||||
// Добавляем в эту коробку все остальные коллайдеры (для формы буквы Г)
|
||||
for (int i = 1; i < colliders.Length; i++)
|
||||
{
|
||||
Bounds b = new Bounds(colliders[i].center, colliders[i].size);
|
||||
totalBounds.Encapsulate(b);
|
||||
}
|
||||
|
||||
_highlightBox = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
Destroy(_highlightBox.GetComponent<Collider>());
|
||||
|
||||
_highlightBox.transform.SetParent(transform);
|
||||
_highlightBox.transform.localPosition = col.center;
|
||||
|
||||
// Ставим зеленую коробку в общий центр и задаем общий размер
|
||||
_highlightBox.transform.localPosition = totalBounds.center;
|
||||
_highlightBox.transform.localRotation = Quaternion.identity;
|
||||
_highlightBox.transform.localScale = col.size;
|
||||
// Умножаем на 1.02, чтобы зеленая коробка была чуть-чуть больше мебели (для красоты)
|
||||
_highlightBox.transform.localScale = totalBounds.size * 1.02f;
|
||||
|
||||
_highlightMaterial = new Material(Shader.Find("Sprites/Default"));
|
||||
_highlightBox.GetComponent<Renderer>().material = _highlightMaterial;
|
||||
|
||||
Reference in new issue
Block a user