private IEnumerator OnTargetAssetChanged( Object asset ) { string assetPath = AssetDatabase.GetAssetPath( asset ); EditorSupport.ESUtility.CurRootPath = assetPath.Substring( 0, assetPath.IndexOf( "/res/", StringComparison.Ordinal ) + 1 );//+1是为了把"/"包含进去 if( asset is ScriptableObject ){ Type editorType = Utility.GetCustomEditor( asset.GetType() ); BaseEditor_ = Editor.CreateEditor( asset, editorType ) as BaseEditor; if( BaseEditor_ ){ RawAsset_ = asset; BaseEditor_.RawAsset = asset; } else{ LastError_ = "不是自定义格式的资源:" + assetPath; } } else{ EditorWww www = EditorWww.Create( assetPath ); while ( !www.Finished ) { yield return null; } var scriptableObj = www.GetAsset() as ScriptableObject; www.Unload(); if ( !scriptableObj ){ LastError_ = "无法识别的资源: " + assetPath; yield break; } Type editorType = Utility.GetCustomEditor( scriptableObj.GetType() ); if ( editorType == null || editorType.BaseType != typeof( BaseEditor ) ) { LastError_ = "没有找到对应的编辑器: " + scriptableObj.GetType(); } else { ScriptableObject tempObj = CreateInstance( scriptableObj.GetType() ); EditorUtility.CopySerialized( scriptableObj, tempObj ); string filePath = Path.ChangeExtension( assetPath, PalmPoineer.Defines.AssetExt.UnityAsset ); AssetDatabase.CreateAsset( tempObj, filePath ); RawAsset_ = tempObj; BaseEditor_ = Editor.CreateEditor( tempObj, editorType ) as BaseEditor; BaseEditor_.RawAsset = tempObj; } } }
private IEnumerator OnTargetAssetChanged(Object asset) { string assetPath = AssetDatabase.GetAssetPath(asset); //Debug.Log("OnTargetAssetChanged(), assetPath : " + assetPath); EditorSupport.ESUtility.CurRootPath = assetPath.Substring(0, assetPath.IndexOf("/res/", StringComparison.Ordinal) + 1);//+1是为了把"/"包含进去 //Debug.Log("OnTargetAssetChanged(), CurRootPath : " + EditorSupport.ESUtility.CurRootPath); if (asset is ScriptableObject) { Type editorType = Utility.GetCustomEditor(asset.GetType()); BaseEditor_ = Editor.CreateEditor(asset, editorType) as BaseEditor; if (BaseEditor_) { ObjFieldShow_ = asset; BaseEditor_.RawAsset = asset; } else { LastError_ = "不是自定义格式的资源:" + assetPath; } } else { yield return null; } }
private void ResetEditor() { LastError_ = string.Empty; BaseEditor_ = null; ObjFieldShow_ = null; ScrollViewPosition_ = Vector2.zero; }
private void ResetEditor() { LastError_ = string.Empty; BaseEditor_ = null; RawAsset_ = null; ScrollViewPosition_ = Vector2.zero; }