Hello,

For example can I show List of ORK combatants or Currencies or Certain type items, in unity inspector from custom script.
So for example player can choose from the list of created currencies in Unity Inspector?

  • Yes, but you'll have to write a custom inspector for your components. Selecting data is done through a popup, e.g.:

    target.currencyID = EditorGUILayout.Popup("Currency", target.currencyID, ORK.Currencies.GetNames(true));

    target is the component your custom inspector is editing.
    currencyID is an int field storing the selected currency.
    The GetNames function returns a name list of all available data (in this case for currencies). You can use the same functionality for other data selection (e.g. for combatants it's ORK.Combatants.GetNames(true)).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thank you, I get this error in inspector though

    NullReferenceException: Object reference not set to an instance of an object
    ORKFramework.ORK.get_Currencies ()

    for this code
    public override void OnInspectorGUI()
    {
    DrawDefaultInspector();
    Building myTarget = (Building)target;

    for (int i = 0; i < myTarget.LevelingSettings.Length; i++)
    {
    for (int j = 0; j < myTarget.LevelingSettings[i].LevelingCost.Length; j++)
    {
    myTarget.LevelingSettings[i].LevelingCost[j].Value = EditorGUILayout.Popup("Currency", (int)myTarget.LevelingSettings[i].LevelingCost[j].Value, ORK.Currencies.GetNames(false));
    }
    }
    }
  • I'm using OrkFramework namespace so this is not an issue.
    Also this error gets fixed if I once click play in editor but every time I change code it comes back again.
  • hello @hellwalker, my guess is that you need to initialize ORK before trying to access its database, that´s why it works when in Play mode
  • Yeah, you need to initialize ORK, e.g. put this code at the start of your inspector:

    if(!ORK.Instantiated)
    {
    ORK.Initialize(ORKAssetHelper.LoadORKProject());
    }
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.