本文整理汇总了C#中UnityEditor.SerializedObject.GetIterator方法的典型用法代码示例。如果您正苦于以下问题:C# SerializedObject.GetIterator方法的具体用法?C# SerializedObject.GetIterator怎么用?C# SerializedObject.GetIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEditor.SerializedObject
的用法示例。
在下文中一共展示了SerializedObject.GetIterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindMissingReferences
private static void FindMissingReferences(string context, GameObject[] objects)
{
foreach (var go in objects)
{
var components = go.GetComponents<Component>();
foreach (var c in components)
{
if (!c)
{
Debug.LogError("Missing Component in GO: " + FullPath(go), go);
continue;
}
SerializedObject so = new SerializedObject(c);
var sp = so.GetIterator();
while (sp.NextVisible(true))
{
if (sp.propertyType == SerializedPropertyType.ObjectReference)
{
if (sp.objectReferenceValue == null
&& sp.objectReferenceInstanceIDValue != 0)
{
ShowError(context, go, c.GetType().Name, ObjectNames.NicifyVariableName(sp.name));
}
}
}
}
}
}
示例2: App
void App(GameObject src, GameObject dst)
{
dst.transform.localPosition=src.transform.localPosition;
Component comp=src.GetComponent<MeshFilter>();
Component dst_comp = dst.AddComponent(comp.GetType());
SerializedObject src_ser_obj = new SerializedObject(comp);
SerializedObject dst_ser_obj = new SerializedObject(dst_comp);
src_ser_obj.Update();
dst_ser_obj.Update();
SerializedProperty ser_prop = src_ser_obj.GetIterator();
bool enterChildren = true;
while (ser_prop.Next(enterChildren)) {
enterChildren = true;
string path = ser_prop.propertyPath;
bool skip = false;
foreach (string blacklisted_path in propertyBlacklist) {
if (path.EndsWith(blacklisted_path)) {
skip = true;
break;
}
}
if (skip) {
enterChildren = false;
continue;
}
//Debug.Log(path);
SerializedProperty dst_ser_prop = dst_ser_obj.FindProperty(path);
AssignSerializedProperty(ser_prop, dst_ser_prop);
}
dst_ser_obj.ApplyModifiedProperties();
}
示例3: LogPropertis
public static string[] LogPropertis(SerializedObject serObj, string startPropertyName, bool enterChildren)
{
if (serObj == null)
return null;
string log = "";
SerializedProperty sp;
bool bFirst = true;
if (startPropertyName != null && startPropertyName != "")
sp = serObj.FindProperty(startPropertyName);
else sp = serObj.GetIterator();
while (true)
{
object value = GetPropertyValue(sp);
log += string.Format("{0}{3}{4}{5} {1,-30} {2, 20} {6}\r\n", sp.depth, NgConvert.GetTabSpace(sp.depth+1) + sp.name, (value == null ? "null" : value.ToString()), sp.editable, sp.isExpanded, sp.isArray, sp.propertyPath);
if (sp.Next(bFirst) == false)
break;
bFirst = enterChildren;
}
{
log = "=====================================================================\r\n" + log;
log = log + "=====================================================================\r\n";
Debug.Log(log);
}
return null;
}
示例4: createLayer
static void createLayer(){
SerializedObject SerializedObjectTagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
SerializedProperty it = SerializedObjectTagManager.GetIterator();
bool showChildren = true;
#if UNITY_5
while(it.NextVisible (showChildren)){
Debug.Log(it.displayName);
if(it.displayName == "Element 8"){
// it.stringValue = "ShadowLayer";
}
}
#else
while(it.NextVisible (showChildren)){
if(it.name == "User Layer 8"){
// it.stringValue = "ShadowLayer";
}
}
//mmmm
#endif
SerializedObjectTagManager.ApplyModifiedProperties();
}
示例5: SearchMissing
/// <summary>
/// 指定アセットにMissingのプロパティがあれば、それをmissingListに追加する
/// </summary>
/// <param name="path">Path.</param>
private static void SearchMissing(string path)
{
// 指定パスのアセットを全て取得
IEnumerable<UnityEngine.Object> assets = AssetDatabase.LoadAllAssetsAtPath (path);
// 各アセットについて、Missingのプロパティがあるかチェック
foreach (UnityEngine.Object obj in assets) {
if (obj == null) {
continue;
}
if (obj.name == "Deprecated EditorExtensionImpl") {
continue;
}
// SerializedObjectを通してアセットのプロパティを取得する
SerializedObject sobj = new SerializedObject (obj);
SerializedProperty property = sobj.GetIterator ();
while (property.Next (true)) {
// プロパティの種類がオブジェクト(アセット)への参照で、
// その参照がnullなのにもかかわらず、参照先インスタンスIDが0でないものはMissing状態!
if (property.propertyType == SerializedPropertyType.ObjectReference &&
property.objectReferenceValue == null &&
property.objectReferenceInstanceIDValue != 0) {
// Missing状態のプロパティリストに追加する
missingList.Add (new AssetParameterData () {
obj = obj,
path = path,
property = property
});
}
}
}
}
示例6: DrawInspector
public static void DrawInspector(Editor wcEditor, System.Type baseType, List<string> ignoreClasses = null) {
var so = new SerializedObject(wcEditor.targets);
var target = wcEditor.target;
so.Update();
var baseTypes = new List<System.Type>();
var baseTargetType = target.GetType();
baseTypes.Add(baseTargetType);
while (baseType != baseTargetType) {
baseTargetType = baseTargetType.BaseType;
baseTypes.Add(baseTargetType);
}
baseTypes.Reverse();
SerializedProperty prop = so.GetIterator();
var result = prop.NextVisible(true);
EditorGUILayout.PropertyField(prop, false);
if (result == true) {
var currentType = EditorUtilitiesEx.FindTypeByProperty(baseTypes, prop);
EditorGUILayout.BeginVertical();
{
while (prop.NextVisible(false) == true) {
var cType = EditorUtilitiesEx.FindTypeByProperty(baseTypes, prop);
if (cType != currentType) {
currentType = cType;
var name = cType.Name;
if (ignoreClasses != null && ignoreClasses.Contains(name) == true) continue;
EditorUtilitiesEx.DrawSplitter(name);
}
EditorGUILayout.PropertyField(prop, true);
}
prop.Reset();
}
EditorGUILayout.EndVertical();
}
so.ApplyModifiedProperties();
}
示例7: GetSerializedProperties
internal static SerializedProperty[] GetSerializedProperties(this Object go) {
var so = new SerializedObject(go);
so.Update();
var result = new List<SerializedProperty>();
var iterator = so.GetIterator();
while (iterator.NextVisible(true)) result.Add(iterator.Copy());
return result.ToArray();
}
示例8: GetProperties
private IEnumerable<SerializedProperty> GetProperties(SerializedObject obj)
{
var iterator = obj.GetIterator();
var enterChildren = true;
while (iterator.NextVisible(enterChildren))
{
enterChildren = false;
yield return iterator;
}
}
示例9: DebugLogAllPropertiesForSerializedProperty
/// <summary>
/// Debugs the log all properties for serialized property.
/// </summary>
/// <param name='aSerializedObject'>
/// A serializedproperty.
/// </param>
public static void DebugLogAllPropertiesForSerializedProperty(SerializedObject aSerializedObject)
{
Debug.Log ("EditorWindowUtility.DebugLogAllPropertiesForSerializedProperty()");
var property = aSerializedObject.GetIterator();
var first = true;
while(property.NextVisible(first))
{
first = false;
Debug.Log(" " + property.name + " = " + property);
}
}
示例10: copySerialized
public static void copySerialized(SerializedObject source, SerializedObject dest)
{
SerializedProperty serializedPropertyCurrent;
serializedPropertyCurrent = source.GetIterator ();
while (serializedPropertyCurrent.Next(true)) {
dest.CopyFromSerializedProperty (serializedPropertyCurrent);
}
dest.ApplyModifiedProperties ();
}
示例11: CopyProperties
private void CopyProperties(SerializedObject source, Object dest, params SerializedPropertyType[] excludeTypes)
{
var newSerializedObject = new SerializedObject(dest);
var prop = source.GetIterator();
while (prop.NextVisible(true))
{
if (!excludeTypes.Contains(prop.propertyType))
{
newSerializedObject.CopyFromSerializedProperty(prop);
}
}
newSerializedObject.ApplyModifiedProperties();
}
示例12: DrawWindowGUI
public void DrawWindowGUI(int i)
{
EditorGUI.BeginChangeCheck();
SerializedObject serializedObject = new SerializedObject(this);
serializedObject.Update();
SerializedProperty iterator = serializedObject.GetIterator();
for (bool flag = true; iterator.NextVisible(flag); flag = false)
{
EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]);
}
serializedObject.ApplyModifiedProperties();
EditorGUI.EndChangeCheck();
GUI.DragWindow(new Rect(0, 0, 10000, 20));
}
示例13: OnGUI
void OnGUI()
{
GUI.Label(new Rect( 10, 10, 50, 25 ), "Ratio");
scaleTextValue = GUI.TextField(new Rect( 50, 10, 50, 25 ), scaleTextValue);
float scale = 1.0f;
float.TryParse(scaleTextValue, out scale);
if( GUI.Button(new Rect(10, 40, 70, 30), "Scale PS") )
{
foreach( Object obj in Selection.objects )
{
GameObject gameObj = obj as GameObject;
if( gameObj != null )
{
ScalePS(gameObj, scale);
}
}
}
if( GUI.Button(new Rect(80, 40, 70, 30), "Serz log") )
{
foreach( Object obj in Selection.objects )
{
GameObject gameObj = obj as GameObject;
if( gameObj.particleSystem != null )
{
SerializedObject so = new SerializedObject(gameObj.particleSystem);
SerializedProperty it = so.GetIterator();
while (it.Next(true))
Debug.Log (it.propertyPath);
break;
}
LineRenderer lineRenderer = gameObj.GetComponent<LineRenderer>();
if( lineRenderer != null )
{
SerializedObject so = new SerializedObject(lineRenderer);
SerializedProperty it = so.GetIterator();
while (it.Next(true))
Debug.Log (it.propertyPath);
break;
}
}
}
}
示例14: DrawDefaultInspectorExcept
public static bool DrawDefaultInspectorExcept(SerializedObject serializedObject, params string[] propsNotToDraw)
{
if (serializedObject == null) throw new System.ArgumentNullException("serializedObject");
EditorGUI.BeginChangeCheck();
var iterator = serializedObject.GetIterator();
for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
{
if (propsNotToDraw == null || !propsNotToDraw.Contains(iterator.name))
{
//EditorGUILayout.PropertyField(iterator, true);
SPEditorGUILayout.PropertyField(iterator, true);
}
}
return EditorGUI.EndChangeCheck();
}
示例15: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
drawPrefixLabel = false;
totalHeight = 0;
Begin(position, property, label);
position.height = EditorGUI.GetPropertyHeight(property, label, true);
EditorGUI.PropertyField(position, property);
totalHeight += position.height;
position.y += position.height;
if (property.objectReferenceValue != null) {
serialized = new SerializedObject(property.objectReferenceValue);
iterator = serialized.GetIterator();
iterator.NextVisible(true);
EditorGUI.indentLevel += 1;
int currentIndent = EditorGUI.indentLevel;
while (true) {
position.height = EditorGUI.GetPropertyHeight(iterator, iterator.displayName.ToGUIContent(), false);
totalHeight += position.height;
EditorGUI.indentLevel = currentIndent + iterator.depth;
EditorGUI.PropertyField(position, iterator);
position.y += position.height;
if (!iterator.NextVisible(iterator.isExpanded)) {
break;
}
}
EditorGUI.indentLevel = currentIndent;
EditorGUI.indentLevel -= 1;
serialized.ApplyModifiedProperties();
}
End();
}