private void InitWebView(Rect webViewRect)
        {
            m_CurrentSkin = EditorGUIUtility.skinIndex;
            m_IsDocked    = docked;
            m_IsOffline   = false;

            if (!webView)
            {
                var x      = (int)webViewRect.x;
                var y      = (int)webViewRect.y;
                int width  = (int)webViewRect.width;
                int height = (int)webViewRect.height;

                // Create WebView.
                webView = ScriptableObject.CreateInstance <WebView>();
                webView.InitWebView(m_Parent, x, y, width, height, false);
                webView.hideFlags = HideFlags.HideAndDontSave;
                webView.AllowRightClickMenu(true);

                // Sync focus.
                if (hasFocus)
                {
                    SetFocus(true);
                }
            }

            // Direct WebView event callbacks to us.
            webView.SetDelegateObject(this);

            // Load the A$ startup file.
            webView.LoadFile(AssetStoreUtils.GetLoaderPath());
        }
        public static void DecryptFile(string inputFile, string outputFile, string keyIV)
        {
            byte[] array  = new byte[32];
            byte[] array2 = new byte[16];
            AssetStoreUtils.HexStringToByteArray(keyIV, array, 0);
            AssetStoreUtils.HexStringToByteArray(keyIV, array2, 64);
            FileStream fileStream  = File.Open(inputFile, FileMode.Open);
            FileStream fileStream2 = File.Open(outputFile, FileMode.CreateNew);
            AesManaged aesManaged  = new AesManaged();

            aesManaged.Key = array;
            aesManaged.IV  = array2;
            CryptoStream cryptoStream = new CryptoStream(fileStream, aesManaged.CreateDecryptor(aesManaged.Key, aesManaged.IV), CryptoStreamMode.Read);

            try
            {
                byte[] array3 = new byte[40960];
                int    count;
                while ((count = cryptoStream.Read(array3, 0, array3.Length)) > 0)
                {
                    fileStream2.Write(array3, 0, count);
                }
            }
            finally
            {
                cryptoStream.Close();
                fileStream.Close();
                fileStream2.Close();
            }
        }
        public static void Download(string package_id, string url, string key, string package_name,
                                    string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback)
        {
            string[] dest = PackageStorePath(publisher_name, category_name,
                                             package_name, package_id, url);

            JSONValue existing = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, dest, key));

            // If the package is actively being downloaded right now just return
            if (existing.Get("in_progress").AsBool(true))
            {
                Debug.Log("Will not download " + package_name + ". Download is already in progress.");
                return;
            }

            // The package is not being downloaded.
            // If the package has previously been partially downloaded then
            // resume that download.
            string existingUrl = existing.Get("download.url").AsString(true);
            string existingKey = existing.Get("download.key").AsString(true);
            bool   resumeOK    = (existingUrl == url && existingKey == key);

            JSONValue download = new JSONValue();

            download["url"] = url;
            download["key"] = key;
            JSONValue parameters = new JSONValue();

            parameters["download"] = download;

            AssetStoreUtils.Download(package_id, url, dest, key, parameters.ToString(), resumeOK, doneCallback);
        }
Example #4
0
        public void OnEnable()
        {
            SetMinMaxSizes();
            titleContent = GetLocalizedTitleContent();
            AssetStoreUtils.RegisterDownloadDelegate(this);

            EditorApplication.update += TrackFocusState;
        }
Example #5
0
 public void OnDisable()
 {
     AssetStoreAsset.PreviewInfo info = m_Asset == null ? null : m_Asset.previewInfo;
     if (info != null)
     {
         info.downloadProgress = -1f;
         info.buildProgress    = -1;
     }
     AssetStoreUtils.UnRegisterDownloadDelegate(this);
     m_Purchasing = PurchaseStatus.Init;
 }
Example #6
0
 public void OnDisable()
 {
     AssetStoreAsset.PreviewInfo previewInfo = (this.m_Asset != null) ? this.m_Asset.previewInfo : null;
     if (previewInfo != null)
     {
         previewInfo.downloadProgress = -1f;
         previewInfo.buildProgress    = -1f;
     }
     AssetStoreUtils.UnRegisterDownloadDelegate(this);
     this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.Init;
 }
 public void OnDisable()
 {
     EditorApplication.update -= new EditorApplication.CallbackFunction(this.Update);
     if (this.m_PreviewEditor != null)
     {
         this.m_PreviewEditor.Dispose();
         this.m_PreviewEditor = (EditorWrapper)null;
     }
     if (this.m_PreviewObject != (Object)null)
     {
         this.m_PreviewObject = (Object)null;
     }
     AssetStoreUtils.UnRegisterDownloadDelegate((ScriptableObject)this);
 }
Example #8
0
 // Reloads the web view
 public void Reload()
 {
     m_CurrentSkin = EditorGUIUtility.skinIndex;
     m_IsDocked    = docked;
     if (m_IsOffline)
     {
         m_IsOffline = false;
         webView.LoadFile(AssetStoreUtils.GetLoaderPath());
     }
     else
     {
         webView.Reload();
     }
 }
Example #9
0
 public void OnDisable()
 {
     EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(this.Update));
     if (this.m_PreviewEditor != null)
     {
         this.m_PreviewEditor.Dispose();
         this.m_PreviewEditor = null;
     }
     if (this.m_PreviewObject != null)
     {
         this.m_PreviewObject = null;
     }
     AssetStoreUtils.UnRegisterDownloadDelegate(this);
 }
Example #10
0
 public void OnDisable()
 {
     EditorApplication.update -= Update;
     if (m_PreviewEditor != null)
     {
         m_PreviewEditor.Dispose();
         m_PreviewEditor = null;
     }
     if (m_PreviewObject != null)
     {
         m_PreviewObject = null;
     }
     AssetStoreUtils.UnRegisterDownloadDelegate(this);
 }
 public void OnLoadError(string url)
 {
     if (this.webView != null)
     {
         if (this.m_IsOffline)
         {
             object[] args = new object[] { url };
             Debug.LogErrorFormat("Unexpected error: Failed to load offline Asset Store page (url={0})", args);
         }
         else
         {
             this.m_IsOffline = true;
             this.webView.LoadFile(AssetStoreUtils.GetOfflinePath());
         }
     }
 }
        public void OnLoadError(string url)
        {
            if (!webView)
            {
                return;
            }

            if (m_IsOffline)
            {
                Debug.LogErrorFormat("Unexpected error: Failed to load offline Asset Store page (url={0})", url);
                return;
            }

            m_IsOffline = true;
            webView.LoadFile(AssetStoreUtils.GetOfflinePath());
        }
Example #13
0
 public void OnLoadError(string url)
 {
     if (!(bool)this.webView)
     {
         return;
     }
     if (this.m_IsOffline)
     {
         Debug.LogErrorFormat("Unexpected error: Failed to load offline Asset Store page (url={0})", (object)url);
     }
     else
     {
         this.m_IsOffline = true;
         this.webView.LoadFile(AssetStoreUtils.GetOfflinePath());
     }
 }
 public void OnLoadError(string url)
 {
     if (!this.m_WebView)
     {
         return;
     }
     if (this.m_IsOffline)
     {
         Debug.LogErrorFormat("Unexpected error: Failed to load offline Asset Store page (url={0})", new object[]
         {
             url
         });
         return;
     }
     this.m_IsOffline = true;
     this.m_WebView.LoadFile(AssetStoreUtils.GetOfflinePath());
 }
Example #15
0
 public static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback)
 {
     string[] destination = PackageStorePath(publisher_name, category_name, package_name, package_id, url);
     JSONValue value2 = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, destination, key));
     if (value2.Get("in_progress").AsBool(true))
     {
         Debug.Log("Will not download " + package_name + ". Download is already in progress.");
     }
     else
     {
         string str = value2.Get("download.url").AsString(true);
         string str2 = value2.Get("download.key").AsString(true);
         bool resumeOK = (str == url) && (str2 == key);
         JSONValue value3 = new JSONValue();
         value3["url"] = url;
         value3["key"] = key;
         JSONValue value4 = new JSONValue();
         value4["download"] = value3;
         AssetStoreUtils.Download(package_id, url, destination, key, value4.ToString(), resumeOK, doneCallback);
     }
 }
 private void InitWebView(Rect webViewRect)
 {
     this.m_CurrentSkin = EditorGUIUtility.skinIndex;
     this.m_IsDocked    = base.docked;
     this.m_IsOffline   = false;
     if (!this.m_WebView)
     {
         int x      = (int)webViewRect.x;
         int y      = (int)webViewRect.y;
         int width  = (int)webViewRect.width;
         int height = (int)webViewRect.height;
         this.m_WebView = ScriptableObject.CreateInstance <WebView>();
         this.m_WebView.InitWebView(this.m_Parent, x, y, width, height, false);
         this.m_WebView.hideFlags = HideFlags.HideAndDontSave;
         if (base.hasFocus)
         {
             this.SetFocus(true);
         }
     }
     this.m_WebView.SetDelegateObject(this);
     this.m_WebView.LoadFile(AssetStoreUtils.GetLoaderPath());
 }
Example #17
0
        public static void DecryptFile(string inputFile, string outputFile, string keyIV)
        {
            byte[] array  = new byte[32];
            byte[] array2 = new byte[16];
            AssetStoreUtils.HexStringToByteArray(keyIV, array, 0);
            AssetStoreUtils.HexStringToByteArray(keyIV, array2, 64);
            EditorUtility.DisplayProgressBar("Decrypting", "Decrypting package", 0f);
            FileStream fileStream  = File.Open(inputFile, FileMode.Open);
            FileStream fileStream2 = File.Open(outputFile, FileMode.CreateNew);
            long       length      = fileStream.Length;
            long       num         = 0L;
            AesManaged aesManaged  = new AesManaged();

            aesManaged.Key = array;
            aesManaged.IV  = array2;
            CryptoStream cryptoStream = new CryptoStream(fileStream, aesManaged.CreateDecryptor(aesManaged.Key, aesManaged.IV), CryptoStreamMode.Read);

            try
            {
                byte[] array3 = new byte[40960];
                int    num2;
                while ((num2 = cryptoStream.Read(array3, 0, array3.Length)) > 0)
                {
                    fileStream2.Write(array3, 0, num2);
                    num += (long)num2;
                    if (EditorUtility.DisplayCancelableProgressBar("Decrypting", "Decrypting package", (float)num / (float)length))
                    {
                        throw new Exception("User cancelled decryption");
                    }
                }
            }
            finally
            {
                cryptoStream.Close();
                fileStream.Close();
                fileStream2.Close();
                EditorUtility.ClearProgressBar();
            }
        }
Example #18
0
        public static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback)
        {
            string[]  destination = PackageStorePath(publisher_name, category_name, package_name, package_id, url);
            JSONValue value2      = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, destination, key));

            if (value2.Get("in_progress").AsBool(true))
            {
                Debug.Log("Will not download " + package_name + ". Download is already in progress.");
            }
            else
            {
                string    str      = value2.Get("download.url").AsString(true);
                string    str2     = value2.Get("download.key").AsString(true);
                bool      resumeOK = (str == url) && (str2 == key);
                JSONValue value3   = new JSONValue();
                value3["url"] = url;
                value3["key"] = key;
                JSONValue value4 = new JSONValue();
                value4["download"] = value3;
                AssetStoreUtils.Download(package_id, url, destination, key, value4.ToString(), resumeOK, doneCallback);
            }
        }
        public static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback)
        {
            string[]  destination = AssetStoreContext.PackageStorePath(publisher_name, category_name, package_name, package_id, url);
            JSONValue jSONValue   = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, destination, key));

            if (jSONValue.Get("in_progress").AsBool(true))
            {
                Debug.Log("Will not download " + package_name + ". Download is already in progress.");
                return;
            }
            string    a        = jSONValue.Get("download.url").AsString(true);
            string    a2       = jSONValue.Get("download.key").AsString(true);
            bool      resumeOK = a == url && a2 == key;
            JSONValue value    = default(JSONValue);

            value["url"] = url;
            value["key"] = key;
            JSONValue jSONValue2 = default(JSONValue);

            jSONValue2["download"] = value;
            AssetStoreUtils.Download(package_id, url, destination, key, jSONValue2.ToString(), resumeOK, doneCallback);
        }
        public static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback)
        {
            string[]  destination = AssetStoreContext.PackageStorePath(publisher_name, category_name, package_name, package_id, url);
            JSONValue jsonValue1  = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, destination, key));

            if (jsonValue1.Get("in_progress").AsBool(true))
            {
                Debug.Log((object)("Will not download " + package_name + ". Download is already in progress."));
            }
            else
            {
                string    str1       = jsonValue1.Get("download.url").AsString(true);
                string    str2       = jsonValue1.Get("download.key").AsString(true);
                bool      resumeOK   = str1 == url && str2 == key;
                JSONValue jsonValue2 = new JSONValue();
                jsonValue2["url"] = (JSONValue)url;
                jsonValue2["key"] = (JSONValue)key;
                JSONValue jsonValue3 = new JSONValue();
                jsonValue3["download"] = jsonValue2;
                AssetStoreUtils.Download(package_id, url, destination, key, jsonValue3.ToString(), resumeOK, doneCallback);
            }
        }
 public static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback)
 {
   string[] destination = AssetStoreContext.PackageStorePath(publisher_name, category_name, package_name, package_id, url);
   JSONValue jsonValue1 = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, destination, key));
   if (jsonValue1.Get("in_progress").AsBool(true))
   {
     Debug.Log((object) ("Will not download " + package_name + ". Download is already in progress."));
   }
   else
   {
     string str1 = jsonValue1.Get("download.url").AsString(true);
     string str2 = jsonValue1.Get("download.key").AsString(true);
     bool resumeOK = str1 == url && str2 == key;
     JSONValue jsonValue2 = new JSONValue();
     jsonValue2["url"] = (JSONValue) url;
     jsonValue2["key"] = (JSONValue) key;
     JSONValue jsonValue3 = new JSONValue();
     jsonValue3["download"] = jsonValue2;
     AssetStoreUtils.Download(package_id, url, destination, key, jsonValue3.ToString(), resumeOK, doneCallback);
   }
 }
Example #22
0
 private void OnEnable()
 {
     AssetStoreUtils.RegisterDownloadDelegate(this);
 }
Example #23
0
 public void OnDisable()
 {
     AssetStoreUtils.UnRegisterDownloadDelegate((ScriptableObject)this);
 }
 public static void Download(string id, string url, string[] destination, string key, string jsonData, bool resumeOK)
 {
     AssetStoreUtils.DownloadDoneCallback doneCallback = null;
     AssetStoreUtils.Download(id, url, destination, key, jsonData, resumeOK, doneCallback);
 }
 public static string GetAssetStoreSearchUrl()
 {
     return(AssetStoreUtils.GetAssetStoreUrl().Replace("https", "http"));
 }
Example #26
0
 public void OnEnable()
 {
     EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(this.Update));
     AssetStoreUtils.RegisterDownloadDelegate(this);
 }
		public static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback)
		{
			string[] destination = AssetStoreContext.PackageStorePath(publisher_name, category_name, package_name, package_id, url);
			JSONValue jSONValue = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, destination, key));
			if (jSONValue.Get("in_progress").AsBool(true))
			{
				Debug.Log("Will not download " + package_name + ". Download is already in progress.");
				return;
			}
			string a = jSONValue.Get("download.url").AsString(true);
			string a2 = jSONValue.Get("download.key").AsString(true);
			bool resumeOK = a == url && a2 == key;
			JSONValue value = default(JSONValue);
			value["url"] = url;
			value["key"] = key;
			JSONValue jSONValue2 = default(JSONValue);
			jSONValue2["download"] = value;
			AssetStoreUtils.Download(package_id, url, destination, key, jSONValue2.ToString(), resumeOK, doneCallback);
		}
Example #28
0
 public void OnDisable()
 {
     EditorApplication.update -= TrackFocusState;
     AssetStoreUtils.UnRegisterDownloadDelegate(this);
 }
Example #29
0
 public void OnEnable()
 {
     this.SetMinMaxSizes();
     base.titleContent = base.GetLocalizedTitleContent();
     AssetStoreUtils.RegisterDownloadDelegate(this);
 }
Example #30
0
 public void OnEnable()
 {
     this.SetMinMaxSizes();
     this.titleContent = this.GetLocalizedTitleContent();
     AssetStoreUtils.RegisterDownloadDelegate((ScriptableObject)this);
 }
Example #31
0
 public void OnEnable()
 {
     EditorApplication.update += Update;
     AssetStoreUtils.RegisterDownloadDelegate(this);
 }
Example #32
0
 public void OnDisable()
 {
     AssetStoreUtils.UnRegisterDownloadDelegate(this);
 }
Example #33
0
        public static void AddAsset(AssetStoreAsset searchResult, Texture2D placeholderPreviewImage)
        {
            if (placeholderPreviewImage != null)
            {
                searchResult.previewImage = ScaleImage(placeholderPreviewImage, 256, 256);
            }

            searchResult.previewInfo          = null;
            searchResult.previewBundleRequest = null;

            // Dynamic previews is asset bundles to be displayed in
            // the inspector. Static previews are images.
            if (!string.IsNullOrEmpty(searchResult.dynamicPreviewURL) && searchResult.previewBundle == null)
            {
                // Debug.Log("dyn url " + searchResult.disposed.ToString() + " " + searchResult.dynamicPreviewURL);
                searchResult.disposed = false;
                // searchResult.previewBundle = AssetBundle.CreateFromFile("/users/jonasd/test.unity3d");
                // searchResult.previewAsset = searchResult.previewBundle.mainAsset;

                // Request the asset bundle data from the url and register a callback
                AsyncHTTPClient client = new AsyncHTTPClient(searchResult.dynamicPreviewURL);
                client.doneCallback = delegate(IAsyncHTTPClient c) {
                    if (!client.IsSuccess())
                    {
                        System.Console.WriteLine("Error downloading dynamic preview: " + client.text);
                        // Try the static preview instead
                        searchResult.dynamicPreviewURL = null;
                        DownloadStaticPreview(searchResult);
                        return;
                    }

                    // We only suppport one asset so grab the first one
                    AssetStoreAsset sel = GetFirstAsset();

                    // Make sure that the selection hasn't changed meanwhile
                    if (searchResult.disposed || sel == null || searchResult.id != sel.id)
                    {
                        //Debug.Log("dyn disposed " + searchResult.disposed.ToString() + " " + (sel == null ? "null" : sel.id.ToString()) + " " + searchResult.id.ToString());
                        return;
                    }

                    // Go create the asset bundle in memory from the binary blob asynchronously
                    try
                    {
                        AssetBundleCreateRequest cr = AssetBundle.LoadFromMemoryAsync(c.bytes);

                        // Workaround: Don't subject the bundle to the usual compatibility checks.  We want
                        // to stay compatible with previews created in prior versions of Unity and with the
                        // stuff we put into previews, we should generally be able to still load the content
                        // in the editor.
                        cr.DisableCompatibilityChecks();

                        searchResult.previewBundleRequest = cr;
                        EditorApplication.CallbackFunction callback = null;

                        // The callback will be called each tick and check if the asset bundle is ready
                        double startTime = EditorApplication.timeSinceStartup;
                        callback = () => {
                            AssetStoreUtils.UpdatePreloading();

                            if (!cr.isDone)
                            {
                                double nowTime = EditorApplication.timeSinceStartup;
                                if (nowTime - startTime > 10.0)
                                {
                                    // Timeout. Stop polling
                                    EditorApplication.update -= callback;
                                    System.Console.WriteLine("Timed out fetch live preview bundle " +
                                                             (searchResult.dynamicPreviewURL ?? "<n/a>"));
                                    // Debug.Log("Not done Timed out" + cr.progress.ToString() );
                                }
                                else
                                {
                                    // Debug.Log("Not done " + cr.progress.ToString() );
                                }
                                return;
                            }

                            // Done cooking. Stop polling.
                            EditorApplication.update -= callback;

                            // Make sure that the selection hasn't changed meanwhile
                            AssetStoreAsset sel2 = GetFirstAsset();
                            if (searchResult.disposed || sel2 == null || searchResult.id != sel2.id)
                            {
                                // No problem. Just ignore.
                                // Debug.Log("dyn late disposed " + searchResult.disposed.ToString() + " " + (sel2 == null ? "null" : sel2.id.ToString()) + " " + searchResult.id.ToString());
                            }
                            else
                            {
                                searchResult.previewBundle = cr.assetBundle;
#pragma warning disable 618
                                if (cr.assetBundle == null || cr.assetBundle.mainAsset == null)
                                {
                                    // Failed downloading live preview. Fallback to static
                                    searchResult.dynamicPreviewURL = null;
                                    DownloadStaticPreview(searchResult);
                                }
                                else
                                {
                                    searchResult.previewAsset = searchResult.previewBundle.mainAsset;
                                }
#pragma warning restore 618
                            }
                        };

                        EditorApplication.update += callback;
                    }
                    catch (System.Exception e)
                    {
                        System.Console.Write(e.Message);
                        Debug.Log(e.Message);
                    }
                };
                client.Begin();
            }
            else if (!string.IsNullOrEmpty(searchResult.staticPreviewURL))
            {
                DownloadStaticPreview(searchResult);
            }

            // searchResult.previewBundle = null;
            AddAssetInternal(searchResult);

            RefreshFromServer(null);
        }