DefaultAsset is used for assets that does not have a specific type (yet).
void OnGUI() { EditorGUILayout.LabelField(EditorSettings.LayoutImportWindow_Description); m_LayoutAsset = EditorGUILayout.ObjectField(m_LayoutAsset, typeof(UnityEditor.DefaultAsset), false) as UnityEditor.DefaultAsset; // レイアウトファイル(.wlt)をUnityEditorへ登録 EditorGUI.BeginDisabledGroup(m_LayoutAsset == null); if (GUILayout.Button("Import")) { var filePath = Path.GetFullPath( AssetDatabase.GetAssetPath(m_LayoutAsset) ); var fileName = Path.GetFileName(filePath); var savePath = EditorUtility.SaveFilePanel( "Save Layout File", WindowLayout.LayoutsPreferencesPath, fileName, "wlt"); if (!string.IsNullOrEmpty(savePath)) { var saveFullPath = Path.GetFullPath(savePath); File.Copy(filePath, saveFullPath); Debug.Log("Import: " + saveFullPath); } InternalEditorUtility.ReloadWindowLayoutMenu(); // レイアウトメニュー更新 } EditorGUI.EndDisabledGroup(); }
public void SetDefaultDirectory() { if (!m_directory || string.IsNullOrEmpty(AssetDatabase.GetAssetPath(m_directory))) { m_directory = AssetDatabase.LoadAssetAtPath<DefaultAsset>("Assets"); } }
//---------------------------------------------------------------------------------------------------------------------- private static void InitializeAssetFromDefaultAsset(StreamingImageSequencePlayableAsset playableAsset, UnityEditor.DefaultAsset timelineDefaultAsset) { string path = AssetDatabase.GetAssetPath(timelineDefaultAsset).Replace("\\", "/"); const bool ASK_TO_COPY = false; ImageSequenceImporter.ImportImages(path, playableAsset, ASK_TO_COPY); }
public override void OnInspectorGUI() { DefaultAsset defaultAsset = (DefaultAsset)base.target; if (defaultAsset.message.Length > 0) { EditorGUILayout.HelpBox(defaultAsset.message, (!defaultAsset.isWarning) ? MessageType.Info : MessageType.Warning); } }
public override void OnInspectorGUI() { DefaultAsset target = (DefaultAsset)this.target; if (target.message.Length > 0) { EditorGUILayout.HelpBox(target.message, !target.isWarning ? MessageType.Info : MessageType.Warning); } }
//---------------------------------------------------------------------------------------------------------------------- /// <inheritdoc/> public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom) { StreamingImageSequencePlayableAsset asset = clip.asset as StreamingImageSequencePlayableAsset; if (null == asset) { Debug.LogError("Asset is not a StreamingImageSequencePlayableAsset: " + clip.asset); return; } StreamingImageSequenceTrack sisTrack = track as StreamingImageSequenceTrack; Assert.IsNotNull(sisTrack); //This callback occurs before the clip is assigned to the track, but we need the track for creating curves. clip.parentTrack = track; //If we have a default asset, and clonedFrom is NULL, which means this is created by user interaction, //such as Folder D&D UnityEditor.DefaultAsset timelineDefaultAsset = asset.GetTimelineDefaultAsset(); if (null != timelineDefaultAsset && null == clonedFrom) { InitializeAssetFromDefaultAsset(asset, timelineDefaultAsset); } //If the clip already has curves (because of cloning, etc), then we don't set anything if (null == clip.curves) { int numImages = asset.GetNumImages(); if (numImages > 0) { SISUserSettings userSettings = SISUserSettings.GetInstance(); clip.duration = (double)(numImages) / (userSettings.GetDefaultSISPlayableAssetFPS()); clip.displayName = Path.GetFileName(asset.GetFolder()); } clip.CreateCurves("Curves: " + clip.displayName); } TimelineClipSISData sisData = null; asset.InitTimelineClipCurve(clip); if (null == clonedFrom) { sisData = new TimelineClipSISData(clip); asset.BindTimelineClipSISData(sisData); return; } //Duplicate/Split process StreamingImageSequencePlayableAsset clonedFromAsset = clonedFrom.asset as StreamingImageSequencePlayableAsset; Assert.IsNotNull(clonedFromAsset); TimelineClipSISData otherSISData = clonedFromAsset.GetBoundTimelineClipSISData(); sisData = new TimelineClipSISData(clip, otherSISData); asset.BindTimelineClipSISData(sisData); clip.displayName = clonedFrom.displayName + " (Cloned)"; }
private object GetDefaultAssetPropertyValue(DefaultAsset asset) { if (asset == null) return null; var assetPath = AssetDatabase.GetAssetPath(asset); if (String.IsNullOrEmpty(assetPath)) return null; var assetName = Path.GetFileName(assetPath); var outputPath = Path.Combine(babylonScene.OutputPath, assetName); File.Copy(assetPath, outputPath, true); Dictionary<string, object> assetInfo = new Dictionary<string, object>(); assetInfo.Add("type", asset.GetType().FullName); assetInfo.Add("filename", assetName); return assetInfo; }
/// <summary> /// Gets the ink file from the .ink file reference. /// </summary> /// <returns>The ink file with path.</returns> /// <param name="path">Path.</param> public static InkFile GetInkFileWithFile(DefaultAsset file) { if(InkLibrary.Instance.inkLibrary == null) return null; foreach(InkFile inkFile in InkLibrary.Instance.inkLibrary) { if(inkFile.inkAsset == file) { return inkFile; } } return null; }
public InkFile(DefaultAsset inkFile) { Debug.Assert(inkFile != null); this.inkAsset = inkFile; }
private void GetObjectsInfolder(UnityEditor.DefaultAsset folder) { string path = AssetDatabase.GetAssetPath(folder); GetObjectsInfolder(path); }
//---------------------------------------------------------------------------------------------------------------------- /// <inheritdoc/> public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom) { StreamingImageSequencePlayableAsset asset = clip.asset as StreamingImageSequencePlayableAsset; if (null == asset) { Debug.LogError("Asset is not a StreamingImageSequencePlayableAsset: " + clip.asset); return; } //[Note-sin: 2021-2-25] Track can be null during copy and paste if (null != track) { //This callback occurs before the clip is assigned to the track, but we need the track for creating curves. clip.TryMoveToTrack(track); } //If we have a default asset, and clonedFrom is NULL, which means this is created by user interaction, //such as Folder D&D UnityEditor.DefaultAsset timelineDefaultAsset = asset.GetTimelineDefaultAsset(); if (null != timelineDefaultAsset && null == clonedFrom) { InitializeAssetFromDefaultAsset(asset, timelineDefaultAsset); } //If the clip already has curves (because of cloning, etc), then we don't set anything if (null == clip.curves) { int numImages = asset.GetNumImages(); if (numImages > 0) { SISUserSettings userSettings = SISUserSettings.GetInstance(); clip.duration = (double)(numImages) / (userSettings.GetDefaultSISPlayableAssetFPS()); clip.displayName = Path.GetFileName(asset.GetFolder()); } ExtendedClipEditorUtility.CreateTimelineClipCurve(clip, StreamingImageSequencePlayableAsset.GetTimeCurveBinding()); } if (null == clonedFrom) { asset.BindClipData(new SISClipData(clip)); return; } //Duplicate/Split process StreamingImageSequencePlayableAsset clonedFromAsset = clonedFrom.asset as StreamingImageSequencePlayableAsset; Assert.IsNotNull(clonedFromAsset); SISClipData otherSISData = clonedFromAsset.GetBoundClipData(); if (null == otherSISData) { asset.BindClipData(new SISClipData(clip)); //[Note-sin: 2021-2-25] can be null during copy and paste return; } SISClipData sisData = new SISClipData(clip, otherSISData); asset.BindClipData(sisData); clip.displayName = clonedFrom.displayName + " (Cloned)"; }
void OnGUI() { GUILayout.Label(m_sources.Length > 1 ? "Find Multiple References" : "Find References", EditorStyles.boldLabel); m_directory = EditorGUILayout.ObjectField("Directory : ", m_directory, typeof(DefaultAsset), false, null) as DefaultAsset; var firstObject = m_sources.Any() ? m_sources[0] : null; var newFirstObject = EditorGUILayout.ObjectField("Find : ", firstObject, typeof(Object), false, null); if (newFirstObject != firstObject) { m_sources = new[] {newFirstObject}; } if (m_process != null && !m_process.HasExited) { //Show spinner GUILayout.Label("Searching..."); } else { if (GUILayout.Button("Find")) { StartProcess(); } if (m_references != null) { GUILayout.Label("Found " + m_references.Count + " references", EditorStyles.boldLabel); foreach (var reference in m_references) { GUILayout.BeginHorizontal(); //GUILayout.Label(AssetDatabase.GetCachedIcon(reference)); //if (GUILayout.Button(Path.GetFileNameWithoutExtension(reference))) //, "Label" //{ // Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(reference); //} EditorGUILayout.ObjectField(AssetDatabase.LoadMainAssetAtPath(reference), typeof(Object), false, null); GUILayout.EndHorizontal(); } if (m_references.Any()) { m_replacement = EditorGUILayout.ObjectField("Replace : ", m_replacement, typeof(Object), false, null); if (GUILayout.Button("Replace")) { var textReplacements = new List<KeyValuePair<string, string>>(m_sources.Length); var replacementAssetPath = AssetDatabase.GetAssetPath(m_replacement); var replacementGUID = AssetDatabase.AssetPathToGUID(replacementAssetPath); var replacementResourcesIndex = replacementAssetPath.IndexOf(ResourcesDir, StringComparison.OrdinalIgnoreCase); foreach (var source in m_sources) { var sourceAssetPath = AssetDatabase.GetAssetPath(source); var sourceGUID = AssetDatabase.AssetPathToGUID(sourceAssetPath); textReplacements.Add(new KeyValuePair<string, string>(sourceGUID, replacementGUID)); var sourceResourcesIndex = sourceAssetPath.IndexOf(ResourcesDir, StringComparison.OrdinalIgnoreCase); if (sourceResourcesIndex >= 0 && replacementResourcesIndex >= 0) { var sourceResourcesPath = Path.ChangeExtension(sourceAssetPath.Substring(sourceResourcesIndex + ResourcesDir.Length), null); var replacementResourcesPath = Path.ChangeExtension(replacementAssetPath.Substring(replacementResourcesIndex + ResourcesDir.Length), null); textReplacements.Add(new KeyValuePair<string, string>(sourceResourcesPath, replacementResourcesPath)); } //var assetImporter = AssetImporter.GetAtPath(sourceAssetPath); //if (assetImporter != null && !string.IsNullOrEmpty(assetImporter.assetBundleName)) //{ // var assetbundlepath = assetPath.Remove(0, 7); // searchArgment += " OR " + assetbundlepath; //} } foreach (var reference in m_references) { var text = File.ReadAllText(reference); foreach (var textReplacement in textReplacements) { text = Regex.Replace(text, string.Format(@"\b{0}\b", textReplacement.Key), textReplacement.Value); } File.WriteAllText(reference, text); } } } } } }