选中操作
- //拿到编辑器当前选中的物体
- Selection.activeGameObject;
贴图相关
- //根据路径获取图片导入器,并设置参数
- TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
- TextureImporterPlatformSettings platformSettings = textureImporter.GetDefaultPlatformTextureSettings();
- platformSettings.crunchedCompression = true;
- platformSettings.compressionQuality = 100;
- textureImporter.SetPlatformTextureSettings(platformSettings);
- AssetDatabase.ImportAsset(path)
预设相关
- //PrefabUtility是操作预设资源的API
-
- //保存预设到指定位置
- PrefabUtility.SavePrefabAsset(path);
- PrefabUtility.SaveAsPrefabAsset();
-
- //Hierarchy里的物体替换预设
- PrefabUtility.ReplacePrefab(obj, go, ReplacePrefabOptions.ReplaceNameBased);
-
-
- //修改预设后设置脏数据
- EditorUtility.SetDirty();
- //这种是刷新指定物体
- EditorUtility.SetDirty(obj);
-
- //刷新编辑器
- AssetDatabase.Refresh();