fix чать инвенторя
This commit is contained in:
@@ -1,31 +1,45 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Animations;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
/// <summary>
|
||||
/// Инструмент создания полного игрока с опциональным инвентарём.
|
||||
/// Tools > Player Builder
|
||||
/// </summary>
|
||||
public class PlayerBuilderTool : EditorWindow
|
||||
{
|
||||
// Модель
|
||||
// ── Модель ────────────────────────────────────────────────────────────────
|
||||
private GameObject characterModel;
|
||||
private Transform headBone;
|
||||
private Transform headBone;
|
||||
private Transform handBone;
|
||||
|
||||
// Параметры движения
|
||||
private float walkSpeed = 5f;
|
||||
private float runSpeed = 9f;
|
||||
// ── Параметры движения ────────────────────────────────────────────────────
|
||||
private float walkSpeed = 5f;
|
||||
private float runSpeed = 9f;
|
||||
private float crouchSpeed = 2.5f;
|
||||
private float jumpHeight = 1.5f;
|
||||
private float gravity = -9.81f;
|
||||
private float jumpHeight = 1.5f;
|
||||
private float gravity = -9.81f;
|
||||
|
||||
// Коллайдер
|
||||
private float height = 1.8f;
|
||||
private float radius = 0.5f;
|
||||
// ── Коллайдер ─────────────────────────────────────────────────────────────
|
||||
private float height = 1.8f;
|
||||
private float radius = 0.5f;
|
||||
private float centerY = 0.9f;
|
||||
|
||||
// Камера
|
||||
private bool addCamera = true;
|
||||
// ── Камера ────────────────────────────────────────────────────────────────
|
||||
private bool addCamera = true;
|
||||
private float cameraHeight = 1.7f;
|
||||
|
||||
// Анимации
|
||||
// ── Инвентарь ─────────────────────────────────────────────────────────────
|
||||
private bool includeInventory = true;
|
||||
private int inventorySlots = 36;
|
||||
private int hotbarSlots = 9;
|
||||
|
||||
// ── Input Actions ─────────────────────────────────────────────────────────
|
||||
private UnityEngine.InputSystem.InputActionAsset inputActions;
|
||||
|
||||
// ── Анимации ──────────────────────────────────────────────────────────────
|
||||
private AnimationClip idleClip;
|
||||
private AnimationClip walkClip;
|
||||
private AnimationClip runClip;
|
||||
@@ -33,9 +47,8 @@ public class PlayerBuilderTool : EditorWindow
|
||||
private AnimationClip crouchIdleClip;
|
||||
private AnimationClip crouchWalkClip;
|
||||
|
||||
// Аниматор контроллер
|
||||
private AnimatorController animatorController;
|
||||
private bool createAnimatorController = true;
|
||||
// ── Scroll ────────────────────────────────────────────────────────────────
|
||||
private Vector2 _scroll;
|
||||
|
||||
[MenuItem("Tools/Player Builder")]
|
||||
public static void ShowWindow()
|
||||
@@ -45,97 +58,121 @@ public class PlayerBuilderTool : EditorWindow
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Настройки персонажа", EditorStyles.boldLabel);
|
||||
_scroll = EditorGUILayout.BeginScrollView(_scroll);
|
||||
|
||||
// Секция модели
|
||||
GUILayout.Label("Конструктор Персонажа", EditorStyles.boldLabel);
|
||||
|
||||
// ── Секция модели ─────────────────────────────────────────────────────
|
||||
GUILayout.Space(6);
|
||||
GUILayout.Label("Модель", EditorStyles.miniBoldLabel);
|
||||
characterModel = (GameObject)EditorGUILayout.ObjectField("Модель персонажа", characterModel, typeof(GameObject), false);
|
||||
headBone = (Transform)EditorGUILayout.ObjectField("Кость головы", headBone, typeof(Transform), true);
|
||||
headBone = (Transform)EditorGUILayout.ObjectField("Кость головы (Head)", headBone, typeof(Transform), true);
|
||||
handBone = (Transform)EditorGUILayout.ObjectField("Кость руки (RightHand)", handBone, typeof(Transform), true);
|
||||
|
||||
GUILayout.Space(10);
|
||||
if (characterModel != null && GUILayout.Button("Автопоиск костей Head/Hand"))
|
||||
AutoFindBones();
|
||||
|
||||
// Секция движения
|
||||
// ── Движение ──────────────────────────────────────────────────────────
|
||||
GUILayout.Space(6);
|
||||
GUILayout.Label("Движение", EditorStyles.miniBoldLabel);
|
||||
walkSpeed = EditorGUILayout.FloatField("Скорость ходьбы", walkSpeed);
|
||||
runSpeed = EditorGUILayout.FloatField("Скорость бега", runSpeed);
|
||||
crouchSpeed = EditorGUILayout.FloatField("Скорость краулинга", crouchSpeed);
|
||||
jumpHeight = EditorGUILayout.FloatField("Высота прыжка", jumpHeight);
|
||||
gravity = EditorGUILayout.FloatField("Гравитация", gravity);
|
||||
walkSpeed = EditorGUILayout.FloatField("Скорость ходьбы", walkSpeed);
|
||||
runSpeed = EditorGUILayout.FloatField("Скорость бега", runSpeed);
|
||||
crouchSpeed = EditorGUILayout.FloatField("Скорость присядки", crouchSpeed);
|
||||
jumpHeight = EditorGUILayout.FloatField("Высота прыжка", jumpHeight);
|
||||
gravity = EditorGUILayout.FloatField("Гравитация", gravity);
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
// Секция коллайдера
|
||||
GUILayout.Label("Коллайдер", EditorStyles.miniBoldLabel);
|
||||
height = EditorGUILayout.FloatField("Высота", height);
|
||||
radius = EditorGUILayout.FloatField("Радиус", radius);
|
||||
// ── Коллайдер ─────────────────────────────────────────────────────────
|
||||
GUILayout.Space(6);
|
||||
GUILayout.Label("Коллайдер CharacterController", EditorStyles.miniBoldLabel);
|
||||
height = EditorGUILayout.FloatField("Высота", height);
|
||||
radius = EditorGUILayout.FloatField("Радиус", radius);
|
||||
centerY = EditorGUILayout.FloatField("Центр Y", centerY);
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
// Секция камеры
|
||||
// ── Камера ────────────────────────────────────────────────────────────
|
||||
GUILayout.Space(6);
|
||||
GUILayout.Label("Камера", EditorStyles.miniBoldLabel);
|
||||
addCamera = EditorGUILayout.Toggle("Добавить камеру", addCamera);
|
||||
addCamera = EditorGUILayout.Toggle("Добавить камеру", addCamera);
|
||||
if (addCamera)
|
||||
{
|
||||
cameraHeight = EditorGUILayout.Slider("Высота камеры", cameraHeight, 1f, 2f);
|
||||
|
||||
// ── Input Actions ─────────────────────────────────────────────────────
|
||||
GUILayout.Space(6);
|
||||
GUILayout.Label("Input System", EditorStyles.miniBoldLabel);
|
||||
inputActions = (UnityEngine.InputSystem.InputActionAsset)EditorGUILayout.ObjectField(
|
||||
"PlayerControls.inputactions",
|
||||
inputActions,
|
||||
typeof(UnityEngine.InputSystem.InputActionAsset),
|
||||
false);
|
||||
if (inputActions == null)
|
||||
EditorGUILayout.HelpBox("Назначьте Assets/Input/PlayerControls.inputactions", MessageType.Warning);
|
||||
|
||||
// ── Инвентарь ─────────────────────────────────────────────────────────
|
||||
GUILayout.Space(6);
|
||||
GUILayout.Label("Инвентарь", EditorStyles.miniBoldLabel);
|
||||
includeInventory = EditorGUILayout.Toggle("Включить инвентарь", includeInventory);
|
||||
if (includeInventory)
|
||||
{
|
||||
inventorySlots = EditorGUILayout.IntField("Слотов инвентаря", inventorySlots);
|
||||
hotbarSlots = EditorGUILayout.IntField("Слотов хотбара", hotbarSlots);
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
// Секция анимаций
|
||||
GUILayout.Label("Анимации", EditorStyles.miniBoldLabel);
|
||||
createAnimatorController = EditorGUILayout.Toggle("Создать контроллер", createAnimatorController);
|
||||
idleClip = (AnimationClip)EditorGUILayout.ObjectField("Idle", idleClip, typeof(AnimationClip), false);
|
||||
walkClip = (AnimationClip)EditorGUILayout.ObjectField("Walk", walkClip, typeof(AnimationClip), false);
|
||||
runClip = (AnimationClip)EditorGUILayout.ObjectField("Run", runClip, typeof(AnimationClip), false);
|
||||
jumpClip = (AnimationClip)EditorGUILayout.ObjectField("Jump", jumpClip, typeof(AnimationClip), false);
|
||||
// ── Анимации ──────────────────────────────────────────────────────────
|
||||
GUILayout.Space(6);
|
||||
GUILayout.Label("Анимации (опционально)", EditorStyles.miniBoldLabel);
|
||||
idleClip = (AnimationClip)EditorGUILayout.ObjectField("Idle", idleClip, typeof(AnimationClip), false);
|
||||
walkClip = (AnimationClip)EditorGUILayout.ObjectField("Walk", walkClip, typeof(AnimationClip), false);
|
||||
runClip = (AnimationClip)EditorGUILayout.ObjectField("Run", runClip, typeof(AnimationClip), false);
|
||||
jumpClip = (AnimationClip)EditorGUILayout.ObjectField("Jump", jumpClip, typeof(AnimationClip), false);
|
||||
crouchIdleClip = (AnimationClip)EditorGUILayout.ObjectField("Crouch Idle", crouchIdleClip, typeof(AnimationClip), false);
|
||||
crouchWalkClip = (AnimationClip)EditorGUILayout.ObjectField("Crouch Walk", crouchWalkClip, typeof(AnimationClip), false);
|
||||
|
||||
if (characterModel != null)
|
||||
{
|
||||
var animator = characterModel.GetComponent<Animator>();
|
||||
if (animator != null && animator.avatar != null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Модель содержит Animator - аватар будет скопирован", MessageType.Info);
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(20);
|
||||
|
||||
// Кнопки действий
|
||||
// ── Кнопки ────────────────────────────────────────────────────────────
|
||||
GUI.color = Color.green;
|
||||
if (GUILayout.Button("Создать в сцене"))
|
||||
{
|
||||
if (GUILayout.Button("Создать игрока" + (includeInventory ? " + Инвентарь" : "")))
|
||||
BuildPlayer("Player");
|
||||
}
|
||||
|
||||
GUI.color = Color.yellow;
|
||||
if (GUILayout.Button("Создать тестового игрока (капсула)"))
|
||||
BuildTestPlayer();
|
||||
|
||||
GUI.color = Color.cyan;
|
||||
if (GUILayout.Button("Сохранить как префаб"))
|
||||
{
|
||||
SaveAsPrefab();
|
||||
}
|
||||
|
||||
GUI.color = Color.yellow;
|
||||
if (GUILayout.Button("Создать с тестовой моделью (капсула)"))
|
||||
{
|
||||
BuildTestPlayer();
|
||||
}
|
||||
|
||||
GUI.color = Color.white;
|
||||
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.HelpBox(
|
||||
"1. Назначьте модель персонажа\n" +
|
||||
"2. Назначьте анимации (опционально)\n" +
|
||||
"3. Настройте параметры\n" +
|
||||
"4. Нажмите 'Создать в сцене'",
|
||||
"1. Назначьте модель персонажа (опционально)\n" +
|
||||
"2. Укажите кость головы и кость руки\n" +
|
||||
"3. Назначьте PlayerControls.inputactions\n" +
|
||||
"4. Нажмите 'Создать игрока'",
|
||||
MessageType.Info);
|
||||
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
void BuildPlayer(string playerName)
|
||||
// ── Автопоиск костей ─────────────────────────────────────────────────────
|
||||
|
||||
void AutoFindBones()
|
||||
{
|
||||
GameObject player = new GameObject(playerName);
|
||||
if (characterModel == null) return;
|
||||
headBone = FindChildBone(characterModel.transform, "head") ??
|
||||
FindChildBone(characterModel.transform, "Head");
|
||||
handBone = FindChildBone(characterModel.transform, "hand_r") ??
|
||||
FindChildBone(characterModel.transform, "RightHand") ??
|
||||
FindChildBone(characterModel.transform, "Hand_R") ??
|
||||
FindChildBone(characterModel.transform, "hand");
|
||||
Debug.Log($"[PlayerBuilder] Head: {headBone?.name ?? "не найдена"}, Hand: {handBone?.name ?? "не найдена"}");
|
||||
}
|
||||
|
||||
// ── Создание игрока ───────────────────────────────────────────────────────
|
||||
|
||||
GameObject BuildPlayerGO(string playerName)
|
||||
{
|
||||
var player = new GameObject(playerName);
|
||||
|
||||
// CharacterController
|
||||
var cc = player.AddComponent<CharacterController>();
|
||||
@@ -145,31 +182,27 @@ public class PlayerBuilderTool : EditorWindow
|
||||
|
||||
// Скрипт персонажа
|
||||
var character = player.AddComponent<charecter>();
|
||||
character.walkSpeed = walkSpeed;
|
||||
character.runSpeed = runSpeed;
|
||||
character.walkSpeed = walkSpeed;
|
||||
character.runSpeed = runSpeed;
|
||||
character.crouchSpeed = crouchSpeed;
|
||||
character.jumpHeight = jumpHeight;
|
||||
character.gravity = gravity;
|
||||
character.jumpHeight = jumpHeight;
|
||||
character.gravity = gravity;
|
||||
|
||||
// Модель
|
||||
GameObject model = null;
|
||||
Transform resolvedHead = headBone;
|
||||
Transform resolvedHand = handBone;
|
||||
|
||||
if (characterModel != null)
|
||||
{
|
||||
model = Instantiate(characterModel, player.transform);
|
||||
var model = (GameObject)PrefabUtility.InstantiatePrefab(characterModel, player.transform);
|
||||
model.transform.localPosition = Vector3.zero;
|
||||
model.transform.localRotation = Quaternion.identity;
|
||||
|
||||
// Голова
|
||||
if (headBone != null)
|
||||
{
|
||||
character.head = headBone;
|
||||
}
|
||||
else
|
||||
{
|
||||
character.head = FindChildBone(model.transform, "Head");
|
||||
}
|
||||
if (resolvedHead == null)
|
||||
resolvedHead = FindChildBone(model.transform, "head") ?? FindChildBone(model.transform, "Head");
|
||||
if (resolvedHand == null)
|
||||
resolvedHand = FindChildBone(model.transform, "hand_r") ?? FindChildBone(model.transform, "RightHand");
|
||||
|
||||
//Animator
|
||||
var modelAnimator = model.GetComponent<Animator>();
|
||||
if (modelAnimator != null && modelAnimator.avatar != null)
|
||||
{
|
||||
@@ -178,121 +211,149 @@ public class PlayerBuilderTool : EditorWindow
|
||||
}
|
||||
}
|
||||
|
||||
// Голова если не найдена
|
||||
if (character.head == null)
|
||||
// Кость головы (или создаём точку)
|
||||
if (resolvedHead == null)
|
||||
{
|
||||
GameObject headObj = new GameObject("HeadPoint");
|
||||
headObj.transform.SetParent(model != null ? model.transform : player.transform);
|
||||
var headObj = new GameObject("HeadPoint");
|
||||
headObj.transform.SetParent(player.transform);
|
||||
headObj.transform.localPosition = new Vector3(0, height - 0.2f, 0);
|
||||
character.head = headObj.transform;
|
||||
resolvedHead = headObj.transform;
|
||||
}
|
||||
character.head = resolvedHead;
|
||||
|
||||
// Камера
|
||||
if (addCamera && character.head != null)
|
||||
if (addCamera)
|
||||
{
|
||||
GameObject cameraObj = new GameObject("PlayerCamera");
|
||||
cameraObj.transform.SetParent(character.head);
|
||||
cameraObj.transform.localPosition = new Vector3(0, 0.1f, 0);
|
||||
var camObj = new GameObject("PlayerCamera");
|
||||
camObj.transform.SetParent(resolvedHead);
|
||||
camObj.transform.localPosition = new Vector3(0, 0.1f, 0);
|
||||
var cam = camObj.AddComponent<Camera>();
|
||||
cam.tag = "MainCamera";
|
||||
cam.nearClipPlane = 0.05f;
|
||||
|
||||
var cam = cameraObj.AddComponent<Camera>();
|
||||
cam.tag = "MainCamera";
|
||||
cam.nearClipPlane = 0.1f;
|
||||
|
||||
// Удалить старую
|
||||
var oldCam = GameObject.FindWithTag("MainCamera");
|
||||
if (oldCam != null && oldCam != cameraObj)
|
||||
{
|
||||
if (oldCam != null && oldCam != camObj)
|
||||
DestroyImmediate(oldCam);
|
||||
}
|
||||
}
|
||||
|
||||
// Тег
|
||||
player.tag = "Player";
|
||||
// PlayerInput
|
||||
var piGO = new GameObject("PlayerInput");
|
||||
var pi = piGO.AddComponent<PlayerInput>();
|
||||
if (inputActions != null) pi.actions = inputActions;
|
||||
|
||||
// Позиция
|
||||
// HandEquipSystem
|
||||
if (resolvedHand != null)
|
||||
{
|
||||
var handEquip = player.AddComponent<HandEquipSystem>();
|
||||
handEquip.handBone = resolvedHand;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[PlayerBuilder] Кость руки не найдена — HandEquipSystem не добавлен. Назначьте вручную.");
|
||||
}
|
||||
|
||||
player.tag = "Player";
|
||||
player.transform.position = new Vector3(0, 2, -5);
|
||||
|
||||
Selection.activeGameObject = player;
|
||||
Debug.Log($"[PlayerBuilder] Создан: {playerName}");
|
||||
// Инвентарь
|
||||
if (includeInventory)
|
||||
SetupInventoryForPlayer(player);
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
void SaveAsPrefab()
|
||||
void BuildPlayer(string name)
|
||||
{
|
||||
string path = EditorUtility.SaveFilePanelInProject(
|
||||
"Сохранить префаб",
|
||||
"Player",
|
||||
"prefab",
|
||||
"Выберите место");
|
||||
|
||||
if (string.IsNullOrEmpty(path)) return;
|
||||
|
||||
BuildPlayer("PlayerTemp");
|
||||
|
||||
GameObject player = GameObject.Find("PlayerTemp");
|
||||
if (player == null)
|
||||
{
|
||||
Debug.LogError("Не удалось создать игрока");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject prefab = PrefabUtility.SaveAsPrefabAsset(player, path);
|
||||
DestroyImmediate(player);
|
||||
|
||||
Selection.activeObject = prefab;
|
||||
Debug.Log($"[PlayerBuilder] Сохранено: {path}");
|
||||
var player = BuildPlayerGO(name);
|
||||
Selection.activeGameObject = player;
|
||||
Debug.Log($"[PlayerBuilder] Создан: {name}");
|
||||
}
|
||||
|
||||
void BuildTestPlayer()
|
||||
{
|
||||
var savedModel = characterModel;
|
||||
characterModel = null;
|
||||
headBone = null;
|
||||
BuildPlayer("TestPlayer");
|
||||
var player = BuildPlayerGO("TestPlayer");
|
||||
characterModel = savedModel;
|
||||
|
||||
GameObject player = Selection.activeGameObject;
|
||||
if (player == null) return;
|
||||
|
||||
// Создаём визуальную часть
|
||||
GameObject body = GameObject.CreatePrimitive(PrimitiveType.Capsule);
|
||||
// Визуальная капсула
|
||||
var body = GameObject.CreatePrimitive(PrimitiveType.Capsule);
|
||||
body.name = "Body";
|
||||
body.transform.SetParent(player.transform);
|
||||
body.transform.localPosition = Vector3.zero;
|
||||
body.transform.SetParent(player.transform, false);
|
||||
body.transform.localPosition = new Vector3(0, centerY, 0);
|
||||
body.transform.localScale = new Vector3(radius * 2, height / 2f, radius * 2);
|
||||
DestroyImmediate(body.GetComponent<Collider>());
|
||||
|
||||
GameObject head = new GameObject("Head");
|
||||
head.transform.SetParent(player.transform);
|
||||
head.transform.localPosition = new Vector3(0, centerY + 0.2f, 0);
|
||||
|
||||
var character = player.GetComponent<charecter>();
|
||||
if (character != null)
|
||||
{
|
||||
character.head = head.transform;
|
||||
}
|
||||
|
||||
if (addCamera)
|
||||
{
|
||||
GameObject camObj = new GameObject("PlayerCamera");
|
||||
camObj.transform.SetParent(head.transform);
|
||||
camObj.transform.localPosition = new Vector3(0, 0.1f, 0);
|
||||
var cam = camObj.AddComponent<Camera>();
|
||||
cam.tag = "MainCamera";
|
||||
|
||||
var oldCam = GameObject.FindWithTag("MainCamera");
|
||||
if (oldCam != null && oldCam != camObj)
|
||||
{
|
||||
DestroyImmediate(oldCam);
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log("[PlayerBuilder] Создан тестовый игрок");
|
||||
Selection.activeGameObject = player;
|
||||
Debug.Log("[PlayerBuilder] Создан тестовый игрок (капсула)");
|
||||
}
|
||||
|
||||
void SaveAsPrefab()
|
||||
{
|
||||
string path = EditorUtility.SaveFilePanelInProject("Сохранить префаб", "Player", "prefab", "Выберите место");
|
||||
if (string.IsNullOrEmpty(path)) return;
|
||||
|
||||
var temp = BuildPlayerGO("PlayerTemp");
|
||||
var prefab = PrefabUtility.SaveAsPrefabAsset(temp, path);
|
||||
DestroyImmediate(temp);
|
||||
Selection.activeObject = prefab;
|
||||
Debug.Log($"[PlayerBuilder] Сохранено: {path}");
|
||||
}
|
||||
|
||||
// ── Создание инвентаря ────────────────────────────────────────────────────
|
||||
|
||||
void SetupInventoryForPlayer(GameObject player)
|
||||
{
|
||||
// EventSystem
|
||||
if (FindObjectOfType<EventSystem>() == null)
|
||||
{
|
||||
var esGO = new GameObject("EventSystem");
|
||||
esGO.AddComponent<EventSystem>();
|
||||
esGO.AddComponent<StandaloneInputModule>();
|
||||
}
|
||||
|
||||
// InventoryEvents
|
||||
new GameObject("InventoryEvents").AddComponent<InventoryEvents>();
|
||||
|
||||
// InventoryManager
|
||||
var imGO = new GameObject("InventoryManager");
|
||||
var im = imGO.AddComponent<InventoryManager>();
|
||||
im.inventorySize = inventorySlots;
|
||||
|
||||
// InventoryCanvas — дочерний объект Player
|
||||
var canvasGO = new GameObject("InventoryCanvas");
|
||||
canvasGO.transform.SetParent(player.transform, false);
|
||||
|
||||
var canvas = canvasGO.AddComponent<Canvas>();
|
||||
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
canvas.sortingOrder = 100;
|
||||
canvasGO.AddComponent<UnityEngine.UI.GraphicRaycaster>();
|
||||
|
||||
var uiBuilder = canvasGO.AddComponent<InventoryUIBuilder>();
|
||||
uiBuilder.inventoryRows = inventorySlots / 9;
|
||||
uiBuilder.hotbarSlots = hotbarSlots;
|
||||
|
||||
// Строим UI сразу до запуска игры
|
||||
uiBuilder.BuildInventoryUI();
|
||||
|
||||
// Назначаем ссылки в InventoryManager
|
||||
im.slots = uiBuilder.GetInventorySlots();
|
||||
im.hotbarSlots = uiBuilder.GetHotbarSlots();
|
||||
im.inventoryPanel = uiBuilder.inventoryPanelRect != null ? uiBuilder.inventoryPanelRect.gameObject : null;
|
||||
im.inventoryCanvas = canvas;
|
||||
|
||||
if (im.inventoryPanel != null)
|
||||
im.inventoryPanel.SetActive(false);
|
||||
|
||||
Debug.Log("[PlayerBuilder] Инвентарь создан и назначен.");
|
||||
}
|
||||
|
||||
// ── Утилиты ───────────────────────────────────────────────────────────────
|
||||
|
||||
Transform FindChildBone(Transform parent, string boneName)
|
||||
{
|
||||
if (parent == null) return null;
|
||||
|
||||
if (parent.name.ToLower().Contains(boneName.ToLower()))
|
||||
return parent;
|
||||
|
||||
if (parent.name.ToLower().Contains(boneName.ToLower())) return parent;
|
||||
foreach (Transform child in parent)
|
||||
{
|
||||
var result = FindChildBone(child, boneName);
|
||||
@@ -300,4 +361,4 @@ public class PlayerBuilderTool : EditorWindow
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user