// Use this for initialization void AssetRequestPublisher.PublishAssetRequest(AssetRequest assetReq, SimpleProcessListener listener) { RequiredFuncs.ProcessHTTP( "https://api.taiga.io/api/v1/auth", (response) => { var auth = RequiredFuncs.FromJson <TaigaIOUserInfo>(response); var headerWithAuth = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("Content-Type", "application/json"), new KeyValuePair <string, string>("Authorization", "Bearer " + auth.auth_token) }; RequiredFuncs.ProcessHTTP( "https://api.taiga.io/api/v1/userstories?project=" + projectID, (storiesJson) => { var stories = RequiredFuncs.FromJsonToArray <TaigaIOUserStory>(storiesJson); foreach (var reqUnit in assetReq.units) { if (reqUnit.attributes.Count == 0) { continue; } var storySubjForReq = "Asset Wanted: " + reqUnit.attributes[0] + " " + reqUnit.assettype; bool shouldPublishAssetReq = true; foreach (var story in stories) { if (story.subject == storySubjForReq) { shouldPublishAssetReq = false; break; } } if (shouldPublishAssetReq) { RequiredFuncs.ProcessHTTP( "https://api.taiga.io/api/v1/userstories", (addStoryResponseText) => { RequiredFuncs.Log(RequiredFuncs.ToJsonString(new TaigaIOUserStoryAdd { subject = storySubjForReq, project = projectID })); }, headerWithAuth, RequiredFuncs.ToJson(new TaigaIOUserStoryAdd { subject = storySubjForReq, project = projectID }) ); } } listener.OnFinish(true); }, headerWithAuth ); }, new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("Content-Type", "application/json") }, RequiredFuncs.ToJson(new TaigaIOAuth { username = username, password = password, type = "normal" }) ); }
AssetAddResult <AssetContentType> BasicAssetIn.SetContent <AssetContentType>(BasicAssetInParam <AssetContentType> settingParam) { try { var assetRootPath = Path.GetDirectoryName(assetUnitInfo.localref); if (!Directory.Exists(assetRootPath)) { Directory.CreateDirectory(assetRootPath); } var assetPath = assetRootPath + "/" + settingParam.assetPath; if (typeof(AssetContentType) == typeof(GameObject)) { var gObj = (GameObject)Convert.ChangeType(settingParam.content, typeof(GameObject)); GameObject oldPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(assetPath); GameObject newContent = null; if (oldPrefab != null && settingParam.doOverwrite) { newContent = PrefabUtility.ReplacePrefab(gObj, oldPrefab); } else { newContent = PrefabUtility.CreatePrefab(assetPath, gObj); } EditorUtility.SetDirty(newContent); AssetDatabase.SaveAssets(); return(new AssetAddResult <AssetContentType> { permanentContent = (AssetContentType)Convert.ChangeType(newContent, typeof(AssetContentType)), didSuccess = true }); } else if (typeof(UnityEngine.Object).IsAssignableFrom(typeof(AssetContentType))) { UnityEngine.Object obj = (UnityEngine.Object)(object) settingParam.content; var oldAssetPath = AssetDatabase.GetAssetPath(obj); if (Utilities.IsStringEmpty(oldAssetPath)) { AssetDatabase.CreateAsset(obj, assetPath); } else { if (oldAssetPath.StartsWith("Assets/")) { AssetDatabase.MoveAsset(oldAssetPath, assetPath); } else { if (typeof(AssetContentType) == typeof(Material)) { AssetDatabase.CreateAsset(new Material((Material)(object)obj), assetPath); } } } EditorUtility.SetDirty(obj); AssetDatabase.SaveAssets(); return(new AssetAddResult <AssetContentType> { permanentContent = settingParam.content, didSuccess = true }); } else if (typeof(CommonAssetRef).IsAssignableFrom(typeof(AssetContentType))) { if (File.Exists(assetPath) && settingParam.doOverwrite) { try { return(new AssetAddResult <AssetContentType> { didSuccess = false, permanentContent = RequiredFuncs.FromJsonAtPath <AssetContentType>(assetPath) }); } catch { return(new AssetAddResult <AssetContentType> { didSuccess = false }); } } File.WriteAllText(assetPath, RequiredFuncs.ToJson(settingParam.content)); //AssetDatabase.Refresh(); //AssetDatabase.SaveAssets(); return(new AssetAddResult <AssetContentType> { permanentContent = settingParam.content, didSuccess = true }); } } catch (Exception e) { Debug.LogError(e); } return(new AssetAddResult <AssetContentType> { didSuccess = false }); }