Ejemplo n.º 1
0
        // ================================================================================================================
        // PUBLIC INTERFACE -----------------------------------------------------------------------------------------------

        public static void Connect(string __apiId, string __encryptionKey = null, string __version = "")
        {
            _apiId         = __apiId;
            _encryptionKey = __encryptionKey;

            // This is an odd combination: the static class creates a GameObject that has an instance of the class.
            // The instance just forwards everything to the static class.
            GameObject newGameObject = new GameObject("NewgroundsAPISurrogate-" + (int)(Time.realtimeSinceStartup * 1000f));

            _surrogate = newGameObject.AddComponent <GameObjectSurrogate>();

            Debug.Log("Attempting to connect to newgrounds API");

            if (Application.isEditor)
            {
                // Running in editor: use fake data
                // REPLACE THIS WITH THE URL OF YOUR GAME WHEN TESTING! It needs the session id!
                setContainerURLStatic("http://uploads.ungrounded.net/alternate/999999/999999_alternate_9999.zip/?NewgroundsAPI_PublisherID=9&NewgroundsAPI_SandboxID=Abc999&NewgroundsAPI_SessionID=Abc999&NewgroundsAPI_UserName=john&NewgroundsAPI_UserID=999999&ng_username=john");
            }
            else
            {
                // Need the container URL first (for user parameters)
                Application.ExternalEval(
                    "document.getElementById('unityPlayer').children[0].SendMessage('" + newGameObject.name + "', 'setContainerURL', document.location.toString());"
                    );
            }
        }
Ejemplo n.º 2
0
		// ================================================================================================================
		// PUBLIC INTERFACE -----------------------------------------------------------------------------------------------

		public static void Connect(string __apiId, string __encryptionKey = null, string __version = "") {
			_apiId = __apiId;
			_encryptionKey = __encryptionKey;

			// This is an odd combination: the static class creates a GameObject that has an instance of the class.
			// The instance just forwards everything to the static class.
			GameObject newGameObject = new GameObject("NewgroundsAPISurrogate-" + (int)(Time.realtimeSinceStartup * 1000f));
			_surrogate = newGameObject.AddComponent<GameObjectSurrogate>();

			Debug.Log("Attempting to connect to newgrounds API");

			if (Application.isEditor) {
				// Running in editor: use fake data
				// REPLACE THIS WITH THE URL OF YOUR GAME WHEN TESTING! It needs the session id!
				setContainerURLStatic("http://uploads.ungrounded.net/alternate/999999/999999_alternate_9999.zip/?NewgroundsAPI_PublisherID=9&NewgroundsAPI_SandboxID=Abc999&NewgroundsAPI_SessionID=Abc999&NewgroundsAPI_UserName=john&NewgroundsAPI_UserID=999999&ng_username=john");
			} else {
				// Need the container URL first (for user parameters)
				Application.ExternalEval(
					"document.getElementById('unityPlayer').children[0].SendMessage('" + newGameObject.name + "', 'setContainerURL', document.location.toString());"
				);
			}
		}