Exemplo n.º 1
0
        public IEnumerator StandalonePublish()
        {
            // Restart the server, making sure there is no Shotgun client
            PythonRunner.StopServer(false);

            // Make sure the Shotgun client has stopped
            double initTime = EditorApplication.timeSinceStartup;

            while (Bootstrap.IsClientAlive())
            {
                if (EditorApplication.timeSinceStartup - initTime > shutdownTimeout)
                {
                    Assert.That(false, Is.True);
                }
                System.Threading.Thread.Sleep(100);
            }
            // Bootstrap Shotgun with our test client
            Bootstrap.SpawnClient(clientPath);

            // Give some time for the client to connect
            yield return(PythonRunner.WaitForConnection(Constants.clientName, connectionTimeout));

            // Wait until the client is fully bootstrapped
            initTime = EditorApplication.timeSinceStartup;
            while (!PythonRunner.CallServiceOnClient(Constants.clientName, "bootstrapped"))
            {
                if (EditorApplication.timeSinceStartup - initTime > bootstrapTimeout)
                {
                    break;
                }
                yield return(null);
            }

            // Fake a recording by copying a video file in the right location
            string videoFilePath   = Path.GetFullPath($"{testsPath}/standalone_publish.mp4");
            var    destinationPath = Path.Combine(System.IO.Path.GetTempPath(), Application.productName);

            destinationPath += ".mp4";

            System.IO.File.Copy(videoFilePath, destinationPath, true);

            Service.Call("standalone_publish");

            // Wait until the client has finished publishing
            initTime = EditorApplication.timeSinceStartup;
            while (!PythonRunner.CallServiceOnClient(Constants.clientName, "published"))
            {
                if (EditorApplication.timeSinceStartup - initTime > publishTimeout)
                {
                    break;
                }
                yield return(null);
            }

            // Upon success, the Python script creates a game object named
            // after the product name
            GameObject go = GameObject.Find(Application.productName);

            Assert.IsNotNull(go);
        }
        internal static void DoOnEngineInitialized()
        {
            CallPostInitHook();

            // Now that toolkit has bootstrapped, we can validate that the
            // package and engine versions are compatible (matching Major and
            // Minor version numbers)
            string tkUnityVersionString = PythonRunner.CallServiceOnClient(Constants.clientName, "tk_unity_version");
            string packageVersionString = PackageManager.PackageInfo.FindForAssetPath($"Packages/{Constants.packageName}/Editor/Shotgun.cs").version;

            // Strip the leading "v" in the tk-unity version string.
            // tk-unity version numbers have this form: "vX.Y". We want to
            // extract "X.Y"
            var index = tkUnityVersionString.IndexOf("v");

            if (index != -1 && index < (tkUnityVersionString.Length - 1))
            {
                tkUnityVersionString = tkUnityVersionString.Substring(index + 1);
            }

            // Remove everything after "preview" in the package string
            // Version numbers have this form: "X.Y.Z[-preview][.W]",
            // e.g "0.9.0-preview.1", "1.0.1-preview", "2.0.3".
            // We want to extract "X.Y.Z"
            index = packageVersionString.IndexOf("preview");
            if (index > 0)
            {
                packageVersionString = packageVersionString.Substring(0, index - 1);
            }

            System.Version tkUnityVersion = null;
            System.Version packageVersion = null;

            try
            {
                tkUnityVersion = new System.Version(tkUnityVersionString);
            }
            catch (Exception)
            {
                UnityEngine.Debug.LogWarning($"Cannot determine the version number for tk-unity ({tkUnityVersionString}). Some Shotgun features might not function properly");
            }

            try
            {
                packageVersion = new System.Version(packageVersionString);
            }
            catch (Exception)
            {
                UnityEngine.Debug.LogWarning($"Cannot determine the version number for {Constants.packageName} ({packageVersionString}). Some Shotgun features might not function properly");
            }

            if (tkUnityVersion != null && packageVersion != null)
            {
                // We were able to parse the version numbers. Now compare
                // them to make sure they are compatible
                if (tkUnityVersion.Major != packageVersion.Major ||
                    tkUnityVersion.Minor != packageVersion.Minor)
                {
                    UnityEngine.Debug.LogWarning($"The tk-unity engine version ({tkUnityVersionString}) is not compatible with the Shotgun package version ({packageVersionString}). Some Shotgun features might not function properly");
                }
            }
        }
Exemplo n.º 3
0
 public static dynamic CallService(string service, params object[] args)
 {
     return(PythonRunner.CallServiceOnClient(WORKER_NAME, service, args));
 }