unity 编辑器修改 prefab 的 私有字段
string prefabPath = idcardFunctionalPath; GameObject prefabInstance = PrefabUtility.LoadPrefabContents(prefabPath); SerializedObject serializedObject = new SerializedObject(prefabInstance.GetComponent<MyCube>()); serializedObject.FindProperty("str").stringValue = "xxxxx";//字符串类型 serializedObject.ApplyModifiedProperties();//应用修改 PrefabUtility.SaveAsPrefabAsset(prefabInstance, prefabPath);//保存