Init() публичный статический Метод

public static Init ( ) : bool
Результат bool
        public static void Init(uint appid)
        {
            System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString());
            System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString());

            if (!SteamAPI.Init())
            {
                throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId.");
            }

            AppId = appid;

            initialized = true;

            SteamApps.InstallEvents();
            SteamUtils.InstallEvents();
            SteamParental.InstallEvents();
            SteamMusic.InstallEvents();
            SteamVideo.InstallEvents();
            SteamUser.InstallEvents();
            SteamFriends.InstallEvents();
            SteamScreenshots.InstallEvents();
            SteamUserStats.InstallEvents();
            SteamInventory.InstallEvents();
            SteamNetworking.InstallEvents();
            SteamMatchmaking.InstallEvents();
            SteamParties.InstallEvents();
            SteamNetworkingSockets.InstallEvents();
            SteamInput.InstallEvents();

            RunCallbacksAsync();
        }
Пример #2
0
        public static void Init(uint appid)
        {
            if (IntPtr.Size != 8)
            {
                throw new System.Exception("Only 64bit processes are currently supported");
            }

            System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString());
            System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString());

            if (!SteamAPI.Init())
            {
                throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId.");
            }

            AppId = appid;

            initialized = true;


            SteamApps.InstallEvents();
            SteamUtils.InstallEvents();
            SteamParental.InstallEvents();
            SteamMusic.InstallEvents();
            SteamVideo.InstallEvents();
            SteamUser.InstallEvents();
            SteamFriends.InstallEvents();
            SteamScreenshots.InstallEvents();
            SteamUserStats.InstallEvents();
            SteamInventory.InstallEvents();

            RunCallbacksAsync();
        }
Пример #3
0
        /// <summary>
        /// Initialize the steam client.
        /// If <paramref name="asyncCallbacks"/> is false you need to call <see cref="RunCallbacks"/> manually every frame.
        /// </summary>
        public static bool Init(uint appid, bool asyncCallbacks = true, bool isDevelopment = false)
        {
            if (initialized)
            {
                return(true);
            }

            System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString());
            System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString());
            developmentBuild = isDevelopment;

            if (!SteamAPI.Init())
            {
                return(false);
            }

            AppId = appid;

            initialized = true;

            //
            // Dispatch is responsible for pumping the
            // event loop.
            //
            Dispatch.Init();
            Dispatch.ClientPipe = SteamAPI.GetHSteamPipe();

            AddInterface <SteamApps>();
            AddInterface <SteamFriends>();
            AddInterface <SteamInput>();
            AddInterface <SteamInventory>();
            AddInterface <SteamMatchmaking>();
            AddInterface <SteamMatchmakingServers>();
            AddInterface <SteamMusic>();
            AddInterface <SteamNetworking>();
            AddInterface <SteamNetworkingSockets>();
            AddInterface <SteamNetworkingUtils>();
            AddInterface <SteamParental>();
            AddInterface <SteamParties>();
            AddInterface <SteamRemoteStorage>();
            AddInterface <SteamScreenshots>();
            AddInterface <SteamUGC>();
            AddInterface <SteamUser>();
            AddInterface <SteamUserStats>();
            AddInterface <SteamUtils>();
            AddInterface <SteamVideo>();
            AddInterface <SteamRemotePlay>();

            if (asyncCallbacks)
            {
                //
                // This will keep looping in the background every 16 ms
                // until we shut down.
                //
                Dispatch.LoopClientAsync();
            }

            return(true);
        }
Пример #4
0
        /// <summary>
        /// Initialize the steam client.
        /// If asyncCallbacks is false you need to call RunCallbacks manually every frame.
        /// </summary>
        public static void Init(uint appid, bool asyncCallbacks = true)
        {
            if (initialized)
            {
                throw new System.Exception("Calling SteamClient.Init but is already initialized");
            }

            System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString());
            System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString());

            if (!SteamAPI.Init())
            {
                throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId.");
            }

            AppId = appid;

            initialized = true;

            //
            // Dispatch is responsible for pumping the
            // event loop.
            //
            Dispatch.Init();
            Dispatch.ClientPipe = SteamAPI.GetHSteamPipe();

            AddInterface <SteamApps>();
            AddInterface <SteamFriends>();
            AddInterface <SteamInput>();
            AddInterface <SteamInventory>();
            AddInterface <SteamMatchmaking>();
            AddInterface <SteamMatchmakingServers>();
            AddInterface <SteamMusic>();
            AddInterface <SteamNetworking>();
            AddInterface <SteamNetworkingSockets>();
            AddInterface <SteamNetworkingUtils>();
            AddInterface <SteamParental>();
            AddInterface <SteamParties>();
            AddInterface <SteamRemoteStorage>();
            AddInterface <SteamScreenshots>();
            AddInterface <SteamUGC>();
            AddInterface <SteamUser>();
            AddInterface <SteamUserStats>();
            AddInterface <SteamUtils>();
            AddInterface <SteamVideo>();
            AddInterface <SteamRemotePlay>();
            AddInterface <SteamHTMLSurface>();

            if (asyncCallbacks)
            {
                //
                // This will keep looping in the background every 16 ms
                // until we shut down.
                //
                Dispatch.LoopClientAsync();
            }
        }
Пример #5
0
 public static bool InitSafe()
 {
     return(SteamAPI.Init());
 }
        protected virtual void Awake()
        {
            // Only one instance of SteamManager at a time!
            if (s_instance != null)
            {
                Destroy(gameObject);
                return;
            }
            s_instance = this;

            if (s_EverInitialized)
            {
                // This is almost always an error.
                // The most common case where this happens is when SteamManager gets destroyed because of Application.Quit(),
                // and then some Steamworks code in some other OnDestroy gets called afterwards, creating a new SteamManager.
                // You should never call Steamworks functions in OnDestroy, always prefer OnDisable if possible.
                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/doc/sdk/api#initialization_and_shutdown
                if (SteamAPI.RestartAppIfNecessary(AppId_t.Invalid))
                {
                    Application.Quit();
                    return;
                }
            }
            catch (System.DllNotFoundException e) {     // We catch this exception here, as it will be the first occurrence 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;
            }

            // Initializes the Steamworks API.
            // If this returns false then this indicates one of the following conditions:
            // [*] The Steam client isn't running. A running Steam client is required to provide implementations of the various Steamworks interfaces.
            // [*] The Steam client couldn't determine the App ID of game. If you're running your application from the executable or debugger directly then you must have a [code-inline]steam_appid.txt[/code-inline] in your game directory next to the executable, with your app ID in it and nothing else. Steam will look for this file in the current working directory. If you are running your executable from a different directory you may need to relocate the [code-inline]steam_appid.txt[/code-inline] file.
            // [*] Your application is not running under the same OS user context as the Steam client, such as a different user or administration access level.
            // [*] Ensure that you own a license for the App ID on the currently active Steam account. Your game must show up in your Steam library.
            // [*] Your App ID is not completely set up, i.e. in Release State: Unavailable, or it's missing default packages.
            // Valve's documentation for this is located here:
            // https://partner.steamgames.com/doc/sdk/api#initialization_and_shutdown
            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;
            }

            s_EverInitialized = true;
        }