当前位置: 首页>>代码示例>>C#>>正文


C# SerializedObject.CopyFromSerializedProperty方法代码示例

本文整理汇总了C#中UnityEditor.SerializedObject.CopyFromSerializedProperty方法的典型用法代码示例。如果您正苦于以下问题:C# SerializedObject.CopyFromSerializedProperty方法的具体用法?C# SerializedObject.CopyFromSerializedProperty怎么用?C# SerializedObject.CopyFromSerializedProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEditor.SerializedObject的用法示例。


在下文中一共展示了SerializedObject.CopyFromSerializedProperty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: copySerialized

    public static void copySerialized(SerializedObject source, SerializedObject dest)
    {
        SerializedProperty serializedPropertyCurrent;

                serializedPropertyCurrent = source.GetIterator ();

                while (serializedPropertyCurrent.Next(true)) {

                        dest.CopyFromSerializedProperty (serializedPropertyCurrent);
                }

                dest.ApplyModifiedProperties ();
    }
开发者ID:osmanzeki,项目名称:bmachine,代码行数:13,代码来源:UnityClipboard.cs

示例2: 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();
            }
开发者ID:abstractmachine,项目名称:Fungus-3D-Template,代码行数:14,代码来源:FlowchartWindow.cs

示例3: OnGUI

    void OnGUI()
    {
        try
        {
            scroll = EditorGUILayout.BeginScrollView(scroll);

            foreach (TweakableClass c in tweakables)
            {
                if (c.objects.Length > 0)
                {
                    EditorGUILayout.LabelField(c.type.ToString(), EditorStyles.boldLabel);
                    EditorGUI.indentLevel++;
                    EditorGUILayout.LabelField("Shared Settings", EditorStyles.boldLabel);
                    EditorGUI.indentLevel++;
                    SerializedObject o = new SerializedObject(c.objects[0]);

                    List<SerializedProperty> props = new List<SerializedProperty>();
                    foreach (FieldInfo field in c.sharedFields)
                    {

                        SerializedProperty p = o.FindProperty(field.Name);
                        if (p == null)
                        {
                            Debug.LogWarning("non-properties aren't supported yet. The type: (" + field.FieldType + ") of \"" + c.type + "." + field.Name + "\" is currently illegal.");
                        }
                        else
                        {
                            PropertyField(p);
                            props.Add(p);
                        }

                    }
                    o.ApplyModifiedProperties();
                    EditorGUI.indentLevel--;

                    foreach (UnityEngine.Object obj in c.objects)
                    {
                        EditorGUILayout.LabelField(obj.name, EditorStyles.boldLabel);
                        EditorGUI.indentLevel++;
                        SerializedObject instObj = new SerializedObject(obj);
                        foreach (SerializedProperty p in props) // copy shared props
                        {
                            instObj.CopyFromSerializedProperty(p);
                        }
                        instObj.ApplyModifiedPropertiesWithoutUndo();

                        GUI.changed = false;
                        foreach (FieldInfo field in c.instancedFields)
                        {
                            SerializedProperty prop = instObj.FindProperty(field.Name);
                            if (prop == null)
                            {
                                Debug.LogWarning("non-properties aren't supported yet. The type: (" + field.FieldType + ") of \"" + c.type + "." + field.Name + "\" is currently illegal.");
                            } else
                                PropertyField(prop);

                        }

                        instObj.ApplyModifiedProperties();
                        UnityEngine.Object objParent;
                        if (GUI.changed && (objParent = PrefabUtility.GetPrefabParent(obj)) != null && objParent != obj)
                        {
                            PrefabUtility.RecordPrefabInstancePropertyModifications(obj);
                        }
                        GUI.changed = false;

                        EditorGUI.indentLevel--;
                    }

                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.Separator();

            }
            EditorGUILayout.EndScrollView();
        }
        catch (UnityException e)
        {
            Debug.LogWarning("error occured, refreshing...\n" + e.Message);
            RefreshContent();
        }
    }
开发者ID:Ryxali,项目名称:GameTweaker,代码行数:82,代码来源:GameTweaker.cs

示例4: UpgradeSkies

    public static void UpgradeSkies()
    {
        Undo.RegisterSceneUndo("Upgrade Skies");
        Component[] all = GameObject.FindObjectsOfType(typeof(Transform)) as Component[];

        //Create a dummy game object, add a namespaced Sky to it, find its serialized script type
        GameObject refObj = new GameObject("_dummy_sky");
        mset.Sky refSky = refObj.AddComponent<mset.Sky>();
        SerializedObject refSr = new SerializedObject(refSky);
        SerializedProperty scriptType = refSr.FindProperty("m_Script");

        int count = 0;
        //Find all old sky objects, swap out the Sky script references to mset.Sky
        for(int i=0; i<all.Length; ++i) {
            GameObject obj = all[i].gameObject;
            if(obj) {
                Sky old = obj.GetComponent<Sky>() as Sky;
                if(old != null) {
                    SerializedObject sr = new SerializedObject(old);
                    sr.CopyFromSerializedProperty(scriptType);
                    sr.ApplyModifiedProperties();
                    count++;
                }
            }
        }
        if( count == 0 ) {
            EditorUtility.DisplayDialog("Done Upgrading!", "No deprecated skies found.\n\nPro Tip: Don't forget to use the \"mset\" namespace when scripting with the Sky class.", "Ok");
        } else {
            EditorUtility.DisplayDialog("Done Upgrading!", count + " deprecated skies found and upgraded.\n\nPro Tip: Don't forget to use the \"mset\" namespace when scripting with the Sky class.", "Ok");
        }
        Component.DestroyImmediate(refObj);
    }
开发者ID:damard,项目名称:Unity,代码行数:32,代码来源:SkyshopUtil.cs

示例5: CopyHumanDescriptionToDestination

		private static void CopyHumanDescriptionToDestination(SerializedObject sourceObject, SerializedObject targetObject)
		{
			targetObject.CopyFromSerializedProperty(sourceObject.FindProperty("m_HumanDescription"));
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:4,代码来源:ModelImporterRigEditor.cs

示例6: SaveValues

    void SaveValues( UnityEngine.Object from, UnityEngine.Object to )
    {
        SerializedObject source = new SerializedObject( from );
        SerializedObject destination = new SerializedObject( to );

        SerializedProperty property = source.GetIterator();
        property.NextVisible(true);
        while( property.NextVisible(false) )
        {
            destination.CopyFromSerializedProperty( property );
        }

        destination.ApplyModifiedProperties();
    }
开发者ID:jakeobrien,项目名称:ExquisiteCorpseJam,代码行数:14,代码来源:SettingsWindow.cs

示例7: DisplayShared

    private void DisplayShared(List<UnityEngine.Object> objRef)
    {
        SerializedObject o = new SerializedObject(objRef[0]);
        Type type = objRef[0].GetType();
        FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy);
        EditorGUILayout.LabelField(type.ToString(), EditorStyles.boldLabel);
        EditorGUI.indentLevel++;
        foreach (FieldInfo field in fields)
        {
            bool hasShowinTweakerAttribute = false;
            foreach (Attribute at in field.GetCustomAttributes(true))
            {
                if (at is TweakableField)
                {
                    hasShowinTweakerAttribute = ((TweakableField)at).isSharedAmongAllInstances;
                }
            }
            if (hasShowinTweakerAttribute)
            {
                var prop = o.FindProperty(field.Name);
                if (prop.isArray)
                {
                    DrawArrayProperty(prop);
                }
                else
                {
                    EditorGUILayout.PropertyField(prop);
                }

                for (int i = 1; i < objRef.Count; i++)
                {
                    SerializedObject o2 = new SerializedObject(objRef[i]);
                    o2.CopyFromSerializedProperty(prop);
                    o2.ApplyModifiedPropertiesWithoutUndo();
                }
                o.ApplyModifiedProperties();
            }
        }
        EditorGUI.indentLevel--;
    }
开发者ID:Ryxali,项目名称:Passpartout,代码行数:40,代码来源:GameTweaker.cs


注:本文中的UnityEditor.SerializedObject.CopyFromSerializedProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。