I am trying to write a custom script.
I think it is because Unity is not able to read the namespace information from the dll.
Is there any setup required?

Error detail below:

The type or namespace name 'Editor' does not exist in the namespace 'GamingIsLove.Makinom' (are you missing an assembly reference?)


My code:

using UnityEditor;
using UnityEngine;

using GamingIsLove.Makinom;
using GamingIsLove.Makinom.Editor;
using GamingIsLove.ORKFramework.Components;
using GamingIsLove.ORKFramework;

public class Items : MonoBehaviour
{
public void ListItems()
{
MakinomProjectAsset project = MakinomAssetHelper.LoadProjectAsset();
ORKGenericAssetListTab<ItemAsset, Item> items = new ItemsSettings(project.Makinom);
......
}
}

  • Editor code has to be within an Editor folder or a subfolder of an Editor folder. ORK/Makinom editor code is also under an Editor folder and can't be accessed in 'gameplay' code.

    Also, you can't mix editor and gameplay stuff together :)
    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!
  • I made a silly mistake.
    Thank you for telling me.

    I have a another question.

    I want to get an AssetList from an itemTab.
    However, assetList is protected level in GenericAssetListTab.
    Is there any use case in mind to customize the Editor?
    I would like to create a function to read CSV and add ItemAsset to the List.
  • edited October 2023
    Solved.
    I get/set item prices on Editor mode.

    below:

    using System.Collections.Generic;

    using UnityEditor;
    using UnityEngine;

    using GamingIsLove.Makinom;
    using GamingIsLove.ORKFramework;

    public void ListItems()
    {
    ORKDataHandlerCache dataCache = new ORKDataHandlerCache();
    ItemsSettings itemsSettings = dataCache.Items;
    int num = itemsSettings.Count;
    Item[] items = new Item[num];
    for (int i = 0; i < num; i++)
    {
    items[i] = itemsSettings.Get(i);
    }
    foreach (Item item in items)
    {
    updateValue(item, 100.0f); // from csv
    showItemMinimal(item);
    }
    }
    private void showItemMinimal(Item item)
    {
    Debug.Log("===Item===");
    Debug.Log(" Name: " + item.DataName);
    Debug.Log(" Type Name: " + item.itemType.settings.EditorAsset.name);
    Debug.Log(" price: " + item.price.buyPriceValue.ToString());
    }
    private void updateValue(Item item, float value)
    {
    FloatValue<GameObjectSelection> fv = new FloatValue<GameObjectSelection>(value);
    item.price.buyPriceValue.SetData(fv.GetData());
    }
    }
    Post edited by forestsource on
  • You don't need to get them from the item tab specifically to access those assets in editor code. You can get any asset list via the EditorDataHandler class:

    GenericAssetList<T> assetList = EditorDataHandler.Instance.GetAssets<T>();
    Simply replace T with the asset class you want to get, e.g. ItemAsset for items.
    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.