private static void OnScriptsReloaded()
        {
#if false
            Debug.Log("Script Reloaded.");
            AssetManagementWindow window = (AssetManagementWindow)EditorWindow.GetWindow(typeof(AssetManagementWindow));
            DiscardAssetManager();
            bool recursive = true;
            try {
                var setting = RequiredFuncs.FromJsonAtPath <AssetInstallSetting>(lastInstallFilePath);
                recursive = setting.recursive;
            } catch {}
            if (File.Exists(AssetManagementWindow.continueDummyFilePath))
            {
                File.Delete(AssetManagementWindow.continueDummyFilePath);
                if (EditorUtility.DisplayDialog("Confirm", "OnScriptsReloaded(): Will continue install.", "OK", "Cancel"))
                {
                    (NewAssetManager() as AssetInstaller).ContinueUnfinishedInstall(GetListener(recursive, window.doAutoDonwload, window));
                }
            }
            if (File.Exists(AssetManagementWindow.reinstallDummyFilePath))
            {
                File.Delete(AssetManagementWindow.reinstallDummyFilePath);
                if (EditorUtility.DisplayDialog("Confirm", "OnScriptsReloaded(): Will install assets by new ERWCs.", "OK", "Cancel"))
                {
                    (NewAssetManager() as AssetInstaller).InstallAssetsFromERWCs(new AssetRequest(), GetListener(recursive, window.doAutoDonwload, window));
                }
            }
#endif
        }
        IEnumerator RemoteSPCo(string eWords, Taker <GrammarBlock> listener)
        {
            inteceptHelper.OnBeginSession(listener);
            var  form       = new WWWForm();
            bool didCollect = false;

            form.AddBinaryData("ewords", System.Text.Encoding.UTF8.GetBytes(eWords));
            UnityWebRequest www = UnityWebRequest.Post(uri, form);

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log("HTML_MonoBLProcessor: " + www.error);
            }
            else
            {
                Debug.Log(Encoding.UTF8.GetString(www.downloadHandler.data));
                var gblock = RequiredFuncs.FromJson <DeserializedGBlock>(www.downloadHandler.data);
                listener.Take(gblock);
                didCollect = true;
            }
            inteceptHelper.OnEndSession(listener);
            if (!didCollect)
            {
                listener.None();
            }
        }
Beispiel #3
0
 void AssetReferer.ReferAsset(AssetUnitInfo assetUnitInfo, AssetReferenceListener listener)
 {
     if (assetUnitInfo.reference.StartsWith("unityab:"))
     {
         listener.OnBeginRefering();
         var json  = assetUnitInfo.reference.Substring(8);
         var abRef = RequiredFuncs.FromJson <AssetBundleRef>(json);
         NetworkUtil.ProcessWebRequest(
             UnityWebRequestAssetBundle.GetAssetBundle(abRef.uri, 0),
             (www) => {
             var bundle = DownloadHandlerAssetBundle.GetContent(www);
             if (string.IsNullOrEmpty(abRef.assetPath))
             {
                 //stub
             }
             else
             {
                 var bundleAsset = bundle.LoadAsset(abRef.assetPath);
                 if (bundleAsset != null)
                 {
                     listener.OnObjectObtained(bundleAsset, abRef.assetPath);
                 }
             }
             listener.OnFinish();
         }
             );
     }
 }
Beispiel #4
0
 void AssetReferer.ReferAsset(AssetUnitInfo assetUnitInfo, AssetReferenceListener listener)
 {
     if (assetUnitInfo.reference.StartsWith("platform:"))
     {
         var json        = assetUnitInfo.reference.Substring(9);
         var pRef        = RequiredFuncs.FromJson <PlatformRef>(json);
         var auInfoClone = AssetUtils.CloneAssetRef(assetUnitInfo);
         auInfoClone.reference = pRef.defaultBuild;
         baseReferer.assetReferer.ReferAsset(auInfoClone, listener);
     }
 }
Beispiel #5
0
        public void SendNCSRequest(SimpleProcessListener listener)
        {
            if (pendingNCSReq.units.Count == 0)
            {
                return;
            }
            var reqInJson = RequiredFuncs.ToJsonString(pendingNCSReq);

            pendingNCSReq = new NounCommonSenseRequest {
                units = new List <NounCommonSenseRequestUnit>()
            };
            var copiedTakers = pendingNCSTakers;

            pendingNCSTakers = new Dictionary <string, List <Taker <NounCommonSenseUnit> > >();
            var wwwForm = new WWWForm();

            wwwForm.AddField("ncsReqInJson", reqInJson);
            Debug.Log("CommonSenseReq: " + reqInJson);
            UnityWebRequest www = UnityWebRequest.Post(serverURL + "GetNounCommonSense", wwwForm);

            NetworkUtil.ProcessWebRequest(www, (givenWebReq) => {
                if (www.error != null)
                {
                    listener.OnFinish(false);
                    return;
                }
                var ncs = RequiredFuncs.FromJson <StoredNounCommonSense>(www.downloadHandler.text);
                Debug.Log(www.downloadHandler.text);
                foreach (var ncsUnit in ncs.units)
                {
                    foreach (var pair in copiedTakers)
                    {
                        if (pair.Key.Equals(ncsUnit.noun, StringComparison.CurrentCultureIgnoreCase))
                        {
                            foreach (var collector in pair.Value)
                            {
                                cachedNCS.Add(ncsUnit);
                                collector.Take(ncsUnit);
                            }
                        }
                        else
                        {
                            foreach (var collector in pair.Value)
                            {
                                collector.None();
                            }
                        }
                    }
                }
            });
        }
        void OnGUI()
        {
            EditorGUILayout.LabelField("BaseAssets");
            index          = EditorGUILayout.Popup(index, baseAssetRequests);
            doAutoDonwload = EditorGUILayout.Toggle("Auto", doAutoDonwload);
            if (GUILayout.Button("AllowRemoteAssetSupply"))
            {
                FindObjectOfType <HTML_AUSupplier>().bridgeSupplier.BeginAssetSupply();
            }
            if (GUILayout.Button("TestCommonSense"))
            {
                FindObjectOfType <HTML_MonoBCSGiver>().SendNCSRequest(new StubSimpleProcessListener {
                });
            }
#if false
            if (GUILayout.Button("InstallBaseAssets"))
            {
                var currentReq = dependencyAssetReq;
                dependencyAssetReq = new AssetRequest();
                Directory.CreateDirectory(EditTimeAssetUtils.temporaryDir);
                File.WriteAllText(lastInstallFilePath, RequiredFuncs.ToJson(new AssetInstallSetting {
                    recursive = false
                }));
                (NewAssetManager() as AssetInstaller).InstallAssetsFromRequest(
                    RequiredFuncs.FromJsonAtPath <AssetRequest>(EditTimeAssetUtils.builtinAssetDir + "BaseAssetRequests/" + baseAssetRequests[index]),
                    GetListener(false, doAutoDonwload, this)
                    );
            }
            if (GUILayout.Button("InstallAllAssetsRecursive"))
            {
                var currentReq = dependencyAssetReq;
                dependencyAssetReq = new AssetRequest();
                Directory.CreateDirectory(EditTimeAssetUtils.temporaryDir);
                File.WriteAllText(lastInstallFilePath, RequiredFuncs.ToJson(new AssetInstallSetting {
                    recursive = true
                }));
                (NewAssetManager() as AssetInstaller).InstallAssetsFromERWCs(
                    RequiredFuncs.FromJsonAtPath <AssetRequest>(EditTimeAssetUtils.builtinAssetDir + "BaseAssetRequests/" + baseAssetRequests[index]),
                    GetListener(true, doAutoDonwload, this));
            }
            if (GUILayout.Button("UninstallAllAssets"))
            {
                if (EditorUtility.DisplayDialog("Delete all assets.", "Really?", "OK", "Cancel"))
                {
                    (NewAssetManager() as AssetInstaller).UninstallAllAsets(new SimpleProcessListener_DetroyGObj {
                        clientListener = new StdSimpleProcessListener()
                    });
                }
            }
            if (assetManager != null)
            {
                GUILayout.Label("Asset Manager is Active.");
                if (GUILayout.Button("ConcludeBehaverPrefabs"))
                {
                    //GameObject.FindObjectOfType<PrepMonoBBehaverFrontFactory>().GenerateBehaverFrontPrefabs();
                }
                if (GUILayout.Button("Stop"))
                {
                    DiscardAssetManager();
                }
                if (pickAndDownloadTriggers != null)
                {
                    foreach (var pickAndTrigger in pickAndDownloadTriggers)
                    {
                        GUILayout.Label(
                            "AssetPickUnit: " + pickAndTrigger.assetUnitToDownload.sname
                            );

                        if (!pickAndTrigger.didInstalled)
                        {
                            if (GUILayout.Button("Install"))
                            {
                                pickAndTrigger.installTrigger.Trigger(new PrvtAssetPickTriggerListener {
                                    param = pickAndTrigger
                                });
                            }
                        }
                        else
                        {
                            GUILayout.Label("Already Installed.");
                        }
                    }
                }
            }
            if (dependencyAssetReq != null)
            {
                foreach (var assetReqUnit in dependencyAssetReq.units)
                {
                    if (!String.IsNullOrEmpty(assetReqUnit.sname))
                    {
                        GUILayout.Label("DependencyAssetReqUnits: " + assetReqUnit.sname);
                    }
                }
                if (GUILayout.Button("InstallDependencies"))
                {
                    (NewAssetManager() as AssetInstaller).InstallAssetsFromRequest(
                        dependencyAssetReq, GetListener(false, doAutoDonwload, this)
                        );
                }
            }
#endif
        }