Ananke Csv Master 7.Using Data In Your Game

Back to Table of Contents

Overview

This section explains how to use ScriptableObject instance values in your game.

While we’ll demonstrate a simple implementation, in production you’d typically use systems like Addressables for dynamic loading.

For this example, we’ll create a Singleton GameObject with ScriptableObject references.

Creating MasterDataHolder

First, create a MasterDataHolder class (you can use any class name) to maintain master data.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using CatHut;

public class MasterDataHolder : SingletonMonoBehaviour<MasterDataHolder>
{
    public Player PlayerData;
}

Attach the component to your GameObject. After compilation completes, you’ll see the PlayerData field appear in the Inspector. You can then click the selector dot to assign the generated asset.

If the asset doesn’t appear, there might be an issue with asset generation. If no errors are present.

try triggering a reimport by either:
・Modifying the CSV
・Using Tools > CatHut > AnankeCsvMaster > Import All Csv

Accessing Master Data

To access master data from other classes using MasterDataHolder, use the following pattern:

GroupNameData.DataSetNameData[id].PropertyName

The data is stored in Dictionary format. You can also access properties using string indexers, though this requires casting:

        // Duplicatable = false の場合
        // [key].Property
        var temp01 = MasterDataHolder.Instance.PlayerData.CharacterData["p001"].Name;
        // access by PropertyName
        var temp02 = MasterDataHolder.Instance.PlayerData.CharacterData["p001"]["Name"] as string; 

Important Considerations

While setting up references as MonoBehaviour fields is straightforward, remember that deleting instances will break these links. It’s recommended to implement a robust loading system using Addressables or similar solutions for production environments.

Conclusion

This covers the basic usage of AnankeCsvMaster. For advanced usage patterns, please refer to the following sections once you’re comfortable with these basics.

Next

Advanced

コメント

タイトルとURLをコピーしました