正所谓:人靠衣装,佛靠金装。学会VR与游戏开发,成就大神人生。
1-1本课程目标 1-2他可以做什么
2-1属性 2-2方法
3-1属性 3-2方法
获取材质球中的属性
序列化对象类
targetObject / targetObjects:返回一个或一组Object;
方法
根据名称查找对象中的序列化属性;如果不知道属性路径可以通过在属性面板上的相应变量上使用shift+右键可log路径名;(侧重于查找指定属性)
public SerializedProperty FindProperty(string propertyPath);
获取第一个序列化属性,然后可以通过SerializedProperty的Next()方法遍历对象中的序列化属性;(侧重于遍历功能)
public SerializedProperty GetIterator();
将对属性的修改应用到该序列化对象上;
public bool ApplyModifiedProperties();
public bool ApplyModifiedPropertiesWithoutUndo()
拷贝属性值;注意两者方法的区别,第二个如果进行拷贝操作则返回true;
public void CopyFromSerializedProperty(SerializedProperty prop);
public bool CopyFromSerializedPropertyIfDifferent(SerializedProperty prop);
Shift+鼠标右键即可显示序列化路径
boolValue
floatValue
doubleValue
intValue
vector3Value
rectValue:为属性指定值;
name: 获取属性名
propertyPath:获取属性路径
方法
方法都比较简单,测试一下即可
利用记事本打开材质球属性如下
Material mat = AssetDatabase.LoadAssetAtPath(path, typeof(Material)) as Material;
SerializedObject so = new SerializedObject(mat);
SerializedProperty m_SavedProperties = so.FindProperty("m_SavedProperties");
SerializedProperty property = saveProperty.FindPropertyRelative("m_Scale");
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有