private CopyFromSerializedProperty ( UnityEditor.SerializedProperty prop ) : void | ||
prop | UnityEditor.SerializedProperty | |
return | void |
private void SetupReferencedClip(string otherModelImporterPath) { SerializedObject targetImporter = GetModelImporterSerializedObject(otherModelImporterPath); // We may receive a path that doesn't have a importer. if (targetImporter != null) { targetImporter.CopyFromSerializedProperty(serializedObject.FindProperty("m_AnimationType")); SerializedProperty copyAvatar = targetImporter.FindProperty("m_CopyAvatar"); if (copyAvatar != null) { copyAvatar.boolValue = true; } SerializedProperty avatar = targetImporter.FindProperty("m_LastHumanDescriptionAvatarSource"); if (avatar != null) { avatar.objectReferenceValue = m_Avatar; } CopyHumanDescriptionToDestination(serializedObject, targetImporter); targetImporter.ApplyModifiedProperties(); targetImporter.Dispose(); } }
private void SetupReferencedClip(string otherModelImporterPath) { SerializedObject serializedObject = ModelImporterRigEditor.GetModelImporterSerializedObject(otherModelImporterPath); if (serializedObject == null) { return; } serializedObject.CopyFromSerializedProperty(this.serializedObject.FindProperty("m_AnimationType")); SerializedProperty property1 = serializedObject.FindProperty("m_CopyAvatar"); if (property1 != null) { property1.boolValue = true; } SerializedProperty property2 = serializedObject.FindProperty("m_LastHumanDescriptionAvatarSource"); if (property2 != null) { property2.objectReferenceValue = (UnityEngine.Object) this.m_Avatar; } ModelImporterRigEditor.CopyHumanDescriptionToDestination(this.serializedObject, serializedObject); serializedObject.ApplyModifiedProperties(); serializedObject.Dispose(); }
public static void copySerialized(SerializedObject source, SerializedObject dest) { SerializedProperty serializedPropertyCurrent; serializedPropertyCurrent = source.GetIterator (); while (serializedPropertyCurrent.Next(true)) { dest.CopyFromSerializedProperty (serializedPropertyCurrent); } dest.ApplyModifiedProperties (); }
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(); }
public void UpdateObject(SyncObjectMessage msg) { Object obj = EditorUtility.InstanceIDToObject(msg.object_id); if (obj) { SerializedObject ser_obj = new UnityEditor.SerializedObject(obj); ser_obj.CopyFromSerializedProperty(msg.prop); ser_obj.ApplyModifiedPropertiesWithoutUndo(); EditorSceneManager.MarkSceneDirty(m_scene); } }
private void SetupReferencedClip(string otherModelImporterPath) { SerializedObject modelImporterSerializedObject = GetModelImporterSerializedObject(otherModelImporterPath); if (modelImporterSerializedObject != null) { modelImporterSerializedObject.CopyFromSerializedProperty(base.serializedObject.FindProperty("m_AnimationType")); SerializedProperty property = modelImporterSerializedObject.FindProperty("m_CopyAvatar"); if (property != null) { property.boolValue = true; } SerializedProperty property2 = modelImporterSerializedObject.FindProperty("m_LastHumanDescriptionAvatarSource"); if (property2 != null) { property2.objectReferenceValue = this.m_Avatar; } CopyHumanDescriptionToDestination(base.serializedObject, modelImporterSerializedObject); modelImporterSerializedObject.ApplyModifiedProperties(); modelImporterSerializedObject.Dispose(); } }
private static void Run() { UnityEditor.EditorApplication.playModeStateChanged += state => { switch (state) { case UnityEditor.PlayModeStateChange.ExitingPlayMode: //var targets = FindObjectsOfType(typeof(Inner_PlayModeSave).DeclaringType); // 비활성 오브젝트 제외 var targets = Resources.FindObjectsOfTypeAll(typeof(Inner_PlayModeSave).DeclaringType); // 비활성 오브젝트 포함 targetSoArr = new UnityEditor.SerializedObject[targets.Length]; for (int i = 0; i < targets.Length; i++) { targetSoArr[i] = new UnityEditor.SerializedObject(targets[i]); } break; case UnityEditor.PlayModeStateChange.EnteredEditMode: if (targetSoArr == null) { break; } foreach (var oldSO in targetSoArr) { if (oldSO.targetObject == null) { continue; } var oldIter = oldSO.GetIterator(); var newSO = new UnityEditor.SerializedObject(oldSO.targetObject); while (oldIter.NextVisible(true)) { newSO.CopyFromSerializedProperty(oldIter); } newSO.ApplyModifiedProperties(); } break; } }; }
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(); } }
static void CopyHumanDescriptionToDestination(SerializedObject sourceObject, SerializedObject targetObject) { targetObject.CopyFromSerializedProperty(sourceObject.FindProperty("m_HumanDescription")); }
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); }
private static void CopyHumanDescriptionToDestination(SerializedObject sourceObject, SerializedObject targetObject) { targetObject.CopyFromSerializedProperty(sourceObject.FindProperty("m_HumanDescription")); }
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(); }
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--; }