Свойства скрипта не отображаются в инспектореC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 Свойства скрипта не отображаются в инспекторе

Сообщение Anonymous »

У меня есть собственный скрипт юнита. Когда я добавляю его в игровой объект, свойства компонента не отображаются.
Вот снимок экрана редактора Unity:
Изображение

Я заметил, что в режиме отладки все отображается правильно:
Изображение

А вот мой код: https://pastebin.com/vBpAxtkL

Код: Выделить всё

using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public class CardPicker : MonoBehaviour
{
#region Variables
[SerializeField] int test = 18;
// Editor completed fields
[SerializeField] List cardPool = new List();

// Random
private System.Random random = new System.Random();
int totalWeight;
#endregion

#region Functions
private void Awake()
{
ProcessTotalWeight();
}

private void ProcessTotalWeight()
{
totalWeight = 0;
foreach (Card card in cardPool)
{
totalWeight += card.weight;
}
}

private InventoryCard PickCard()
{
int roll = random.Next(totalWeight + 1);

int sum = 0;
foreach (var card in cardPool)
{
sum += card.weight;
if (sum >= roll)
{
return new InventoryCard(card);
}
}
return new InventoryCard(cardPool[0]);
}

/// 
/// Pick a specified amount of cards, adding them to the inventory
/// 
/// 
The amount of cards to pick
public List PickCards(int amount, List inventory)
{
List cards = new List();
for (int i = 0; i < amount; i++)
{
InventoryCard card = PickCard();

// Select the cards of the same type already present in the inventory
var sameCards =
from c in inventory.Concat(cards)
where c.type == card.type
select c;

// If there is at least a card present, it's level is ugpraded
int present = 0;
foreach (InventoryCard c in sameCards)
{
present++;

if (present >= card.maxAvailable)
{
c.level += 1;
break;
}
}

// Else the card is normally picked
if (present < card.maxAvailable)
{
cards.Add(card);
}
}
Debug.Log($"(CardPicker) Picked {cards.Count} cards");
// Return the picked cards
return cards;
}
#endregion
}
Я использую Unity 2022.3.20f1.
Может ли кто-нибудь мне с этим помочь?

Подробнее здесь: https://stackoverflow.com/questions/786 ... -inspector
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»