line / line-sdk-unity

Provides a modern way of implementing LINE APIs in Unity games, for iOS and Android.
https://developers.line.biz/
Apache License 2.0
117 stars 24 forks source link

Request to Change the Timing of SetupSDK() Call in LineSDK. #67

Closed k0uhe1D closed 8 months ago

k0uhe1D commented 8 months ago

Is it a security issue?

No, this is not a security issue.

What did you do?

I am implementing a feature to change the channelID based on the env from an external class.

What did you expect?

I expected to be able to change the channelID after LineSDK.Awake() is called.

What happened actually?

Currently, SetupSDK() is called immediately after LineSDK.Awake(), which prevents me from implementing the feature as intended. When I try to implement it like LineSDK.Instance.channelID = _lineChannelId; from an external class, I get the following error: Exception: LINE SDK channel ID is not set.

Your environment?

I am using the latest versions of all packages, including the LINE SDK.

Sample project

Suggestion

Could you consider changing the calling of SetupSDK() from LineSDK.Awake() to LineSDK.Start()? This change would allow for the channelID to be changed after LineSDK.Awake() is called, and prevent the error Exception: LINE SDK channel ID is not set. from occurring.


        void Awake() {
            if (instance == null) {
                instance = this;
            } else if (instance != this) {
                Destroy(gameObject);
            }
            DontDestroyOnLoad(gameObject);
        }

        void Start()
        {
            SetupSDK();
        }
LineSDK.Instance.channelID = _lineChannelId;

https://github.com/line/line-sdk-unity/blob/667f000e06a1d0283f9f9acea7d759c65211ecf4/LINE_SDK_Unity/Assets/LineSDK/LineSDK.cs#L40-L48

onevcat commented 8 months ago

@k0uhe1D Thanks for the suggestion. I will try to check what we can do to solve this!

onevcat commented 8 months ago

1.4.0 was released with the related changes.

Thank you for reporting and helping to improve the project!