private void Awake() { // Only one instance of SteamManager at a time! if (s_instance != null) { Destroy(gameObject); return; } s_instance = this; if (s_EverInialized) { // This is almost always an error. // The most common case where this happens is the SteamManager getting desstroyed via Application.Quit() and having some code in some OnDestroy which gets called afterwards, creating a new SteamManager. throw new System.Exception("Tried to Initialize the SteamAPI twice in one session!"); } // We want our SteamManager Instance to persist across scenes. DontDestroyOnLoad(gameObject); if (!Packsize.Test()) { Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this); } if (!DllCheck.Test()) { Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this); } try { // If Steam is not running or the game wasn't started through Steam, SteamAPI_RestartAppIfNecessary starts the // Steam client and also launches this game again if the User owns it. This can act as a rudimentary form of DRM. // Once you get a Steam AppID assigned by Valve, you need to replace AppId_t.Invalid with it and // remove steam_appid.txt from the game depot. eg: "(AppId_t)480" or "new AppId_t(480)". // See the Valve documentation for more information: https://partner.steamgames.com/documentation/drm#FAQ if (SteamAPI.RestartAppIfNecessary(AppId_t.Invalid)) { Application.Quit(); return; } } catch (System.DllNotFoundException e) { // We catch this exception here, as it will be the first occurence of it. Debug.LogError("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + e, this); Application.Quit(); return; } // Initialize the SteamAPI, if Init() returns false this can happen for many reasons. // Some examples include: // Steam Client is not running. // Launching from outside of steam without a steam_appid.txt file in place. // Running under a different OS User or Access level (for example running "as administrator") // Ensure that you own a license for the AppId on your active Steam account // If your AppId is not completely set up. Either in Release State: Unavailable, or if it's missing default packages. // Valve's documentation for this is located here: // https://partner.steamgames.com/documentation/getting_started // https://partner.steamgames.com/documentation/example // Under: Common Build Problems // https://partner.steamgames.com/documentation/bootstrap_stats // At the very bottom // If you're running into Init issues try running DbgView prior to launching to get the internal output from Steam. // http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx m_bInitialized = SteamAPI.Init(); if (!m_bInitialized) { Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this); return; } // 機能別生成、初期化 Leaderboard = new SteamLeaderboard(); s_EverInialized = true; }
// Use this for initialization IEnumerator test() { yield return(new WaitForSeconds(2f)); SteamLeaderboard.InstantiateLeaderboard(this); }
public override void OnInspectorGUI() { //base.OnInspectorGUI(); var style = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, wordWrap = true }; var styleTextArea = new GUIStyle(GUI.skin.textArea) { stretchWidth = true, wordWrap = true, alignment = TextAnchor.MiddleCenter }; SteamLeaderboard _leaderboard = (SteamLeaderboard)target; GUILayout.BeginVertical("Box"); { GUILayout.Space(10); EditorGUILayout.LabelField("-- Steam Leaderboard --", style); GUILayout.Space(10); GUILayout.BeginVertical("box"); { GUILayout.BeginHorizontal(); { GUILayout.Label("-- Leaderboard name --)", style); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(style); { _leaderboard.leaderboardName = GUILayout.TextArea(_leaderboard.leaderboardName, styleTextArea); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.Space(10); GUILayout.BeginVertical("box"); { GUILayout.BeginHorizontal(style); { GUILayout.Label("-- Leaderboard Cell Prefab --", style); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(style); { _leaderboard.leaderboardPrefab = (GameObject)EditorGUILayout.ObjectField(_leaderboard.leaderboardPrefab, typeof(GameObject) , false); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.BeginVertical("box"); { GUILayout.BeginHorizontal(style); { GUILayout.Label("-- Leaderboard starting range--", style); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(style); { _leaderboard.leaderboardEntriesRangeinit = EditorGUILayout.IntField(_leaderboard.leaderboardEntriesRangeinit, styleTextArea); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(style); { GUILayout.Label("-- Leaderboard ending range--", style); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(style); { _leaderboard.leaderboardEntriesRangeEnd = EditorGUILayout.IntField(_leaderboard.leaderboardEntriesRangeEnd, styleTextArea); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.Space(10); GUILayout.BeginVertical("box"); { GUILayout.BeginHorizontal(); { GUILayout.Label("-- Distance between each cell --", style); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { _leaderboard.distanceBetweenCells = EditorGUILayout.FloatField(_leaderboard.distanceBetweenCells, styleTextArea); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.Space(10); GUILayout.BeginVertical("box"); { GUILayout.BeginHorizontal(); { GUILayout.Label("-- Upload score method --", style); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { _leaderboard.uploadScoreMethod = (ELeaderboardUploadScoreMethod)EditorGUILayout.EnumPopup(_leaderboard.uploadScoreMethod); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.Space(10); GUILayout.BeginVertical("box"); { GUILayout.BeginHorizontal(); { GUILayout.Label("-- Request type --", style); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { _leaderboard.requestType = (ELeaderboardDataRequest)EditorGUILayout.EnumPopup(_leaderboard.requestType); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.Space(10); if (GUILayout.Button("Check leaderboard exist (Runtime only)")) { try { SteamLeaderboard.FindLeaderboard(); } catch (InvalidOperationException) { Debug.Log("Since it is a static method, it needs an instance of the steamLeaderboard. Use only at runtime"); } } } GUILayout.EndVertical(); EditorUtility.SetDirty(_leaderboard); }