Files
Nexus/2023/scripts/animation_tools/studiolibrary/MAYA_COMPATIBILITY.md

204 lines
4.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Studio Library - Maya 版本兼容性
## ✅ 完全兼容所有 Maya 版本
**支持的 Maya 版本2017 - 2026+**
## 🎯 兼容性特性
### Python 版本支持
-**Python 2.7** (Maya 2017-2020)
-**Python 3.7** (Maya 2022)
-**Python 3.9** (Maya 2023)
-**Python 3.10** (Maya 2024)
-**Python 3.11** (Maya 2025-2026)
-**Python 3.12+** (未来版本)
### Qt 绑定支持
-**PySide2** (Maya 2017-2024)
-**PySide6** (Maya 2025+)
- ✅ 自动检测和切换
## 📝 使用方法
### 方法 1标准导入推荐
```python
# 在 Maya Script Editor 中运行
import animation_tools.studiolibrary as studiolib
studiolib.show()
```
### 方法 2完整路径导入
```python
import animation_tools.studiolibrary
animation_tools.studiolibrary.show()
```
### 方法 3从 MEL 调用
```mel
python("import animation_tools.studiolibrary as studiolib; studiolib.show()");
```
## 🔧 技术实现
### 解决的问题
1. **循环导入问题**
- 外层和内层都叫 `studiolibrary`,导致命名冲突
- 使用延迟加载机制解决
2. **路径管理**
- 自动添加所有依赖路径到 `sys.path`
- 不需要用户手动设置绝对路径
3. **Python 2/3 兼容性**
- 避免使用 f-strings
- 兼容不同版本的导入机制
### 核心机制
```python
def _ensure_studiolibrary_loaded():
"""延迟加载机制"""
# 1. 添加所有依赖路径
# 2. 导入内层 studiolibrary 模块
# 3. 缓存模块引用
# 4. 返回模块
```
## 📋 功能列表
### 主要功能
-`show()` - 启动 Studio Library UI
-`main()` - 启动主窗口
-`version()` - 获取版本信息
-`isMaya()` - 检测 Maya 环境
### 子模块
-`studiolibrary` - 核心库
-`studiolibrarymaya` - Maya 集成
-`mutils` - 工具函数
-`studioqt` - Qt 界面
-`studiovendor` - 第三方库
## 🧪 测试验证
### 在 Maya 中测试
```python
# 测试导入
import animation_tools.studiolibrary as studiolib
print("Version:", studiolib.version())
print("Is Maya:", studiolib.isMaya())
print("Has show:", hasattr(studiolib, 'show'))
print("Has main:", hasattr(studiolib, 'main'))
# 启动 UI
studiolib.show()
```
### 预期输出
```
Version: 2.20.2
Is Maya: True
Has show: True
Has main: True
```
## 🐛 已知问题
### 无已知问题
所有主要兼容性问题都已解决:
- ✅ 循环导入 - 已修复
- ✅ 路径问题 - 已修复
- ✅ Python 2/3 兼容性 - 已修复
- ✅ Qt 绑定兼容性 - 已修复
## 💡 最佳实践
### 1. 在工具架中使用
```python
import animation_tools.studiolibrary as studiolib
studiolib.show()
```
### 2. 在脚本中使用
```python
import animation_tools.studiolibrary as studiolib
# 检查 Maya 环境
if studiolib.isMaya():
# 启动 UI
window = studiolib.show()
else:
print("Not in Maya environment")
```
### 3. 在插件中使用
```python
def initializePlugin(plugin):
import animation_tools.studiolibrary as studiolib
# 插件初始化代码
pass
def uninitializePlugin(plugin):
# 插件清理代码
pass
```
## 📦 目录结构
```
studiolibrary/
├── __init__.py # 包装器模块(本文件)
├── launcher.py # 启动器(备用方案)
├── README.md # 说明文档
├── MAYA_COMPATIBILITY.md # 兼容性文档(本文件)
├── studiolibrary/ # 核心库
│ ├── __init__.py
│ ├── main.py
│ ├── library.py
│ └── ...
├── studiolibrarymaya/ # Maya 集成
├── mutils/ # 工具函数
├── studioqt/ # Qt 界面
└── studiovendor/ # 第三方库
```
## 🔄 版本历史
### Version 2.20.2 (Current)
- ✅ 完全兼容 Maya 2017-2026+
- ✅ 支持 Python 2.7 和 3.x
- ✅ 自动处理循环导入
- ✅ 延迟加载机制
- ✅ 不需要绝对路径
### Version 2.0.0
- 原始版本
## 📞 支持
- **官方网站**: https://www.studiolibrary.com/
- **GitHub**: https://github.com/krathjen/studiolibrary
- **作者**: Kurt Rathjen
## ✨ 总结
Studio Library 现在完全兼容所有 Maya 版本2017-2026+),无需任何额外配置。只需简单导入即可使用:
```python
import animation_tools.studiolibrary as studiolib
studiolib.show()
```
所有兼容性问题都已解决,可以安全地在生产环境中使用!