Skip to content

Latest commit

 

History

History
135 lines (88 loc) · 4.01 KB

RelationshipsBetweenClasses.md

File metadata and controls

135 lines (88 loc) · 4.01 KB

日本語

Role of each class

Manages CMS imports. Saves necessary states.

Content being saved

  • Build destination path
  • Target languages (array)
  • Currently used CuvClient

Determines which CMS to use and which model to employ. Once implemented, it shows up in the dropdown of CuvImporter.

CMS types

  • Cockpit CMS
  • Google Sheets

File reference method

Attributes used in CuvClient

[IgnoreImporter] attribute

When specified, it will not be displayed in the dropdown list of CuvImporter.

[IgnoreImporter] // <--
public sealed class TestCockpitCuvClient : CockpitCuvClient<TestCockpitModel, TestCockpitCuvModelList>
{
    protected override JsonConverter<TestCockpitModel> CreateConverter()
        => new CuvModelConverter<TestCockpitModel>();
}

[CuvDisplayName("Name")] attribute

When specified, it allows you to change the name displayed in the dropdown list of CuvImporter.

[CuvDisplayName("YourCustomName")] // <--
public sealed class TestCockpitCuvClient : CockpitCuvClient<TestCockpitModel, TestCockpitCuvModelList>
{
    protected override JsonConverter<TestCockpitModel> CreateConverter()
        => new CuvModelConverter<TestCockpitModel>();
}

Generated by CuvClient. Saves data in target language-specific ScriptableObject. The model is stored in arrays and can be obtained with a Key.

Model. Corresponds to one article of data in CMS.

Determines how to reference the CuvModelList and creates a CuvReference. Once implemented, it shows up in the dropdown of CuvImporter.

Types

A ScriptableObject that manages references to the CuvModelList<T> stored by language. The user extracts data from here.

Component

CuvModelKey("ref") Attribute

Although it's fine to use the created CuvReference directly, it's convenient to use this component because it displays a drop-down list of the configured Key.

Pass the field name of the CuvReference you want to reference as an argument.

public abstract class Test : MonoBehaviour
{
    [SerializeField] GoogleSheetCuvReference _reference;
    [SerializeField, CuvModelKey("_reference")] string _key;

CuvComponent

A class that wraps the CuvModelKey to simplify usage.

using CMSuniVortex.Compornents;
using CMSuniVortex.GoogleSheet;
using UnityEngine;
using UnityEngine.UI;

public sealed class TestText : CuvComponent<GoogleSheetCuvReference>
{
    [SerializeField] Text _text;
        
    protected override void OnChangeLanguage(GoogleSheetCuvReference reference, string key)
    {
        if (reference.GetList().TryGetByKey(key, out var model))
        {
            _text.text = model.Text;
        }
    }
}

CuvAsyncComponent

Asynchronous version of the CuvComponent.

SetParam

By enclosing it with {}, you can embed parameters.

  • Statement You have earned {number} coins.
  • Display You have earned 5 coins.
var text = model.Text.SetParam("number", 5);