public static ResNode GetAssetsAsync(AssetType t, System.Action <ResConfigData, ResNode, System.Object> callBack, string strParam, bool isGuid = false, System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal) { ResNode res = null; if (null == strParam) { return(res); } if (strParam.Equals(string.Empty)) { return(res); } if (isGuid && t != AssetType.Asset_Prefab) { Debug.LogWarning("类型:" + t.ToString() + "不支持通过guid来获取"); return(null); } switch (t) { case AssetType.Asset_Prefab: res = GetPrefabAsync(strParam, isGuid, callBack, userDataObj, priority); return(res); } Debug.LogWarning("类型:" + t.ToString() + "不支持通过assetbundlename和assetName来获取"); return(res); }
public frmInvOffered(METAboltInstance instance, InstantMessage e, UUID objectID, AssetType type) { InitializeComponent(); SetExceptionReporter(); Application.ThreadException += new ThreadExceptionHandler().ApplicationThreadException; this.instance = instance; client = this.instance.Client; msg = e; this.objectID = objectID; this.Text += " [" + client.Self.Name + "]"; invtype = type; if (invtype == AssetType.Folder) { instance.State.FolderRcvd = true; } else { instance.State.FolderRcvd = false; } diag = e.Dialog; //if (e.Dialog == InstantMessageDialog.TaskInventoryOffered) //{ // diainv = true; //} string a = "a"; if (type.ToString().ToLower(CultureInfo.CurrentCulture).StartsWith("a", StringComparison.CurrentCultureIgnoreCase) || type.ToString().ToLower(CultureInfo.CurrentCulture).StartsWith("o", StringComparison.CurrentCultureIgnoreCase) || type.ToString().ToLower(CultureInfo.CurrentCulture).StartsWith("u", StringComparison.CurrentCultureIgnoreCase)) { a = "an"; } lblSubheading.Text = "You have received " + a + " " + type.ToString() + " named '" + e.Message + "' from " + e.FromAgentName; if (instance.Config.CurrentConfig.PlayInventoryItemReceived) { SoundPlayer simpleSound = new SoundPlayer(Properties.Resources.Item_received); simpleSound.Play(); simpleSound.Dispose(); } timer1.Interval = instance.DialogTimeOut; timer1.Enabled = true; timer1.Start(); DateTime dte = DateTime.Now.AddMinutes(15.0d); label1.Text = "This item will be auto accepted @ " + dte.ToShortTimeString(); this.Text += " " + "[ " + client.Self.Name + " ]"; }
/// <summary> /// Called in every button press. /// </summary> public void OnButtonClick() { // Set selected asset type and active button. AvatarCreatorContext.selectedAssetType = m_assetType; AvatarCreatorContext.activeAssetCategoryButton = this; Debug.Log("Asset type changed to: " + m_assetType.ToString()); // Log user action. AvatarCreatorContext.logManager.LogAction("AssetSelected", m_assetType.ToString()); // Update asset list. UpdateScrollList(); }
public void UnloadUnitySceneMemory(AssetType assetType, Object asset) { if (asset != null) { if (assetType == AssetType.Prefab) { //资源是GameObject; GameObject go = asset as GameObject; if (go) { Destroy(go); return; } //泛型加载,资源是Prefab上的MonoBehaviour脚本; MonoBehaviour monoBehaviour = (MonoBehaviour)asset; if (monoBehaviour != null) { Destroy(monoBehaviour.gameObject); return; } } if (assetType == AssetType.AnimeClip || assetType == AssetType.AnimeCtrl || assetType == AssetType.Audio || assetType == AssetType.Texture || assetType == AssetType.Material) { Destroy(asset); return; } LogHelper.PrintError(string.Format("[ResourceMgr]UnloadUnityObject error,AssetType:{0},Object:{1}" , assetType.ToString(), asset.name)); } }
public AssetKey(AssetType assetType, params string[] tags) { AssetType = assetType; Tags = tags.Select(x => x.ToUpperInvariant()).OrderBy(x => x).ToArray(); var objects = Tags.Concat(new string[] { AssetType.ToString() }).ToArray(); compoundKey = new CompoundKey(objects); }
public Stock CreateStock(AssetType assetType, decimal price, int quantity, int occurences) { Stock stock; switch (assetType) { case AssetType.Bond: { stock = new Bond(); break; } case AssetType.Equity: { stock = new Equity(); break; } default: throw new Exception("Specify a valid AssetType"); } stock.Price = price; stock.Quantity = quantity; stock.StockName = assetType.ToString() + (occurences + 1).ToString(); return(stock); }
public static List <ResNode> GetAllAssetsFromPath(AssetType t, string path) { List <ResNode> reslut = null; if (null == path) { return(null); } if (path.Equals(string.Empty)) { return(null); } switch (t) { case AssetType.Asset_Prefab: reslut = GetPrefabsFromPatch(path); break; default: Debug.LogWarning(StringHelper.BuildString("类型:", t.ToString(), "不支持通过GetAllAssetsFromPath来获取")); break; } return(null); }
public static ResNode GetAssets(AssetType t, string assetBundleName, string assetName) { ResNode res = null; if (assetBundleName.Equals(string.Empty) || assetName.Equals(string.Empty)) { return(res); } switch (t) { case AssetType.Asset_Font: res = GetFont(assetBundleName, assetName); break; case AssetType.Asset_Sprite: res = GetSprite(assetBundleName, assetName); break; case AssetType.Asset_Prefab: res = GetPrefab(assetBundleName, assetName); break; default: Debug.LogWarning(StringHelper.BuildString("类型:", t.ToString(), "不支持通过assetbundlename和assetName来获取")); break; } return(res); }
/// <summary> /// 通过资源名字获得相对路径 /// </summary> /// <param name="name"></param> public static string GetRelativePathForName(string name) { string suffix = Path.GetExtension(name); AssetType type = EnumEditorTool.GetAssetType(suffix); return(AssetsFolderName + type.ToString() + "/" + name); }
private void placeAsset(AssetType assetType) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //If Keyboard place P, if touch screen press screen if ((Input.GetKeyDown("p")) || (((Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began)) && !EventSystem.current.IsPointerOverGameObject())) { if (Input.touchCount == 1) { drawerActive = false; } Debug.Log("p is pressed"); if (Physics.Raycast(ray, out hit, 100.0f)) { Debug.Log("Raycast hit, place Asset: " + assetType.ToString()); GameObject resource = Resources.Load <GameObject>("AssetsLibrary/" + assetType.ToString()); if (resource == null) { Debug.Log("Missing Resource of type: " + assetType.ToString()); } else { GameObject go = (GameObject)Instantiate(resource, new Vector3(hit.point.x, hit.point.y, hit.point.z), Quaternion.Euler(0, 0, 0)); //Update SynchedAsset SyncedAsset sa = go.GetComponent <SyncedAsset>(); if (sa == null) { Debug.Log("Resource Missing SyncedAsset"); } else { sa.sa_type = assetType.ToString(); sa.sa_createdBy = UserSettings.main.userName; } go.name = assetType.ToString(); //Return cursor to default Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); AddToTree(go, assetType); } } } }
public ntfGroupNotice(RadegastInstance instance, InstantMessage msg) : base(NotificationType.GroupNotice) { InitializeComponent(); Disposed += new System.EventHandler(ntfGroupNotice_Disposed); this.instance = instance; this.msg = msg; client.Groups.GroupProfile += new System.EventHandler <GroupProfileEventArgs>(Groups_GroupProfile); if (msg.BinaryBucket.Length > 18 && msg.BinaryBucket[0] != 0) { type = (AssetType)msg.BinaryBucket[1]; destinationFolderID = client.Inventory.FindFolderForType(type); int icoIndx = InventoryConsole.GetItemImageIndex(type.ToString().ToLower()); if (icoIndx >= 0) { //icnItem.Image = frmMain.ResourceImages.Images[icoIndx]; icnItem.Visible = true; } txtItemName.Text = Utils.BytesToString(msg.BinaryBucket, 18, msg.BinaryBucket.Length - 19); btnSave.Enabled = true; btnSave.Visible = icnItem.Visible = txtItemName.Visible = true; } if (msg.BinaryBucket.Length >= 18) { groupID = new UUID(msg.BinaryBucket, 2); } else { groupID = msg.FromAgentID; } int pos = msg.Message.IndexOf('|'); string title = msg.Message.Substring(0, pos); lblTitle.Text = title; string text = msg.Message.Replace("\n", System.Environment.NewLine); text = text.Remove(0, pos + 1); lblSentBy.Text = string.Format("Sent by {0}", msg.FromAgentName); txtNotice.Text = text; if (instance.Groups.ContainsKey(groupID)) { group = instance.Groups[groupID]; ShowNotice(); } else { client.Groups.RequestGroupProfile(groupID); } GUI.GuiHelpers.ApplyGuiFixes(this); }
protected override void ProcessRecord() { ResponseType response = null; base.ProcessRecord(); try { var applyTag = new applyTags { assetType = AssetType.ToString().ToUpperInvariant(), assetId = AssetId, }; if (ParameterSetName.Equals("With_TagKeyName")) { var applyByName = new ApplyTagType { tagKeyName = TagKeyName, value = Value, valueSpecified = !string.IsNullOrEmpty(Value) }; applyTag.tag = new[] { applyByName }; } else { var applyById = new ApplyTagByIdType { tagKeyId = TagKeyId, value = Value, valueSpecified = !string.IsNullOrEmpty(Value) }; applyTag.tagById = new[] { applyById }; } response = Connection.ApiClient.Tagging.ApplyTags(applyTag).Result; } catch (AggregateException ae) { ae.Handle( e => { if (e is ComputeApiException) { WriteError( new ErrorRecord(e, "-2", ErrorCategory.InvalidOperation, Connection)); } else { ThrowTerminatingError( new ErrorRecord(e, "-1", ErrorCategory.ConnectionError, Connection)); } return(true); }); } WriteObject(response); }
public ntfGroupNotice(RadegastInstance instance, InstantMessage msg) : base(NotificationType.GroupNotice) { InitializeComponent(); this.instance = instance; this.msg = msg; if (msg.BinaryBucket.Length > 18 && msg.BinaryBucket[0] != 0) { type = (AssetType)msg.BinaryBucket[1]; destinationFolderID = client.Inventory.FindFolderForType(type); int icoIndx = InventoryConsole.GetItemImageIndex(type.ToString().ToLower()); if (icoIndx >= 0) { icnItem.Image = frmMain.ResourceImages.Images[icoIndx]; icnItem.Visible = true; } txtItemName.Text = Utils.BytesToString(msg.BinaryBucket, 18, msg.BinaryBucket.Length - 19); btnSave.Enabled = true; btnSave.Visible = icnItem.Visible = txtItemName.Visible = true; } string group = string.Empty; string text = msg.Message.Replace("\n", System.Environment.NewLine); int pos = msg.Message.IndexOf('|'); string title = msg.Message.Substring(0, pos); text = text.Remove(0, pos + 1); if (instance.Groups.ContainsKey(msg.FromAgentID)) { group = instance.Groups[msg.FromAgentID].Name; if (instance.Groups[msg.FromAgentID].InsigniaID != UUID.Zero) { imgGroup.Init(instance, instance.Groups[msg.FromAgentID].InsigniaID, string.Empty); } } lblTitle.Text = title; lblSentBy.Text = string.Format("Sent by {0}, {1}", msg.FromAgentName, group); txtNotice.Text = text; // Fire off event NotificationEventArgs args = new NotificationEventArgs(instance); args.Text = string.Format("{0}{1}{2}{3}{4}", lblTitle.Text, System.Environment.NewLine, lblSentBy.Text, System.Environment.NewLine, txtNotice.Text ); if (btnSave.Visible == true) { args.Buttons.Add(btnSave); args.Text += string.Format("{0}Attachment: {1}", System.Environment.NewLine, txtItemName.Text); } args.Buttons.Add(btnOK); FireNotificationCallback(args); }
private void CreateUploadFolderIfNotExisted(AssetType typeFile) { string targetFolder = Path.Combine(_configuration.RootDataFolder, typeFile.ToString()); if (!_fileSystemService.Exists(targetFolder)) { _fileSystemService.CreateDirectory(targetFolder); } }
public override string ToString() { System.Text.StringBuilder aJSON = new System.Text.StringBuilder("{\n"); aJSON.Append("\"class\" : \"" + mType.ToString("g") + "\",\n"); aJSON.Append("\"guid\" : \"" + mGUID + "\",\n"); aJSON.Append("\"path\" : \"" + mAssetFilePath + "\""); aJSON.Append("\n}"); return(aJSON.ToString()); }
public static ResNode GetAssets(AssetType t, string strParam, bool isGuid = false) { ResNode res = null; if (null == strParam) { return(res); } if (strParam.Equals(string.Empty)) { return(res); } if (isGuid && t != AssetType.Asset_Prefab) { Debug.LogWarning(StringHelper.BuildString("类型:", t.ToString(), "不支持通过guid来获取")); return(null); } switch (t) { case AssetType.Asset_Font: res = GetFont(strParam); break; case AssetType.Asset_Cursour: res = GetCursorResource(strParam); break; case AssetType.Asset_Material: res = GetMaterialResource(strParam); break; case AssetType.Asset_Prefab: res = GetPrefab(strParam, isGuid); break; default: Debug.LogWarning(StringHelper.BuildString("类型:", t.ToString(), "不支持通过strParam来获取")); break; } return(res); }
public void ToString_ShouldReturnValue() { // Arrange const string assetTypeString = "Some Asset Type"; var assetType = new AssetType(assetTypeString); // Act var actual = assetType.ToString(); // Assert Assert.That(actual, Is.EqualTo(assetTypeString)); }
public ntfGroupNotice(RadegastInstance instance, InstantMessage msg) : base(NotificationType.GroupNotice) { InitializeComponent(); Disposed += new System.EventHandler(ntfGroupNotice_Disposed); this.instance = instance; this.msg = msg; client.Groups.GroupProfile += new System.EventHandler<GroupProfileEventArgs>(Groups_GroupProfile); if (msg.BinaryBucket.Length > 18 && msg.BinaryBucket[0] != 0) { type = (AssetType)msg.BinaryBucket[1]; destinationFolderID = client.Inventory.FindFolderForType(type); int icoIndx = InventoryConsole.GetItemImageIndex(type.ToString().ToLower()); if (icoIndx >= 0) { icnItem.Image = frmMain.ResourceImages.Images[icoIndx]; icnItem.Visible = true; } txtItemName.Text = Utils.BytesToString(msg.BinaryBucket, 18, msg.BinaryBucket.Length - 19); btnSave.Enabled = true; btnSave.Visible = icnItem.Visible = txtItemName.Visible = true; } if (msg.BinaryBucket.Length >= 18) { groupID = new UUID(msg.BinaryBucket, 2); } else { groupID = msg.FromAgentID; } int pos = msg.Message.IndexOf('|'); string title = msg.Message.Substring(0, pos); lblTitle.Text = title; string text = msg.Message.Replace("\n", System.Environment.NewLine); text = text.Remove(0, pos + 1); lblSentBy.Text = string.Format("Sent by {0}", msg.FromAgentName); txtNotice.Text = text; if (instance.Groups.ContainsKey(groupID)) { group = instance.Groups[groupID]; ShowNotice(); } else { client.Groups.RequestGroupProfile(groupID); } }
/// <summary> /// 获取AssetBundle文件的名字; /// </summary> /// <param name="type">资源类型</param> /// <param name="assetName">资源名字</param> /// <returns>AssetBundle资源名字</returns> public static string GetAssetBundleFileName(AssetType type, string assetName) { string assetBundleName = null; if (type == AssetType.Non || string.IsNullOrEmpty(assetName)) { return(assetBundleName); } //AssetBundle的名字不支持大写; //AssetBundle打包命名方式为[assetType/assetName.assetbundle],每个文件夹下的资源都带有相同的前缀,不同文件夹下,资源前缀不同; assetBundleName = (type.ToString() + "/" + assetName + ".assetbundle").ToLower(); return(assetBundleName); }
/// <summary> /// 本函数不能获取预制体和字体 /// </summary> /// <param name="t"></param> /// <param name="conf"></param> /// <param name="callBack"></param> /// <param name="userDataObj"></param> /// <returns></returns> public static ResNode GetAssetsAsync(AssetType t, ResConfigData conf, System.Action <ResConfigData, ResNode, System.Object> callBack, System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal) { ResNode res = null; if (null == conf) { return(res); } switch (t) { case AssetType.Asset_Prefab: UnionResConfigData unionCof = conf as UnionResConfigData; if (null == unionCof) { Debug.LogWarning("预制体参数转换失败,请确认参数2是否是UnionResConfigData类型"); return(null); } return(GetPrefabAsync(unionCof, callBack, userDataObj, priority)); case AssetType.Asset_FBX: return(GetFBXResourceAsync(conf, callBack, userDataObj, priority)); case AssetType.Asset_AnimationClip: return(GetAnimationClipResourceAsync(conf, callBack, userDataObj, priority)); case AssetType.Asset_AnimatorController: return(GetAnimatorControllerResourceAsync(conf, callBack, userDataObj, priority)); case AssetType.Asset_Audio: return(GetAudioResourceAsync(conf, callBack, userDataObj, priority)); case AssetType.Asset_Font: Debug.LogWarning("字体属于通用资源,不支持异步加载"); return(res); case AssetType.Asset_Material: return(GetMaterialResourceAsync(conf, callBack, userDataObj, priority)); case AssetType.Asset_Texture: return(GetTextureResourceAsync(conf, callBack, userDataObj, priority)); case AssetType.Asset_Sprite: return(GetSpriteAsync(conf.AssetBundleName, conf.AssetName, callBack, userDataObj, priority)); } Debug.LogWarning("无效的资源类型:" + t.ToString()); return(res); }
public override string Execute(string[] args, UUID fromAgentID) { if (args.Length != 2) { return(usage); } Success = false; AssetID = UUID.Zero; assetType = AssetType.Unknown; DownloadHandle.Reset(); if (!UUID.TryParse(args[0], out AssetID)) { return(usage); } try { assetType = (AssetType)Enum.Parse(typeof(AssetType), args[1], true); } catch (ArgumentException) { return(usage); } if (!Enum.IsDefined(typeof(AssetType), assetType)) { return(usage); } // Start the asset download Client.Assets.RequestAsset(AssetID, assetType, true, Assets_OnAssetReceived); if (DownloadHandle.WaitOne(120 * 1000, false)) { if (Success) { return(String.Format("Saved {0}.{1}", AssetID, assetType.ToString().ToLower())); } else { return(String.Format("Failed to download asset {0}, perhaps {1} is the incorrect asset type?", AssetID, assetType)); } } else { return("Timed out waiting for texture download"); } }
public override string Execute(string[] args, UUID fromAgentID) { if (args.Length != 2) { return("Usage: download [uuid] [assetType]"); } Success = false; AssetID = UUID.Zero; assetType = AssetType.Unknown; DownloadHandle.Reset(); if (UUID.TryParse(args[0], out AssetID)) { int typeInt; if (Int32.TryParse(args[1], out typeInt) && typeInt >= 0 && typeInt <= 22) { assetType = (AssetType)typeInt; // Start the asset download Client.Assets.RequestAsset(AssetID, assetType, true, Assets_OnAssetReceived); if (DownloadHandle.WaitOne(120 * 1000, false)) { if (Success) { return(String.Format("Saved {0}.{1}", AssetID, assetType.ToString().ToLower())); } else { return(String.Format("Failed to download asset {0}, perhaps {1} is the incorrect asset type?", AssetID, assetType)); } } else { return("Timed out waiting for texture download"); } } else { return("Usage: download [uuid] [assetType]"); } } else { return("Usage: download [uuid] [assetType]"); } }
private void RepopulateAssetTypeFilter() { TMP_Dropdown dropdown = assetFilterDropdown.GetComponent <TMP_Dropdown>(); dropdown.ClearOptions(); dropdown.options.Add(new TMP_Dropdown.OptionData("All")); Array assetTypes = Enum.GetValues(typeof(AssetType)); for (int i = 1; i < assetTypes.Length; i++) { AssetType assetType = (AssetType)assetTypes.GetValue(i); dropdown.options.Add(new TMP_Dropdown.OptionData(assetType.ToString())); } dropdown.RefreshShownValue(); }
public void CreateBondTest() { StockFactory stockFactory = new StockFactory(); AssetType type = AssetType.Bond; decimal price = 20; int quantity = 1; int occurence = 0; Stock s = stockFactory.CreateStock(type, price, quantity, occurence); Assert.AreEqual(s.AssetType, type); Assert.AreEqual(s.Price, price); Assert.AreEqual(s.Quantity, quantity); Assert.AreEqual(s.StockName, type.ToString() + (occurence + 1).ToString()); Assert.IsTrue(s.GetType() == typeof(Bond)); }
Asset CreateAsset(AssetType type, UUID assetID, byte[] data) { switch (type) { case AssetType.Bodypart: return(new AssetBodypart(assetID, data)); case AssetType.Clothing: return(new AssetClothing(assetID, data)); case AssetType.LSLBytecode: return(new AssetScriptBinary(assetID, data)); case AssetType.LSLText: return(new AssetScriptText(assetID, data)); case AssetType.Notecard: return(new AssetNotecard(assetID, data)); case AssetType.Texture: return(new AssetTexture(assetID, data)); case AssetType.Animation: return(new AssetAnimation(assetID, data)); case AssetType.CallingCard: case AssetType.Folder: case AssetType.Gesture: case AssetType.ImageJPEG: case AssetType.ImageTGA: case AssetType.Landmark: case AssetType.LostAndFoundFolder: case AssetType.Object: case AssetType.RootFolder: case AssetType.Simstate: case AssetType.SnapshotFolder: case AssetType.Sound: return(new AssetSound(assetID, data)); case AssetType.SoundWAV: case AssetType.TextureTGA: case AssetType.TrashFolder: case AssetType.Unknown: default: Logger.Log("Asset type " + type.ToString() + " not implemented!", Helpers.LogLevel.Warning); return(null); } }
public override void SetListBytes(Game game, Platform platform, ref List <byte> listBytes) { sectionType = Section.AHDR; listBytes.AddBigEndian(assetID); foreach (char i in assetType.ToString().PadRight(4)) { listBytes.Add((byte)i); } listBytes.AddBigEndian(fileOffset); listBytes.AddBigEndian(fileSize); listBytes.AddBigEndian(plusValue); listBytes.AddBigEndian((int)flags); ADBG.SetBytes(game, platform, ref listBytes); }
public void FilterForAssetType(AssetType type) { TMP_Dropdown dropdown = assetFilterDropdown.GetComponent <TMP_Dropdown>(); for (int i = 0; i < dropdown.options.Count; i++) { if (dropdown.options[i].text == type.ToString()) { dropdown.value = i; break; } } typeFilter = type; shouldRepopulate = true; }
/// <summary> /// Resource同步加载; /// </summary> /// <typeparam name="T">ctrl</typeparam> /// <param name="assetType">资源类型</param> /// <param name="assetName">资源名字</param> /// <returns>ctrl</returns> public T LoadResourceSync <T>(AssetType assetType, string assetName) where T : Object { string path = FilePathHelper.GetResourcePath(assetType, assetName); if (path != null) { //Resources.Load加载同一资源,只会有一份Asset,需要实例化的资源可以Instantiate多个对象; T ctrl = Resources.Load <T>(path); if (ctrl != null) { return(ctrl); } } LogHelper.PrintError(string.Format("[ResourceMgr]LoadResourceSync Load Asset {0} failure!", assetName + "." + assetType.ToString())); return(null); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("SerializedFileException:"); sb.Append(" v:").Append(Version.ToString()); sb.Append(" p:").Append(Platform.ToString()); sb.Append(" t:").Append(AssetType.ToString()); sb.Append(" n:").Append(FileName).AppendLine(); sb.Append("Path:").Append(FilePath).AppendLine(); sb.Append("Message: ").Append(Message).AppendLine(); if (InnerException != null) { sb.Append("Inner: ").Append(InnerException.ToString()).AppendLine(); } sb.Append("StackTrace: ").Append(StackTrace); return(sb.ToString()); }
public override string Execute(string[] args, UUID fromAgentID) { if (args.Length != 2) return "Usage: download [uuid] [assetType]"; Success = false; AssetID = UUID.Zero; assetType = AssetType.Unknown; DownloadHandle.Reset(); if (UUID.TryParse(args[0], out AssetID)) { int typeInt; if (Int32.TryParse(args[1], out typeInt) && typeInt >= 0 && typeInt <= 22) { assetType = (AssetType)typeInt; // Start the asset download Client.Assets.RequestAsset(AssetID, assetType, true, Assets_OnAssetReceived); if (DownloadHandle.WaitOne(120 * 1000, false)) { if (Success) return String.Format("Saved {0}.{1}", AssetID, assetType.ToString().ToLower()); else return String.Format("Failed to download asset {0}, perhaps {1} is the incorrect asset type?", AssetID, assetType); } else { return "Timed out waiting for texture download"; } } else { return "Usage: download [uuid] [assetType]"; } } else { return "Usage: download [uuid] [assetType]"; } }
/// <summary> /// 获取Resource文件加载路径; /// </summary> /// <param name="type">资源类型</param> /// <param name="assetName">资源名字</param> /// <returns>Resource资源路径;</returns> public static string GetResourcePath(AssetType type, string assetName) { if (type == AssetType.Non || type == AssetType.Scripts || string.IsNullOrEmpty(assetName)) { return(null); } string assetPath = null; switch (type) { case AssetType.Prefab: assetPath = "Prefab/"; break; default: assetPath = type.ToString() + "/"; break; } assetPath = assetPath + assetName; return(assetPath); }
private void LoadAllAssets(string bundleUrl, AssetBundle bundle) { foreach (var item in Enum.GetValues(typeof(AssetType))) { AssetType assetType = (AssetType)item; string variant = assetType.ToString().ToLower(); if (bundleUrl.EndsWith(variant)) { if (!AssetCacheList_.ContainsKey(assetType)) { AssetCacheList_.Add(assetType, new List <AssetCache>()); } string[] bundleNames = bundle.GetAllAssetNames(); for (int i = 0; i < bundleNames.Length; i++) { LoadAsset(bundleNames[i], bundle, assetType); } } } }
/// <summary> /// Resource异步加载; /// </summary> /// <typeparam name="T">ctrl</typeparam> /// <param name="assetType">资源类型</param> /// <param name="assetName">资源名字</param> /// <param name="proxy">代理</param> /// <param name="action">资源回调</param> /// <param name="progress">progress回调</param> /// <returns></returns> private IEnumerator <float> LoadResourceAsync <T>(AssetType assetType, string assetName, AsyncResourceProxy proxy , Action <T> action, Action <float> progress) where T : Object { string path = FilePathHelper.GetResourcePath(assetType, assetName); T ctrl = null; if (path != null) { ResourceRequest request = Resources.LoadAsync <T>(path); while (request.progress < 0.99) { if (progress != null) { progress(request.progress); } yield return(Timing.WaitForOneFrame); } while (!request.isDone) { yield return(Timing.WaitForOneFrame); } ctrl = request.asset as T; } if (null == ctrl) { LogHelper.PrintError(string.Format("[ResourceMgr]LoadResourceAsync Load Asset {0} failure!", assetName + "." + assetType.ToString())); } //-------------------------------------------------------------------------------------- //先等一帧; yield return(Timing.WaitForOneFrame); if (!proxy.IsCancel && action != null) { action(ctrl); } if (proxy != null) { proxy.OnFinish(ctrl); } }
private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset) { if (transfer.AssetID == AssetID) { if (transfer.Success) { try { File.WriteAllBytes(String.Format("{0}.{1}", AssetID, assetType.ToString().ToLower()), asset.AssetData); Success = true; } catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, ex); } } DownloadHandle.Set(); } }
public override string Execute(string[] args, UUID fromAgentID) { if (args.Length != 2) return usage; Success = false; AssetID = UUID.Zero; assetType = AssetType.Unknown; DownloadHandle.Reset(); if (!UUID.TryParse(args[0], out AssetID)) return usage; try { assetType = (AssetType)Enum.Parse(typeof(AssetType), args[1], ignoreCase: true); } catch (ArgumentException) { return usage; } if (!Enum.IsDefined(typeof(AssetType), assetType)) return usage; // Start the asset download Client.Assets.RequestAsset(AssetID, assetType, true, Assets_OnAssetReceived); if (DownloadHandle.WaitOne(120 * 1000, false)) { if (Success) return String.Format("Saved {0}.{1}", AssetID, assetType.ToString().ToLower()); else return String.Format("Failed to download asset {0}, perhaps {1} is the incorrect asset type?", AssetID, assetType); } else { return "Timed out waiting for texture download"; } }
public void RequestAsset(UUID uuid, AssetType assetType, bool priority) { m_log.Info("[REQ ASSET]: " + " " + uuid.ToString() + " " + assetType.ToString()); m_user.Assets.RequestAsset(uuid, assetType, priority); }
/// <summary> /// This method is called by establishAppearance to copy inventory folders to make /// copies of Clothing and Bodyparts inventory folders and attaches worn attachments /// </summary> private void CopyInventoryFolders(UUID destination, UUID source, AssetType assetType, Dictionary<UUID,UUID> inventoryMap, AvatarAppearance avatarAppearance) { IInventoryService inventoryService = manager.CurrentOrFirstScene.InventoryService; InventoryFolderBase sourceFolder = inventoryService.GetFolderForType(source, InventoryType.Unknown, assetType); InventoryFolderBase destinationFolder = inventoryService.GetFolderForType (destination, InventoryType.Unknown, assetType); if (sourceFolder == null || destinationFolder == null) throw new Exception("Cannot locate folder(s)"); // Missing source folder? This should *never* be the case if (sourceFolder.Type != (short)assetType) { sourceFolder = new InventoryFolderBase(); sourceFolder.ID = UUID.Random(); if (assetType == AssetType.Clothing) { sourceFolder.Name = "Clothing"; } else { sourceFolder.Name = "Body Parts"; } sourceFolder.Owner = source; sourceFolder.Type = (short)assetType; sourceFolder.ParentID = inventoryService.GetRootFolder(source).ID; sourceFolder.Version = 1; inventoryService.AddFolder(sourceFolder); // store base record m_log.ErrorFormat("[RADMIN] Created folder for source {0}", source); } // Missing destination folder? This should *never* be the case if (destinationFolder.Type != (short)assetType) { destinationFolder = new InventoryFolderBase(); destinationFolder.ID = UUID.Random(); destinationFolder.Name = assetType.ToString(); destinationFolder.Owner = destination; destinationFolder.Type = (short)assetType; destinationFolder.ParentID = inventoryService.GetRootFolder(destination).ID; destinationFolder.Version = 1; inventoryService.AddFolder(destinationFolder); // store base record m_log.ErrorFormat("[RADMIN] Created folder for destination {0}", source); } InventoryFolderBase extraFolder; List<InventoryFolderBase> folders = inventoryService.GetFolderContent(source, sourceFolder.ID).Folders; foreach (InventoryFolderBase folder in folders) { extraFolder = new InventoryFolderBase(); extraFolder.ID = UUID.Random(); extraFolder.Name = folder.Name; extraFolder.Owner = destination; extraFolder.Type = folder.Type; extraFolder.Version = folder.Version; extraFolder.ParentID = destinationFolder.ID; inventoryService.AddFolder(extraFolder); m_log.DebugFormat("[RADMIN] Added folder {0} to folder {1}", extraFolder.ID, sourceFolder.ID); List<InventoryItemBase> items = inventoryService.GetFolderContent(source, folder.ID).Items; foreach (InventoryItemBase item in items) { InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination); destinationItem.Name = item.Name; destinationItem.Description = item.Description; destinationItem.InvType = item.InvType; destinationItem.CreatorId = item.CreatorId; destinationItem.CreatorData = item.CreatorData; destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid; destinationItem.NextPermissions = item.NextPermissions; destinationItem.CurrentPermissions = item.CurrentPermissions; destinationItem.BasePermissions = item.BasePermissions; destinationItem.EveryOnePermissions = item.EveryOnePermissions; destinationItem.GroupPermissions = item.GroupPermissions; destinationItem.AssetType = item.AssetType; destinationItem.AssetID = item.AssetID; destinationItem.GroupID = item.GroupID; destinationItem.GroupOwned = item.GroupOwned; destinationItem.SalePrice = item.SalePrice; destinationItem.SaleType = item.SaleType; destinationItem.Flags = item.Flags; destinationItem.CreationDate = item.CreationDate; destinationItem.Folder = extraFolder.ID; ILLClientInventory inventoryModule = manager.CurrentOrFirstScene.RequestModuleInterface<ILLClientInventory>(); if (inventoryModule != null) inventoryModule.AddInventoryItem(destinationItem); inventoryMap.Add(item.ID, destinationItem.ID); m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, extraFolder.ID); // Attach item, if original is attached int attachpoint = avatarAppearance.GetAttachpoint(item.ID); if (attachpoint != 0) { avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID); m_log.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID); } } } }
Asset CreateAsset(AssetType type, UUID assetID, byte[] data) { switch (type) { case AssetType.Bodypart: return new AssetBodypart(assetID, data); case AssetType.Clothing: return new AssetClothing(assetID, data); case AssetType.LSLBytecode: return new AssetScriptBinary(assetID, data); case AssetType.LSLText: return new AssetScriptText(assetID, data); case AssetType.Notecard: return new AssetNotecard(assetID, data); case AssetType.Texture: return new AssetTexture(assetID, data); case AssetType.Animation: return new AssetAnimation(assetID, data); case AssetType.CallingCard: case AssetType.Folder: case AssetType.Gesture: case AssetType.ImageJPEG: case AssetType.ImageTGA: case AssetType.Landmark: case AssetType.LostAndFoundFolder: case AssetType.Object: case AssetType.RootFolder: case AssetType.Simstate: case AssetType.SnapshotFolder: case AssetType.Sound: return new AssetSound(assetID, data); case AssetType.SoundWAV: case AssetType.TextureTGA: case AssetType.TrashFolder: case AssetType.Unknown: default: Logger.Log("Asset type " + type.ToString() + " not implemented!", Helpers.LogLevel.Warning); return null; } }
bool Inventory_OnInventoryObjectReceived(UUID fromAgentID, string fromAgentName, uint parentEstateID, UUID regionID, Vector3 position, DateTime timestamp, AssetType type, UUID objectID, bool fromTask) { InventoryBase obj = Session.Client.Inventory.Store[objectID]; Display.InventoryItemReceived(Session.SessionNumber, fromAgentID, fromAgentName, parentEstateID, regionID, position, timestamp, obj); Dictionary<string, string> identifiers = new Dictionary<string, string>(); identifiers.Add("$name", fromAgentName); identifiers.Add("$id", fromAgentID.ToString()); identifiers.Add("$item", obj.Name); identifiers.Add("$itemid", objectID.ToString()); identifiers.Add("$type", type.ToString()); ScriptSystem.TriggerEvents(Session.SessionNumber, ScriptSystem.EventTypes.GetItem, identifiers); return true; }
public ntfInventoryOffer(RadegastInstance instance, InstantMessage msg) : base(NotificationType.InventoryOffer) { InitializeComponent(); Disposed += new EventHandler(ntfInventoryOffer_Disposed); this.instance = instance; this.msg = msg; instance.Names.NameUpdated += new EventHandler<UUIDNameReplyEventArgs>(Avatars_UUIDNameReply); if (msg.BinaryBucket.Length > 0) { type = (AssetType)msg.BinaryBucket[0]; destinationFolderID = client.Inventory.FindFolderForType(type); if (msg.BinaryBucket.Length == 17) { objectID = new UUID(msg.BinaryBucket, 1); } if (msg.Dialog == InstantMessageDialog.InventoryOffered) { txtInfo.Text = string.Format("{0} has offered you {1} \"{2}\".", msg.FromAgentName, type.ToString(), msg.Message); } else if (msg.Dialog == InstantMessageDialog.TaskInventoryOffered) { txtInfo.Text = objectOfferText(); } // Fire off event NotificationEventArgs args = new NotificationEventArgs(instance); args.Text = txtInfo.Text; args.Buttons.Add(btnAccept); args.Buttons.Add(btnDiscard); args.Buttons.Add(btnIgnore); FireNotificationCallback(args); } else { Logger.Log("Wrong format of the item offered", Helpers.LogLevel.Warning, client); } }
bool Inventory_OnObjectOffered(InstantMessage offerDetails, AssetType type, UUID objectID, bool fromTask) { AutoResetEvent ObjectOfferEvent = new AutoResetEvent(false); ResponseType object_offer_result=ResponseType.Yes; string msg = ""; ResponseType result; if (!fromTask) msg = "The user "+offerDetails.FromAgentName + " has offered you\n" + offerDetails.Message + "\n Which is a " + type.ToString() + "\nPress Yes to accept or no to decline"; else msg = "The object "+offerDetails.FromAgentName + " has offered you\n" + offerDetails.Message + "\n Which is a " + type.ToString() + "\nPress Yes to accept or no to decline"; Application.Invoke(delegate { ObjectOfferEvent.Reset(); Gtk.MessageDialog md = new MessageDialog(MainClass.win, DialogFlags.Modal, MessageType.Other, ButtonsType.YesNo, false, msg); result = (ResponseType)md.Run(); object_offer_result=result; md.Destroy(); ObjectOfferEvent.Set(); }); ObjectOfferEvent.WaitOne(1000*3600,false); if (object_offer_result == ResponseType.Yes) { if(OnInventoryAccepted!=null) { OnInventoryAccepted(type,objectID); } return true; } else { return false; } }
public string GetAssetUrl(AssetType assetType, string theme, string assetName, UrlHelper helper) { if (Settings.Default.UseCDN) { string url = GetCdnUrl(assetName); if (url != null) return url; } string type = assetType.ToString().ToLower(); if (theme != null) { string path = string.Format("~/{0}/{1}/{2}", type, theme, assetName); if (File.Exists(HostingEnvironment.MapPath(path))) return helper.Content(path); path = string.Format("~/{0}/default/{1}", type, assetName); if (File.Exists(HostingEnvironment.MapPath(path))) return helper.Content(path); } return helper.Content(string.Format("~/{0}/{1}", type, assetName)); }
public IEnumerable<string> GetAssetSources(AssetType type, PageModel pageModel, UrlHelper helper) { //load items not in any group or delivered by CDN foreach (Asset asset in GetNonGroupedAssets(pageModel.Assets, type)) { if (Settings.Default.UseCDN && GetCdnUrl(asset.Name) != null) yield return GetCdnUrl(asset.Name); else yield return helper.AssetPath(asset.AssetType, asset.Name); } var groups = pageModel.Assets.Select(a => a.Group).Distinct().ToArray(); var grouped = GetGroupedAssets(pageModel.Assets, groups, type); if (AssetGroupMode == AssetGroupMode.Disabled) { foreach (string s in grouped.Select(a => helper.AssetPath(a.AssetType, a.Name))) yield return s; } else //load local via combination { if (grouped.Count > 0) { foreach (string group in groups) { //the following method will load and cache the combined script for later var version = GetGroupCombined(type, group, helper).Md5; //add versioning querystring for future updates overridding expires yield return helper.RouteUrl("AssetGroup" + type.ToString(), new { group = group, v = version }); } } } }