protected void doDataBind() { AssetUtility Util = new AssetUtility(); if (txtId.Text != "") { SqlDS_AllHistory.SelectParameters["param"].DefaultValue = Util.CleanInput(txtId.Text); SqlDS_AllHistory.SelectCommand = "SELECT * FROM [vw_All_ProductHistory] WHERE ([ITAssetProductInfoID] = @param)"; } else if (txtUniquePartNumber.Text != "") { SqlDS_AllHistory.SelectParameters["param"].DefaultValue = Util.CleanInput(txtUniquePartNumber.Text); SqlDS_AllHistory.SelectCommand = "SELECT * FROM [vw_All_ProductHistory] WHERE ([UniquePartNum] = @param)"; } if (!string.IsNullOrEmpty(Request.QueryString["id"])) { if (!IsPostBack) { hfSelectedTAB.Value = "1"; } Int32 RowID = Convert.ToInt32(Request.QueryString["id"]); SqlDS_AllHistory.SelectCommand = "SELECT * FROM [vw_All_ProductHistory] WHERE ([ITAssetProductInfoID] = @param)"; SqlDS_AllHistory.SelectParameters["param"].DefaultValue = RowID.ToString(); } }
public ScriptManifest(string name) { manifestPath = new AssetUtility(Options.ScriptPath).GetAsset(name).FilePath; specialComment = new Dictionary<string, string>() { {".js", "//="}, {".coffee", "#="} }[Path.GetExtension(manifestPath)]; }
protected void Button1_Click(object sender, EventArgs e) { //prevent SQL Injection AssetUtility Util = new AssetUtility(); string InputKeyword = Keywords.Text; SqlDataSource1.SelectCommand = string.Format("SELECT * FROM [vw_ITAssetAllProducts] WHERE (([TypeName] LIKE '%{0}%') OR ([SubTypeName] LIKE '%{0}%') OR ([ITAssetDetails] LIKE '%{0}%') OR ([UniquePartNum] LIKE '%{0}%') OR ([UserName] LIKE '%{0}%') OR ([Location] LIKE '%{0}%'))", Util.CleanInput(InputKeyword)); GridView1.AllowPaging = false ; }
public IEnumerable<Asset> GetAssets() { var assetUtility = new AssetUtility(Options.ScriptPath); foreach (var line in File.ReadAllLines(manifestPath)) { var match = Regex.Split(line, specialComment + " require "); if (match.Length > 1) { yield return assetUtility.GetAsset(match[1] + ".*"); } else { match = Regex.Split(line, specialComment + " require_tree "); foreach (var asset in assetUtility.GetAssets(match[1])) yield return asset; } } }
internal static T AssetUtilityLoader(AssetBundleInfo assetBundleInfo) { return(AssetUtility.LoadAsset <T>(assetBundleInfo)); }
internal static T AssetUtilityLoader(string assetBundle, string assetName, string manifest) { return(AssetUtility.LoadAsset <T>(assetBundle, assetName, manifest)); }
// Start Filtering Panel Events private void SetSearchSQL(string fieldName, string filterValue) { AssetUtility Util = new AssetUtility(); string sql = String.Format("SELECT * FROM [dbo].[vw_DCC_DocDB_ALL] WHERE [{0}] ", fieldName); if (filterValue == "") { sql = "SELECT * FROM [dbo].[vw_DCC_DocDB_ALL] WHERE 1<>1"; } else { switch (fieldName) { case "DocID": sql += "=" + Util.CleanInput(filterValue) + ";"; break; case "DCCLogNo": sql += "LIKE '" + Util.CleanInput(filterValue) + "%'"; break; default: sql += "LIKE '%" + Util.CleanInput(filterValue) + "%'"; break; } SqlDS_Gridview_Main.SelectCommand = sql; gridview_main.AllowPaging = false; SqlDS_Gridview_Main.DataBind(); } }
private GameObject PersistAsset(GameObject oldAsset, GameObject newAsset, string assetName, string assetPath) { var fullAssetPath = GetAssetPath(assetName, assetPath, "prefab"); AssetUtility.CreatePathFolders(fullAssetPath); // Is there an earlier instance of the asset already generated and persisted? if (oldAsset != null && AssetDatabase.Contains(oldAsset)) { // Is the earlier asset and this asset exactly the same type? if (oldAsset.GetType() == newAsset.GetType()) { // Check the earlier asset's path, to see if it's already in the right place. var currentPath = AssetUtility.GetProjectRelativeAssetPath(oldAsset); if (currentPath != fullAssetPath) { // If there's any asset that is a part of this collection, then rename it so that the old asset can be moved. FindAndMoveAnyConflictingObject(fullAssetPath, oldAsset); // Move the old asset to the new location. var errorMessage = AssetDatabase.MoveAsset(currentPath, fullAssetPath); if (!string.IsNullOrEmpty(errorMessage)) { throw new System.InvalidOperationException(errorMessage); } } // Replace the earlier prefab with the new instance. GameObject prefab = oldAsset; if (!ReferenceEquals(newAsset, oldAsset)) { prefab = PrefabUtility.ReplacePrefab(newAsset as GameObject, oldAsset, ReplacePrefabOptions.ConnectToPrefab); } // Add the new prefab to the asset collection. _assetCollection.AddDiscrete(prefab); EditorUtility.SetDirty(_assetCollection); // Destroy the template upon which the newly created prefab was based, since it will have been created within the scene. DestroyImmediate(newAsset); return(prefab); } // The earlier asset and the new instance have different types. else { // There's no way to maintain references, so just delete the old instance. _assetCollection.Remove(oldAsset); DestroyImmediate(oldAsset, true); // If there's any asset that is a part of this collection, then rename it so that the new asset can be persisted. FindAndMoveAnyConflictingObject(fullAssetPath); // Create a new prefab based on the supplied template. var prefab = PrefabUtility.CreatePrefab(fullAssetPath, newAsset as GameObject); // Add the new prefab to the asset collection. _assetCollection.AddDiscrete(prefab); EditorUtility.SetDirty(_assetCollection); // Destroy the template upon which the newly created prefab was based, since it will have been created within the scene. DestroyImmediate(newAsset); return(prefab); } } // There was no earlier persistent instance of the asset, so there is nothing to replace. else { // Create a new prefab based on the supplied template. var prefab = PrefabUtility.CreatePrefab(fullAssetPath, newAsset as GameObject); // Add the new prefab to the asset collection. _assetCollection.AddDiscrete(prefab); EditorUtility.SetDirty(_assetCollection); // Destroy the template upon which the newly created prefab was based, since it will have been created within the scene. DestroyImmediate(newAsset); return(prefab); } }
/// <summary> /// 获得资源的名称(请不要在一个不是Mod资源的对象上调用此函数) /// </summary> public static string GetAssetNameEditor <T>(this T asset) where T : UnityEngine.Object { return(AssetUtility.GetAssetName(asset.name)); }
protected void Page_Load(object sender, EventArgs e) { AssetUtility Util = new AssetUtility(); // Create new Utility Instance lblUser.Text = "Current User: " + Util.showUserName(); StyleSelectedMenu(); }
protected void hfUserName_Load(object sender, EventArgs e) { AssetUtility Ut = new AssetUtility(); hfUserName.Value = Ut.GetUserNameOnly(); }
//--------------------------------------------------------------------------------------------------------------------- /// <summary> /// Import a timeline file exported from DCC tools into the scene in the Timeline object /// </summary> /// <param name="jsTimelinePath">The path of the file</param> /// <param name="destFolder">The dest folder of the imported files</param> public static void ImportTimeline(string jsTimelinePath, string destFolder = "") { // prepare asset name, paths, etc string assetName = Path.GetFileNameWithoutExtension(jsTimelinePath); string timelineFolder = Path.GetDirectoryName(jsTimelinePath); if (string.IsNullOrEmpty(timelineFolder)) { Debug.LogError("Can't get directory name for: " + jsTimelinePath); return; } timelineFolder = Path.Combine(timelineFolder, destFolder, assetName).Replace("\\", "/"); //Check if we are exporting from external asset if (!timelineFolder.StartsWith("Assets/")) { timelineFolder = Path.Combine("Assets", destFolder, assetName); } Directory.CreateDirectory(timelineFolder); string strJson = File.ReadAllText(jsTimelinePath); TimelineParam container = JsonUtility.FromJson <TimelineParam>(strJson); string assetFolder = container.assetFolder; if (string.IsNullOrEmpty(assetFolder)) { assetFolder = Path.GetDirectoryName(jsTimelinePath); } //delete existing objects in the scene that is pointing to the Director string timelinePath = Path.Combine(timelineFolder, assetName + "_Timeline.playable").Replace("\\", "/"); PlayableDirector director = RemovePlayableFromDirectorsInScene(timelinePath); if (null == director) { GameObject directorGo = new GameObject(assetName); director = directorGo.AddComponent <PlayableDirector>(); } //Create timeline asset TimelineAsset asset = ScriptableObject.CreateInstance <TimelineAsset>(); AssetEditorUtility.OverwriteAsset(asset, timelinePath); director.playableAsset = asset; string strHome = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); int numTracks = container.Tracks.Length; for (int index = numTracks - 1; index >= 0; index--) { var track = container.Tracks[index]; string strFootagePath = track.Footage; // remove '~' if necessary if (strFootagePath.StartsWith("~")) { strFootagePath = strHome + strFootagePath.Substring(1); } if (!Path.IsPathRooted(strFootagePath)) { strFootagePath = Path.Combine(assetFolder, strFootagePath); } string strFootageName = Path.GetFileNameWithoutExtension(strFootagePath); string strJsonFootage = File.ReadAllText(strFootagePath); AEFootageInfo footageInfo = JsonUtility.FromJson <AEFootageInfo>(strJsonFootage); int numImages = footageInfo.Pictures.Count; if (numImages > 0) { List <string> originalImagePaths = new List <string>(footageInfo.Pictures); for (int xx = 0; xx < numImages; ++xx) { string fileName = footageInfo.Pictures[xx]; // replace '~' with the path to home (for Linux environment if (fileName.StartsWith("~")) { fileName = strHome + fileName.Substring(1); } footageInfo.Pictures[xx] = Path.GetFileName(fileName); } string destFootageFolder = Application.streamingAssetsPath; destFootageFolder = Path.Combine(destFootageFolder, strFootageName).Replace("\\", "/"); Directory.CreateDirectory(destFootageFolder); //make sure the directory exists footageInfo.Folder = AssetUtility.NormalizeAssetPath(destFootageFolder); for (int i = 0; i < numImages; ++i) { string destFilePath = Path.Combine(destFootageFolder, footageInfo.Pictures[i]); if (File.Exists(destFilePath)) { File.Delete(destFilePath); } string srcFilePath = Path.GetFullPath(Path.Combine(assetFolder, originalImagePaths[i])).Replace("\\", "/"); FileUtil.CopyFileOrDirectory(srcFilePath, destFilePath); } } //Convert to WatchedFileInfo List <WatchedFileInfo> imageFiles = WatchedFileInfo.CreateList(footageInfo.Folder, footageInfo.Pictures); StreamingImageSequencePlayableAsset sisAsset = ScriptableObject.CreateInstance <StreamingImageSequencePlayableAsset>(); sisAsset.InitFolderInEditor(footageInfo.Folder, imageFiles, footageInfo.Resolution); string playableAssetPath = Path.Combine(timelineFolder, strFootageName + "_StreamingImageSequence.playable"); AssetEditorUtility.OverwriteAsset(sisAsset, playableAssetPath); StreamingImageSequenceTrack movieTrack = asset.CreateTrack <StreamingImageSequenceTrack>(null, strFootageName); TimelineClip clip = movieTrack.CreateDefaultClip(); clip.asset = sisAsset; clip.start = track.Start; clip.duration = track.Duration; clip.CreateCurves("Curves: " + clip.displayName); SISClipData sisData = new SISClipData(clip); sisAsset.BindClipData(sisData); ExtendedClipEditorUtility.ResetClipDataCurve(sisAsset, StreamingImageSequencePlayableAsset.GetTimeCurveBinding()); if (Object.FindObjectOfType(typeof(UnityEngine.EventSystems.EventSystem)) == null) { var es = new GameObject(); es.AddComponent <UnityEngine.EventSystems.EventSystem>(); es.AddComponent <UnityEngine.EventSystems.StandaloneInputModule>(); es.name = "EventSystem"; } GameObject canvasObj = null; Canvas canvas = Object.FindObjectOfType(typeof(Canvas)) as Canvas; if (canvas != null) { canvasObj = canvas.gameObject; } else { canvasObj = UIUtility.CreateCanvas().gameObject; } Transform directorT = director.gameObject.transform; directorT.SetParent(canvasObj.transform); directorT.localPosition = new Vector3(0.0f, 0.0f, 0.0f); GameObject imageGo = null; Transform imageT = directorT.Find(strFootageName); if (null == imageT) { imageGo = new GameObject(strFootageName); imageT = imageGo.transform; } else { imageGo = imageT.gameObject; } Image image = imageGo.GetOrAddComponent <Image>(); StreamingImageSequenceRenderer renderer = imageGo.GetOrAddComponent <StreamingImageSequenceRenderer>(); RectTransform rectTransform = imageGo.GetComponent <RectTransform>(); rectTransform.SetParent(directorT); rectTransform.localPosition = new Vector3(0.0f, 0.0f, 0.0f); rectTransform.sizeDelta = new Vector2(footageInfo.Resolution.Width, footageInfo.Resolution.Height); director.SetGenericBinding(movieTrack, renderer); EditorUtility.SetDirty(director); } //cause crash if this is called inside of OnImportAsset() UnityEditor.EditorApplication.delayCall += () => { AssetDatabase.Refresh(); if (null != director) { Selection.activeGameObject = director.gameObject; } }; }
public static void ShowWeapon(Type logicType, string entityGroup, EntityData data) { ShowEntity <DRWeapon> (logicType, entityGroup, data, (assetName) => AssetUtility.GetEntityAsset(assetName)); }
//public static void ShowParticle (Type logicType, string entityGroup, EntityData data) { // ShowEntity<DRParticle> (logicType, entityGroup, data, (assetName) => AssetUtility.GetEntityAsset (assetName)); //} public static void ShowMonsterCreater(Type logicType, string entityGroup, EntityData data) { ShowEntity <DRMonsterCreater> (logicType, entityGroup, data, (assetName) => AssetUtility.GetEntityAsset(assetName)); }
public static void ShowBulletEffect(Type logicType, string entityGroup, EntityData data) { ShowEntity <DRBulletEffect> (logicType, entityGroup, data, (assetName) => AssetUtility.GetBulletEffectAsset(assetName)); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { return(AssetUtility.GetHeight(label, GetNumLinesToDraw(property, label), VerticalMargin)); }
//---------------------------------------------------------------------------------------------------------------------- void DrawCacheSettings(SerializedObject so) { GUIStyle styleFold = EditorStyles.foldout; styleFold.fontStyle = FontStyle.Bold; m_sceneCachePlayer.foldCacheSettings = EditorGUILayout.Foldout(m_sceneCachePlayer.foldCacheSettings, "Player", true, styleFold); if (m_sceneCachePlayer.foldCacheSettings) { //Show Selector GUI. Check if we should reopen string fullPath = m_sceneCachePlayer.GetSceneCacheFilePath(); string prevNormalizedPath = AssetUtility.NormalizeAssetPath(fullPath); string newNormalizedPath = EditorGUIDrawerUtility.DrawFileSelectorGUI("Cache File Path", "MeshSync", prevNormalizedPath, "sc", OnSceneCacheFileReload, AssetUtility.NormalizeAssetPath); if (newNormalizedPath != prevNormalizedPath) { ChangeSceneCacheFileInInspector(m_sceneCachePlayer, newNormalizedPath); } if (!string.IsNullOrEmpty(fullPath) && !fullPath.StartsWith(Application.streamingAssetsPath)) { GUILayout.BeginHorizontal(); const float BUTTON_WIDTH = 50.0f; if (GUILayout.Button("Copy", GUILayout.Width(BUTTON_WIDTH))) { string dstPath = Misc.CopyFileToStreamingAssets(fullPath); ChangeSceneCacheFileInInspector(m_sceneCachePlayer, dstPath); } GUILayout.Label("Scene Cache file to StreamingAssets"); EditorGUILayout.LabelField("(RECOMMENDED)", EditorStyles.boldLabel); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(15); } EditorGUILayout.Space(); // time / frame System.Action resetTimeAnimation = () => { so.ApplyModifiedProperties(); m_sceneCachePlayer.ResetTimeAnimation(); }; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(so.FindProperty("m_timeUnit")); if (EditorGUI.EndChangeCheck()) { resetTimeAnimation(); } if (m_sceneCachePlayer.timeUnit == SceneCachePlayer.TimeUnit.Seconds) { EditorGUILayout.PropertyField(so.FindProperty("m_time")); EditorGUILayout.PropertyField(so.FindProperty("m_interpolation")); } else if (m_sceneCachePlayer.timeUnit == SceneCachePlayer.TimeUnit.Frames) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(so.FindProperty("m_baseFrame")); if (EditorGUI.EndChangeCheck()) { resetTimeAnimation(); } EditorGUILayout.PropertyField(so.FindProperty("m_frame")); } // preload { SerializedProperty preloadLength = so.FindProperty("m_preloadLength"); preloadLength.intValue = EditorGUILayout.IntSlider("Preload Length", preloadLength.intValue, 0, m_sceneCachePlayer.frameCount); } EditorGUILayout.Space(); } }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetsPaths) { repeat += 1; if (repeat > 100) { return; } //先处理导入的资源 for (int i = 0; i < importedAssets.Length; i++) { var asset = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(importedAssets[i]); var ModName = ModsEditor.GetModNameByPath(importedAssets[i]); //如果该资源不属于任何一个Mod或者是文件夹,无视 if (ModName == null || AssetDatabase.IsValidFolder(importedAssets[i])) { continue; } ImportAsset(ModName, asset); } //再处理删除的资源 for (int i = 0; i < deletedAssets.Length; i++) { var ModName = ModsEditor.GetModNameByPath(deletedAssets[i]); //如果该资源不属于任何一个Mod或者是文件夹,无视 if (ModName == null || AssetDatabase.IsValidFolder(deletedAssets[i])) { continue; } var AssetName = ModsEditor.GetAssetNameByPath(deletedAssets[i]); DeleteAsset(ModName, AssetName); } //最后处理移动的资源 for (int i = 0; i < movedAssets.Length; i++) { var asset = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(movedAssets[i]); var FromMod = ModsEditor.GetModNameByPath(movedFromAssetsPaths[i]); var ToMod = ModsEditor.GetModNameByPath(movedAssets[i]); var assetName = asset.GetAssetNameEditor(); //如果没有移动到另一个Mod或移动的是文件夹,无视(都为null,即并非Mod之间的资源移动,也无视) if (FromMod == ToMod || AssetDatabase.IsValidFolder(movedAssets[i])) { continue; } if (FromMod == null) { ImportAsset(ToMod, asset); continue; } if (ToMod == null) { AssetDatabase.RenameAsset(movedAssets[i], assetName); DeleteAsset(FromMod, assetName); continue; } var FromModAI = ModsEditor.GetAssetIndexer(FromMod); string newFullName = ToMod + "." + assetName; //将AssetInfo转移出来 var Info = FromModAI[asset.name]; FromModAI.Remove(asset.name); //更改Mod名 asset.name = assetName; newFullName = RenameAsset(newFullName, asset); //再将AssetInfo转移到新Mod Info.ModName = ToMod; Info.ModId = ModsEditor.GetModId(ToMod); Info.AssetName = AssetUtility.GetAssetName(newFullName);//如果发生了重名事件可以修改成新名称 ModsEditor.GetAssetIndexer(ToMod).Add(newFullName, Info); } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
private IEnumerator BeginGeneration() { yield return(UpdateGenerationProgress(0, "Preparing...")); var currentStep = 0; yield return(UpdateGenerationProgress(++currentStep, "Preparing...")); AssetDatabase.Refresh(); yield return(UpdateGenerationProgress(++currentStep, "Preparing...")); UpdateAssetCollection(); yield return(UpdateGenerationProgress(++currentStep, "Preparing...")); var generators = GetDependencyOrderedGenerators(); // Generate all assets, moving or renaming the outputs if necessary. var discreteAssets = new List <object>(); foreach (var generator in generators) { yield return(UpdateGenerationProgress(++currentStep, string.Format("Generating ({0}/{1})...", currentStep - 4, generators.Count))); var generation = generator.BeginGeneration(); while (generation.MoveNext()) { if (generation.Current is WaitHandle) { var waitHandle = (WaitHandle)generation.Current; while (waitHandle.WaitOne(10) == false) { yield return(UpdateGenerationProgress(currentStep)); } if (_generationException != null) { var exception = _generationException; _generationException = null; throw exception; } } else { yield return(UpdateGenerationProgress(currentStep)); } } foreach (var output in generator.activeOutputs) { discreteAssets.Add(output.asset); } } yield return(UpdateGenerationProgress(++currentStep, "Finalizing...", _generators)); // Embed objects within generator collection. var embeddedAssets = EmbedAssets(); yield return(UpdateGenerationProgress(++currentStep, "Finalizing...")); DestroyLeftoverEmbeddedAssets(embeddedAssets); DestroyLeftoverDiscreteAssets(discreteAssets); yield return(UpdateGenerationProgress(++currentStep, "Finalizing...")); EditorUtility.SetDirty(this); AssetDatabase.SaveAssets(); AssetUtility.RecursivelyDeleteEmptyFolders(AssetUtility.GetProjectRelativeAssetFolder(this), false); yield return(UpdateGenerationProgress(++currentStep, "Finalizing...")); AssetDatabase.Refresh(); yield return(UpdateGenerationProgress(++currentStep, "Generation Complete")); }
static void reloadAsset() { tmpAsset = new SerializedObject(AssetUtility.LoadAsset <DynamicLightSetting>("Assets/2DDL/2DLight/Settings", "Settings.asset")); //Debug.Log ("reloadAsset"); }
protected override void OnProcessShaderInternal(Shader shader , ShaderSnippetData snippet , IList <ShaderCompilerData> data) { #region Builtin bool isBuiltinShader = AssetUtility.IsBuiltinOrLibraryAsset(shader); if (isBuiltinShader) { m_BuiltinShaders[shader.name] = data.Count + (m_BuiltinShaders.TryGetValue(shader.name, out int count) ? count : 0); } #endregion #region ProcessInfo ProcessInfo processInfo = new ProcessInfo(); processInfo.IsBuiltinShader = isBuiltinShader; processInfo.ShaderName = shader.name; processInfo.ShaderType = snippet.shaderType; processInfo.PassType = snippet.passType; processInfo.PassName = snippet.passName; processInfo.Compilers = new CompilerInfo[data.Count]; Parallel.For(0, data.Count, (iShader) => { processInfo.Compilers[iShader] = GenerateCompilerInfo(data[iShader]); }); processInfo.Keywords = CollectionKeywords(processInfo.Compilers); #endregion #region Summary { string shaderName = (processInfo.IsBuiltinShader ? "B_" : "") + processInfo.ShaderName; if (!m_ShaderInfos.TryGetValue(shaderName, out ShaderInfo shaderInfo)) { shaderInfo = new ShaderInfo(); m_ShaderInfos.Add(shaderName, shaderInfo); } shaderInfo.ShaderTypes.Add(processInfo.ShaderType); shaderInfo.PassTypes.Add(processInfo.PassType); shaderInfo.VariantCount += processInfo.Compilers.Length; for (int iKeyword = 0; iKeyword < processInfo.Keywords.Length; iKeyword++) { shaderInfo.Keywords.Add(processInfo.Keywords[iKeyword]); } } #endregion int index = ++m_HandledShader; Task.Run(() => { try { string directory = $"{m_ReportDirectory}/{(processInfo.IsBuiltinShader ? "B_" : "")}{StringUtility.FormatToFileName(processInfo.ShaderName)}/"; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } string processName = $"_({processInfo.ShaderType})_({processInfo.PassType})_({processInfo.PassName})_Count("; string path = $"{directory}{index}_{processName}{processInfo.Compilers.Length}).csv"; File.WriteAllText(path , GenerateCompilersReport(processInfo.Compilers, processInfo.Keywords)); MDebug.LogVerbose("Shader", "Save PreprocessShaderReport to path " + path); } catch (Exception e) { MDebug.LogError("Shader" , "Save PreprocessShaderReport Exception:\n" + e.ToString()); } }); }
protected virtual void CreateNewAsset(List <AssetInfo> assetInfoList) { var newAsset = AssetUtility.CreateAsset(WrapperAssetType, AssetType.Name, true); assetInfoList.Add(new AssetInfo(newAsset)); }
private Object PersistHiddenAsset(Object oldAsset, Object newAsset, string assetName) { if (typeof(GameObject).IsInstanceOfType(newAsset)) { throw new System.InvalidOperationException("Assets of type GameObject must always be available after generation."); } // Is there an earlier instance of the asset already generated and persisted? if (oldAsset != null && AssetDatabase.Contains(oldAsset)) { // Is the earlier asset and this asset exactly the same type, and is the old asset currently // persisted as a hidden embedded asset in the asset collection, not as a discrete asset? if (oldAsset.GetType() == newAsset.GetType() && _assetCollection.embeddedAssets.Contains(oldAsset)) { // Update the earlier asset to match the new instance. if (!ReferenceEquals(newAsset, oldAsset)) { AssetUtility.UpdateAssetInPlace(newAsset, oldAsset); } oldAsset.name = assetName; oldAsset.hideFlags |= HideFlags.HideInHierarchy; EditorUtility.SetDirty(oldAsset); // Re-add the old asset to the asset collection just in case it wasn't already there or in the right list for some reason. _assetCollection.AddEmbedded(oldAsset); EditorUtility.SetDirty(_assetCollection); return(oldAsset); } // The earlier asset and the new instance have different types, or the old asset is not embedded in the asset collection. else { // There's no way to maintain references, so just delete the old instance. _assetCollection.Remove(oldAsset); AssetUtility.DeleteAsset(oldAsset); // Persist the new asset. newAsset.name = assetName; newAsset.hideFlags |= HideFlags.HideInHierarchy; AssetDatabase.AddObjectToAsset(newAsset, _assetCollection); EditorUtility.SetDirty(newAsset); // Add the new asset to the asset collection. _assetCollection.AddEmbedded(newAsset); EditorUtility.SetDirty(_assetCollection); return(newAsset); } } // There was no earlier persistent instance of the asset, so there is nothing to replace. else { // Persist the new asset. newAsset.name = assetName; newAsset.hideFlags |= HideFlags.HideInHierarchy; AssetDatabase.AddObjectToAsset(newAsset, _assetCollection); EditorUtility.SetDirty(newAsset); // Add the new asset to the asset collection. _assetCollection.AddEmbedded(newAsset); EditorUtility.SetDirty(_assetCollection); return(newAsset); } }
public static List <Material> SharedMaterials() { List <Material> materials = AssetUtility.GetAssetsAtPath <Material>(MATERIAL_SUB_PATH); return(materials); }
// Token: 0x06010AF5 RID: 68341 RVA: 0x00454E98 File Offset: 0x00453098 private void InitValuesInHeroItem(int lvText = 1, int starNum = 1, int curNum = 0, int totalNum = 1, int state = 0) { if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_InitValuesInHeroItemInt32Int32Int32Int32Int32_hotfix != null) { this.m_InitValuesInHeroItemInt32Int32Int32Int32Int32_hotfix.call(new object[] { this, lvText, starNum, curNum, totalNum, state }); return; } BJLuaObjHelper.IsSkipLuaHotfix = false; if (this.m_hero.HeroInfo != null) { ConfigDataCharImageInfo charImageInfo = this.m_hero.HeroInfo.GetCharImageInfo(this.m_hero.StarLevel); if (charImageInfo != null) { this.m_heroIconImg.sprite = AssetUtility.Instance.GetSprite(AssetUtility.MakeSpriteAssetName(charImageInfo.CardHeadImage, "_1")); } IConfigDataLoader configDataLoader = GameManager.Instance.ConfigDataLoader as IConfigDataLoader; ConfigDataArmyInfo configDataArmyInfo = configDataLoader.GetConfigDataArmyInfo(this.m_hero.GetActiveJob().JobConnectionInfo.m_jobInfo.Army_ID); this.m_heroTypeImg.sprite = AssetUtility.Instance.GetSprite(configDataArmyInfo.Icon); } ProjectLPlayerContext projectLPlayerContext = GameManager.Instance.PlayerContext as ProjectLPlayerContext; if (state != 0) { if (state == 1) { if (curNum >= totalNum) { this.m_uiStateCtrl.SetToUIState("NotGetAndGlowing", false, true); this.m_curHeroItemState = HeroItemUIController.HeroItemState.NotGetAndGlowing; } else { this.m_uiStateCtrl.SetToUIState("NotGet", false, true); this.m_curHeroItemState = HeroItemUIController.HeroItemState.NotGet; } this.m_heroCollectProgressText.text = curNum + "/" + totalNum; this.m_heroCollectProgressImg.fillAmount = (float)curNum / (float)totalNum; this.m_heroIconImg.color = Color.gray; this.m_redMark.gameObject.SetActive(curNum >= totalNum); } } else { this.m_uiStateCtrl.SetToUIState("Get", false, true); this.m_curHeroItemState = HeroItemUIController.HeroItemState.Get; this.m_heroLvText.text = lvText.ToString(); UIUtility.SetGameObjectChildrenActiveCount(this.m_heroStar, starNum); this.m_frameImg.sprite = AssetUtility.Instance.GetSprite(UIUtility.GetHeroItemFrameNameByRank(this.m_hero.HeroInfo.GetRank(this.m_hero.StarLevel))); this.m_ssrFrameEffect.SetActive(this.m_hero.HeroInfo.GetRank(this.m_hero.StarLevel) >= 4); if (projectLPlayerContext.IsHeroShowRedMark(this.m_hero.HeroId, this.m_hero.GetActiveJob().JobConnectionInfo.ID)) { this.m_redMark.gameObject.SetActive(true); } else { this.m_redMark.gameObject.SetActive(false); } } }
public async Task <byte[]> GetThumbnail( string assetId, int width = 80, int height = 60, ulong index = 0, ushort sliceId = 1) { var utility = new AssetUtility(GetStores()); var key = string.Format(cacheKeyFormat, assetId, ServerUri, width, height, index).GetHashCode(); var byteArray = _imagesCache.Get <byte[]>(key); if (byteArray != null) { using (var stream = new MemoryStream(byteArray)) return(stream.ToArray()); } var trackId = _assetTrackCache.Get <string>(assetId); if (trackId == null) { var assetVm = await utility.GetAsync(new AssetRequest(assetId) { ServerUri = ServerUri }); var track = assetVm.HyperAsset.VideoTracks.FirstOrDefault(); trackId = track?.Id.ToString() ?? ""; if (!string.IsNullOrWhiteSpace(trackId)) { _assetTrackCache.Set(assetId, trackId, TimeSpan.FromSeconds(CacheInterval)); } } byte[] thumbnail = null; if (!string.IsNullOrWhiteSpace(trackId)) { thumbnail = await utility.GetSliceImageDataAsync(new AssetSliceRequest() { AssetId = assetId, ServerUri = ServerUri, Width = width, Height = height, FragmentId = index, TrackId = trackId, SliceIds = new List <ushort>() { sliceId } }); } if (thumbnail == null || thumbnail.Length == 0) { return(GetEmptyThumbnail(width, height)); } var data = ImageUtility.ResizeImage(thumbnail, width, height); _imagesCache.Set(key, data, TimeSpan.FromSeconds(CacheInterval)); return(data); }
//---------------------------------------------------------------------------------------------------------------------- public override void OnInspectorGUI() { //View resolution Vector2 res = ViewEditorUtility.GetMainGameViewSize(); EditorGUILayout.LabelField("Resolution (Modify GameView size to change)"); ++EditorGUI.indentLevel; EditorGUILayout.LabelField("Width", res.x.ToString(CultureInfo.InvariantCulture)); EditorGUILayout.LabelField("Height", res.y.ToString(CultureInfo.InvariantCulture)); --EditorGUI.indentLevel; EditorGUILayout.Space(15f); //Check if the asset is actually inspected if (null != TimelineEditor.selectedClip && TimelineEditor.selectedClip.asset != m_asset) { return; } ValidateAssetFolder(); string prevFolder = m_asset.GetFolder(); string newFolder = EditorGUIDrawerUtility.DrawFolderSelectorGUI("Cache Output Folder", "Select Folder", prevFolder, null, AssetUtility.NormalizeAssetPath ); if (newFolder != prevFolder) { m_asset.SetFolder(AssetUtility.NormalizeAssetPath(newFolder)); GUIUtility.ExitGUI(); } TimelineClipSISData timelineClipSISData = m_asset.GetBoundTimelineClipSISData(); if (null == timelineClipSISData) { return; } GUILayout.Space(15); //Capture Selected Frames using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { DrawCaptureSelectedFramesGUI(TimelineEditor.selectedClip, timelineClipSISData); DrawLockFramesGUI(TimelineEditor.selectedClip, timelineClipSISData); } GUILayout.Space(15); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { EditorGUILayout.LabelField("Background Colors"); ++EditorGUI.indentLevel; RenderCachePlayableAssetEditorConfig editorConfig = m_asset.GetEditorConfig(); Color updateBGColor = editorConfig.GetUpdateBGColor(); Color timelineBgColor = m_asset.GetTimelineBGColor(); editorConfig.SetUpdateBGColor(EditorGUILayout.ColorField("In Game Window (Update)", updateBGColor)); m_asset.SetTimelineBGColor(EditorGUILayout.ColorField("In Timeline Window", timelineBgColor)); --EditorGUI.indentLevel; GUILayout.Space(5); } GUILayout.Space(15); DrawUpdateRenderCacheGUI(); }
void OnGUI() { so = so ?? new SerializedObject(this); EditorGUIUtility.wideMode = true; EditorGUILayout.LabelField("Spine SpriteAtlas Import", EditorStyles.boldLabel); using (new SpineInspectorUtility.BoxScope()) { EditorGUI.BeginChangeCheck(); var spriteAtlasAssetProperty = so.FindProperty("spriteAtlasAsset"); EditorGUILayout.PropertyField(spriteAtlasAssetProperty, new GUIContent("SpriteAtlas", EditorGUIUtility.IconContent("SpriteAtlas Icon").image)); if (EditorGUI.EndChangeCheck()) { so.ApplyModifiedProperties(); if (spriteAtlasAsset != null) { if (AssetUtility.SpriteAtlasSettingsNeedAdjustment(spriteAtlasAsset)) { AssetUtility.AdjustSpriteAtlasSettings(spriteAtlasAsset); } GenerateAssetsFromSpriteAtlas(spriteAtlasAsset); } } var spineSpriteAtlasAssetProperty = so.FindProperty("spineSpriteAtlasAsset"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(spineSpriteAtlasAssetProperty, new GUIContent("SpineSpriteAtlasAsset", EditorGUIUtility.IconContent("ScriptableObject Icon").image)); if (spineSpriteAtlasAssetProperty.objectReferenceValue == null) { spineSpriteAtlasAssetProperty.objectReferenceValue = spineSpriteAtlasAsset = FindSpineSpriteAtlasAsset(spriteAtlasAsset); } if (EditorGUI.EndChangeCheck()) { so.ApplyModifiedProperties(); } EditorGUILayout.Space(); using (new EditorGUI.DisabledScope(spineSpriteAtlasAsset == null)) { if (SpineInspectorUtility.LargeCenteredButton(new GUIContent("Load regions by entering Play mode"))) { GenerateAssetsFromSpriteAtlas(spriteAtlasAsset); SpineSpriteAtlasAsset.UpdateByStartingEditorPlayMode(); } } using (new SpineInspectorUtility.BoxScope()) { if (spriteAtlasAsset == null) { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Please assign SpriteAtlas file.", Icons.warning), GUILayout.Height(46)); } else if (spineSpriteAtlasAsset == null || spineSpriteAtlasAsset.RegionsNeedLoading) { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Please hit 'Load regions ..' to load\nregion info. Play mode is started\nand stopped automatically.", Icons.warning), GUILayout.Height(54)); } else { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("SpriteAtlas imported\nsuccessfully.", Icons.spine), GUILayout.Height(46)); } } } bool isAtlasComplete = (spineSpriteAtlasAsset != null && !spineSpriteAtlasAsset.RegionsNeedLoading); bool canImportSkeleton = (spriteAtlasAsset != null && skeletonDataFile != null); using (new SpineInspectorUtility.BoxScope()) { using (new EditorGUI.DisabledScope(!isAtlasComplete)) { var skeletonDataAssetProperty = so.FindProperty("skeletonDataFile"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(skeletonDataAssetProperty, SpineInspectorUtility.TempContent("Skeleton json/skel file", Icons.spine)); if (EditorGUI.EndChangeCheck()) { so.ApplyModifiedProperties(); } EditorGUILayout.Space(); } using (new EditorGUI.DisabledScope(!canImportSkeleton)) { if (SpineInspectorUtility.LargeCenteredButton(new GUIContent("Import Skeleton"))) { //AssetUtility.IngestSpriteAtlas(spriteAtlasAsset, null); string skeletonPath = AssetDatabase.GetAssetPath(skeletonDataFile); string[] skeletons = new string[] { skeletonPath }; AssetUtility.ImportSpineContent(skeletons, null); } } } }
public override void OnInspectorGUI() { animationNameProperty = animationNameProperty ?? serializedObject.FindProperty("animationName"); string animationName = animationNameProperty.stringValue; Animation animation = null; if (ThisSkeletonDataAsset != null) { var skeletonData = ThisSkeletonDataAsset.GetSkeletonData(true); if (skeletonData != null) { animation = skeletonData.FindAnimation(animationName); } } bool animationNotFound = (animation == null); if (changeNextFrame) { changeNextFrame = false; if (ThisSkeletonDataAsset != lastSkeletonDataAsset || ThisSkeletonDataAsset.GetSkeletonData(true) != lastSkeletonData) { preview.Clear(); preview.Initialize(Repaint, ThisSkeletonDataAsset, LastSkinName); if (animationNotFound) { animationNameProperty.stringValue = ""; preview.ClearAnimationSetupPose(); } } preview.ClearAnimationSetupPose(); if (!string.IsNullOrEmpty(animationNameProperty.stringValue)) { preview.PlayPauseAnimation(animationNameProperty.stringValue, true); } } lastSkeletonDataAsset = ThisSkeletonDataAsset; lastSkeletonData = ThisSkeletonDataAsset.GetSkeletonData(true); //EditorGUILayout.HelpBox(AnimationReferenceAssetEditor.InspectorHelpText, MessageType.Info, true); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); DrawDefaultInspector(); if (EditorGUI.EndChangeCheck()) { changeNextFrame = true; } // Draw extra info below default inspector. EditorGUILayout.Space(); if (ThisSkeletonDataAsset == null) { EditorGUILayout.HelpBox("SkeletonDataAsset is missing.", MessageType.Error); } else if (string.IsNullOrEmpty(animationName)) { EditorGUILayout.HelpBox("No animation selected.", MessageType.Warning); } else if (animationNotFound) { EditorGUILayout.HelpBox(string.Format("Animation named {0} was not found for this Skeleton.", animationNameProperty.stringValue), MessageType.Warning); } else { using (new SpineInspectorUtility.BoxScope()) { if (!string.Equals(AssetUtility.GetPathSafeName(animationName), ThisAnimationReferenceAsset.name, System.StringComparison.OrdinalIgnoreCase)) { EditorGUILayout.HelpBox("Animation name value does not match this asset's name. Inspectors using this asset may be misleading.", MessageType.None); } EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(animationName, SpineEditorUtilities.Icons.animation)); if (animation != null) { EditorGUILayout.LabelField(string.Format("Timelines: {0}", animation.Timelines.Count)); EditorGUILayout.LabelField(string.Format("Duration: {0} sec", animation.Duration)); } } } }
private void SetDefaultValue(FormView frmView) { if (frmView.CurrentMode == FormViewMode.Edit || frmView.CurrentMode == FormViewMode.Insert) { AssetUtility Util = new AssetUtility(); string currDate = DateTime.Now.ToString(); TextBox UpdatedByTxb = frmView.FindControl("UpdatedByTxb") as TextBox; TextBox UpdatedAtTxb = frmView.FindControl("UpdatedAtTxb") as TextBox; TextBox TimeOfRecordingADocumentTxb = frmView.FindControl("TimeOfRecordingADocumentTxb") as TextBox; UpdatedByTxb.Text = Util.GetUserFullLogin().ToString(); UpdatedAtTxb.Text = currDate; if (frmView.CurrentMode == FormViewMode.Insert) { TextBox CreatedByTxb = frmView.FindControl("CreatedByTxb") as TextBox; TextBox CreatedAtTxb = frmView.FindControl("CreatedAtTxb") as TextBox; CreatedByTxb.Text = Util.GetUserFullLogin().ToString(); CreatedAtTxb.Text = currDate; TimeOfRecordingADocumentTxb.Text = currDate; } } }
void OnEnable() { settingProfileAsset = new SerializedObject(SettingsManager.LoadMainSettings()); selectableLayerField = AssetUtility.LoadPropertyAsInt("layerCaster", settingProfileAsset); selectableLayerMask = AssetUtility.LoadPropertyAsInt("layerMask", settingProfileAsset); }
public static IEnumerable <ObjectMacro> Types() { return(AssetUtility.FindAllAssetsOfType <ObjectMacro>().ToArray()); }
private Object PersistAsset(Object oldAsset, Object newAsset, string assetName, string assetPath) { if (typeof(GameObject).IsInstanceOfType(newAsset)) { if (oldAsset != null) { return(PersistAsset((GameObject)oldAsset, (GameObject)newAsset, assetName, assetPath)); } else { return(PersistAsset(null, (GameObject)newAsset, assetName, assetPath)); } } var fullAssetPath = GetAssetPath(assetName, assetPath, "asset"); AssetUtility.CreatePathFolders(fullAssetPath); // Is there an earlier instance of the asset already generated and persisted? if (oldAsset != null && AssetDatabase.Contains(oldAsset)) { // Is the earlier asset and this asset exactly the same type, and is the old asset currently // persisted as a discrete asset, not as a hidden embedded asset in the asset collection? if (oldAsset.GetType() == newAsset.GetType() && _assetCollection.discreteAssets.Contains(oldAsset)) { // Check the earlier asset's path, to see if it's already in the right place. var currentPath = AssetUtility.GetProjectRelativeAssetPath(oldAsset); if (currentPath != fullAssetPath) { // If there's any asset that is a part of this collection, then rename it so that the old asset can be moved. FindAndMoveAnyConflictingObject(fullAssetPath, oldAsset); // Move the old asset to the new location. var errorMessage = AssetDatabase.MoveAsset(currentPath, fullAssetPath); if (!string.IsNullOrEmpty(errorMessage)) { throw new System.InvalidOperationException(errorMessage); } } // Update the earlier asset to match the new instance. if (!ReferenceEquals(newAsset, oldAsset)) { AssetUtility.UpdateAssetInPlace(newAsset, oldAsset); } oldAsset.name = assetName; EditorUtility.SetDirty(oldAsset); // Re-add the old asset to the asset collection just in case it wasn't already there or in the right list for some reason. _assetCollection.AddDiscrete(oldAsset); EditorUtility.SetDirty(_assetCollection); return(oldAsset); } // The earlier asset and the new instance have different types, or the old asset is embedded in the asset collection. else { // There's no way to maintain references, so just delete the old instance. _assetCollection.Remove(oldAsset); DestroyImmediate(oldAsset, true); // If there's any asset that is a part of this collection, then rename it so that the new asset can be persisted. FindAndMoveAnyConflictingObject(fullAssetPath); // Persist the new asset. newAsset.name = assetName; AssetDatabase.CreateAsset(newAsset, fullAssetPath); EditorUtility.SetDirty(newAsset); // Add the new asset to the asset collection. _assetCollection.AddDiscrete(newAsset); EditorUtility.SetDirty(_assetCollection); return(newAsset); } } // There was no earlier persistent instance of the asset, so there is nothing to replace. else { // Persist the new asset. newAsset.name = assetName; AssetDatabase.CreateAsset(newAsset, fullAssetPath); EditorUtility.SetDirty(newAsset); // Add the new asset to the asset collection. _assetCollection.AddDiscrete(newAsset); EditorUtility.SetDirty(_assetCollection); return(newAsset); } }