本文整理汇总了C#中UnityEditor.SerializedObject.ApplyModifiedProperties方法的典型用法代码示例。如果您正苦于以下问题:C# SerializedObject.ApplyModifiedProperties方法的具体用法?C# SerializedObject.ApplyModifiedProperties怎么用?C# SerializedObject.ApplyModifiedProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEditor.SerializedObject
的用法示例。
在下文中一共展示了SerializedObject.ApplyModifiedProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAxis
public static bool AddAxis( AxisDefinition axis )
{
if( AxisDefined( axis.name ) )
{
return false;
}
SerializedObject serializedObject = new SerializedObject( AssetDatabase.LoadAllAssetsAtPath( "ProjectSettings/InputManager.asset" )[0] );
SerializedProperty axesProperty = serializedObject.FindProperty( "m_Axes" );
axesProperty.arraySize++;
serializedObject.ApplyModifiedProperties();
SerializedProperty axisProperty = axesProperty.GetArrayElementAtIndex( axesProperty.arraySize - 1 );
GetChildProperty( axisProperty, "m_Name" ).stringValue = axis.name;
GetChildProperty( axisProperty, "descriptiveName" ).stringValue = axis.descriptiveName;
GetChildProperty( axisProperty, "descriptiveNegativeName" ).stringValue = axis.descriptiveNegativeName;
GetChildProperty( axisProperty, "negativeButton" ).stringValue = axis.negativeButton;
GetChildProperty( axisProperty, "positiveButton" ).stringValue = axis.positiveButton;
GetChildProperty( axisProperty, "altNegativeButton" ).stringValue = axis.altNegativeButton;
GetChildProperty( axisProperty, "altPositiveButton" ).stringValue = axis.altPositiveButton;
GetChildProperty( axisProperty, "gravity" ).floatValue = axis.gravity;
GetChildProperty( axisProperty, "dead" ).floatValue = axis.dead;
GetChildProperty( axisProperty, "sensitivity" ).floatValue = axis.sensitivity;
GetChildProperty( axisProperty, "snap" ).boolValue = axis.snap;
GetChildProperty( axisProperty, "invert" ).boolValue = axis.invert;
GetChildProperty( axisProperty, "type" ).intValue = (int)axis.type;
GetChildProperty( axisProperty, "axis" ).intValue = axis.axis - 1;
GetChildProperty( axisProperty, "joyNum" ).intValue = axis.joyNum;
serializedObject.ApplyModifiedProperties();
return true;
}
示例2: createMecanimResources
public override void createMecanimResources(GAFAnimationAssetInternal _Asset)
{
var serializedAsset = new SerializedObject(_Asset);
var mecanimFolder = serializedAsset.FindProperty("m_MecanimResourcesDirectory");
var mecanimFolderPath = string.Empty;
if (!string.IsNullOrEmpty(mecanimFolder.stringValue) &&
System.IO.Directory.Exists(Application.dataPath + "/" + mecanimFolder.stringValue))
{
mecanimFolderPath = "Assets/" + mecanimFolder.stringValue;
}
else
{
var assetDirectoryPath = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(_Asset));
mecanimFolderPath = assetDirectoryPath + "/" + _Asset.name + "_animator/";
mecanimFolder.stringValue = mecanimFolderPath.Substring("Assets/".Length, mecanimFolderPath.Length - "Assets/".Length);
serializedAsset.ApplyModifiedProperties();
if (!System.IO.Directory.Exists(Application.dataPath + "/" + mecanimFolderPath.Substring("Assets/".Length, mecanimFolderPath.Length - "Assets/".Length)))
AssetDatabase.CreateFolder(assetDirectoryPath, _Asset.name + "_animator");
}
List<RuntimeAnimatorController> controllersList = new List<RuntimeAnimatorController>();
foreach (var timeline in _Asset.getTimelines())
{
var controllerPath = mecanimFolderPath + "[" + _Asset.name + "]_Timeline_" + timeline.linkageName + ".controller";
var animatorController = AssetDatabase.LoadAssetAtPath(controllerPath, typeof(AnimatorController)) as AnimatorController;
if (animatorController == null)
animatorController = AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
createAnimations(timeline, animatorController, mecanimFolderPath);
controllersList.Add(animatorController);
}
var controllers = serializedAsset.FindProperty("m_AnimatorControllers");
controllers.ClearArray();
for (int i = 0; i < controllersList.Count; ++i)
{
controllers.InsertArrayElementAtIndex(0);
var property = controllers.GetArrayElementAtIndex(0);
property.objectReferenceValue = controllersList[i];
}
serializedAsset.ApplyModifiedProperties();
AssetDatabase.SaveAssets();
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
}
示例3: Apply
internal override void Apply()
{
MappingRelevantSettings[] sourceArray = new MappingRelevantSettings[base.targets.Length];
for (int i = 0; i < base.targets.Length; i++)
{
SerializedObject obj2 = new SerializedObject(base.targets[i]);
SerializedProperty property = obj2.FindProperty("m_AnimationType");
SerializedProperty property2 = obj2.FindProperty("m_CopyAvatar");
sourceArray[i].humanoid = property.intValue == 3;
sourceArray[i].hasNoAnimation = property.intValue == 0;
sourceArray[i].copyAvatar = property2.boolValue;
}
MappingRelevantSettings[] destinationArray = new MappingRelevantSettings[base.targets.Length];
Array.Copy(sourceArray, destinationArray, base.targets.Length);
for (int j = 0; j < base.targets.Length; j++)
{
if (!this.m_AnimationType.hasMultipleDifferentValues)
{
destinationArray[j].humanoid = this.m_AnimationType.intValue == 3;
}
if (!this.m_CopyAvatar.hasMultipleDifferentValues)
{
destinationArray[j].copyAvatar = this.m_CopyAvatar.boolValue;
}
}
base.serializedObject.ApplyModifiedProperties();
for (int k = 0; k < base.targets.Length; k++)
{
if (sourceArray[k].usesOwnAvatar && !destinationArray[k].usesOwnAvatar)
{
SerializedObject serializedObject = new SerializedObject(base.targets[k]);
AvatarSetupTool.ClearAll(serializedObject);
serializedObject.ApplyModifiedProperties();
}
if (!sourceArray[k].usesOwnAvatar && destinationArray[k].usesOwnAvatar)
{
ModelImporter importer = base.targets[k] as ModelImporter;
if (sourceArray[k].hasNoAnimation)
{
AssetDatabase.ImportAsset(importer.assetPath);
}
SerializedObject modelImporterSerializedObject = new SerializedObject(base.targets[k]);
GameObject original = AssetDatabase.LoadMainAssetAtPath(importer.assetPath) as GameObject;
Animator component = original.GetComponent<Animator>();
bool flag = (component != null) && !component.hasTransformHierarchy;
if (flag)
{
original = UnityEngine.Object.Instantiate<GameObject>(original);
AnimatorUtility.DeoptimizeTransformHierarchy(original);
}
AvatarSetupTool.AutoSetupOnInstance(original, modelImporterSerializedObject);
this.m_IsBiped = AvatarBipedMapper.IsBiped(original.transform);
if (flag)
{
UnityEngine.Object.DestroyImmediate(original);
}
modelImporterSerializedObject.ApplyModifiedProperties();
}
}
}
示例4: ShurikenParticleScaleChange
public void ShurikenParticleScaleChange(float _Value)
{
ParticleSystem[] ParticleSystems = GetComponentsInChildren<ParticleSystem>();
transform.localScale *= _Value;
foreach(ParticleSystem _ParticleSystem in ParticleSystems) {
_ParticleSystem.startSpeed *= _Value;
_ParticleSystem.startSize *= _Value;
_ParticleSystem.gravityModifier *= _Value;
SerializedObject _SerializedObject = new SerializedObject(_ParticleSystem);
_SerializedObject.FindProperty("CollisionModule.particleRadius").floatValue *= _Value;
_SerializedObject.FindProperty("ShapeModule.radius").floatValue *= _Value;
_SerializedObject.FindProperty("ShapeModule.boxX").floatValue *= _Value;
_SerializedObject.FindProperty("ShapeModule.boxY").floatValue *= _Value;
_SerializedObject.FindProperty("ShapeModule.boxZ").floatValue *= _Value;
_SerializedObject.FindProperty("VelocityModule.x.scalar").floatValue *= _Value;
_SerializedObject.FindProperty("VelocityModule.y.scalar").floatValue *= _Value;
_SerializedObject.FindProperty("VelocityModule.z.scalar").floatValue *= _Value;
_SerializedObject.FindProperty("ClampVelocityModule.x.scalar").floatValue *= _Value;
_SerializedObject.FindProperty("ClampVelocityModule.y.scalar").floatValue *= _Value;
_SerializedObject.FindProperty("ClampVelocityModule.z.scalar").floatValue *= _Value;
_SerializedObject.FindProperty("ClampVelocityModule.magnitude.scalar").floatValue *= _Value;
_SerializedObject.ApplyModifiedProperties();
}
}
示例5: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
position.x += 4;
position.width -= 6;
if (!initialized) {
AIEditorWindow[] windows=Resources.FindObjectsOfTypeAll<AIEditorWindow>();
if(windows.Length >0){
controller = windows[0].controller;
}
initialized=true;
}
if (controller != null) {
NamedParameter param=(NamedParameter)property.objectReferenceValue;
if(param == null){
property.objectReferenceValue=param=CreateUserParameter();
}
position.width-=15;
Rect r= new Rect(position);
r.x+=position.width;
r.width=20;
param.userVariable=GUI.Toggle(r,param.userVariable,GUIContent.none);
if(param != null && param.userVariable){
param.Name=string.Empty;
SerializedObject paramObject= new SerializedObject(param);
paramObject.Update();
EditorGUI.PropertyField(position,paramObject.FindProperty("value"),new GUIContent(label.text));
paramObject.ApplyModifiedProperties();
}else{
string[] parameters=null;
if(fieldInfo.FieldType == typeof(Vector3Parameter)){
parameters=controller.GetParameterNames(fieldInfo.FieldType,typeof(GameObjectParameter));
}else{
parameters=controller.GetParameterNames(fieldInfo.FieldType);
}
if(parameters.Length == 0){
System.Array.Resize (ref parameters, parameters.Length + 1);
parameters[parameters.Length - 1] = "None";
List<string> list= new List<string>(parameters);
list.Swap(0,parameters.Length-1);
parameters=list.ToArray();
}
for(int i=0;i< parameters.Length;i++){
if(parameters[i] == param.Name){
selectedIndex=i;
}
}
GUI.color=(parameters[selectedIndex]=="None"?Color.red:Color.white);
selectedIndex=EditorGUI.Popup(position,label.text,selectedIndex,parameters);
GUI.color=Color.white;
if(parameters[selectedIndex]!="None"){
param.Name=parameters[selectedIndex];
}
}
}
}
示例6: applyColor
//Change Color
private void applyColor()
{
foreach(GameObject go in Selection.gameObjects)
{
ParticleSystem[] systems;
if(IncludeChildren) systems = go.GetComponentsInChildren<ParticleSystem>(true);
else systems = go.GetComponents<ParticleSystem>();
foreach(ParticleSystem ps in systems)
{
SerializedObject psSerial = new SerializedObject(ps);
if(!AffectAlpha)
{
psSerial.FindProperty("InitialModule.startColor.maxColor").colorValue = new Color(ColorValue.r, ColorValue.g, ColorValue.b, psSerial.FindProperty("InitialModule.startColor.maxColor").colorValue.a);
psSerial.FindProperty("InitialModule.startColor.minColor").colorValue = new Color(ColorValue2.r, ColorValue2.g, ColorValue2.b, psSerial.FindProperty("InitialModule.startColor.minColor").colorValue.a);
}
else
{
psSerial.FindProperty("InitialModule.startColor.maxColor").colorValue = ColorValue;
psSerial.FindProperty("InitialModule.startColor.minColor").colorValue = ColorValue2;
}
psSerial.ApplyModifiedProperties();
}
}
}
示例7: ScaleLegacySystems
void ScaleLegacySystems(float scaleFactor)
{
//get all emitters we need to do scaling on
ParticleEmitter[] emitters = GetComponentsInChildren<ParticleEmitter>();
//get all animators we need to do scaling on
ParticleAnimator[] animators = GetComponentsInChildren<ParticleAnimator>();
//apply scaling to emitters
foreach (ParticleEmitter emitter in emitters)
{
emitter.minSize *= scaleFactor;
emitter.maxSize *= scaleFactor;
emitter.worldVelocity *= scaleFactor;
emitter.localVelocity *= scaleFactor;
emitter.rndVelocity *= scaleFactor;
//some variables cannot be accessed through regular script, we will acces them through a serialized object
SerializedObject so = new SerializedObject(emitter);
so.FindProperty("m_Ellipsoid").vector3Value *= scaleFactor;
so.FindProperty("tangentVelocity").vector3Value *= scaleFactor;
so.ApplyModifiedProperties();
}
//apply scaling to animators
foreach (ParticleAnimator animator in animators)
{
animator.force *= scaleFactor;
animator.rndForce *= scaleFactor;
}
}
示例8: OnInspectorGUI
public override void OnInspectorGUI()
{
var sortingGroup = target as SortingGroup;
serializedObject.Update();
EditorGUILayout.PropertyField (sortingMode);
var mode = (SortingGroup.SortingMode)sortingMode.intValue;
showManualMode.target = mode == SortingGroup.SortingMode.Manual;
if (EditorGUILayout.BeginFadeGroup (showManualMode.faded))
list.DoLayoutList();
EditorGUILayout.EndFadeGroup ();
EditorGUI.BeginChangeCheck();
SortingLayerField (new GUIContent("Sorting Layer"), sortingLayerID, EditorStyles.popup);
if (EditorGUI.EndChangeCheck())
{
foreach (var renderer in sortingGroup.GetComponentsInChildren<Renderer>())
{
var so = new SerializedObject(renderer);
so.FindProperty("m_SortingLayerID").intValue = sortingLayerID.intValue;
so.ApplyModifiedProperties();
}
}
serializedObject.ApplyModifiedProperties();
}
示例9: ShowComponents
private string ShowComponents(SerializedObject objTarget, GameObject gameObject)
{
var targetComponentAssemblyName = objTarget.FindProperty("targetComponentAssemblyName");
var targetComponentFullname = objTarget.FindProperty("targetComponentFullname");
var targetComponentText = objTarget.FindProperty("targetComponentText");
var objComponents = gameObject.GetComponents<Component>();
var objTypesAssemblynames = (from objComp in objComponents select objComp.GetType().AssemblyQualifiedName).ToList();
var objTypesName = (from objComp in objComponents select objComp.GetType().Name).ToList();
int index = objTypesAssemblynames.IndexOf(targetComponentAssemblyName.stringValue);
index = EditorGUILayout.Popup("Target Component", index, objTypesName.ToArray());
if (index != -1)
{
targetComponentAssemblyName.stringValue = objTypesAssemblynames[index];
targetComponentFullname.stringValue = objComponents.GetType().FullName;
targetComponentText.stringValue = objTypesName[index];
}
else
{
targetComponentAssemblyName.stringValue = null;
}
objTarget.ApplyModifiedProperties();
return targetComponentAssemblyName.stringValue;
}
示例10: OnInspectorGUI
public override void OnInspectorGUI()
{
SerializedObject myScript = new SerializedObject(target);
SerializedProperty SpawnGameObject = myScript.FindProperty("SpawnGameObject");
SerializedProperty SpawnTime = myScript.FindProperty("SpawnTime");
SerializedProperty DependOnThisState = myScript.FindProperty("DependOnThisState");
SerializedProperty DestroyTime = myScript.FindProperty("DestroyTime");
SerializedProperty OffsetDueDirection = myScript.FindProperty("OffsetDueDirection");
EditorGUILayout.Space(); EditorGUILayout.Space();
SpawnGameObject.objectReferenceValue =
EditorGUILayout.ObjectField(new GUIContent("Spawn Game Object"), SpawnGameObject.objectReferenceValue, typeof(GameObject), true) as GameObject;
if (SpawnGameObject.objectReferenceValue == null) {
EditorGUILayout.HelpBox(_spawnError, MessageType.Error);
}
EditorGUILayout.Slider(SpawnTime, 0.0f, 1.0f, new GUIContent("Spawn Time (%)"));
EditorGUILayout.Space(); EditorGUILayout.Space();
EditorGUILayout.PropertyField(DependOnThisState);
if (DependOnThisState.boolValue) {
EditorGUILayout.Slider(DestroyTime, 0.0f, 1.0f, new GUIContent("Destroy Time (%)"));
}
EditorGUILayout.Space(); EditorGUILayout.Space();
EditorGUILayout.LabelField("Player Base Setup", EditorStyles.boldLabel);
EditorGUILayout.HelpBox(_offsetDueDirectionInfo, MessageType.Info);
EditorGUILayout.PropertyField(OffsetDueDirection);
myScript.ApplyModifiedProperties();
}
示例11: CreateAudioAssets
private static void CreateAudioAssets()
{
if(Selection.objects.Length > 0)
{
foreach(Object obj in Selection.objects)
{
if(obj.GetType() == typeof(AudioClip))
{
string path = AssetDatabase.GetAssetPath(obj);
if(!string.IsNullOrEmpty(path))
{
path = Path.ChangeExtension(path, ".asset");
SerializedObject asset = new SerializedObject(CreateAudioAssetAtPath(path));
asset.FindProperty("audioClip").objectReferenceValue = obj;
asset.ApplyModifiedProperties();
asset.Dispose();
}
}
}
AssetDatabase.SaveAssets();
}
}
示例12: LegacyEffectScaleChange
public void LegacyEffectScaleChange(float Value)
{
ParticleEmitter[] ParticleEmitters = GetComponentsInChildren<ParticleEmitter>();
ParticleAnimator[] ParticleAnimators = GetComponentsInChildren<ParticleAnimator>();
ParticleRenderer[] ParticleRenderers = GetComponentsInChildren<ParticleRenderer>();
transform.localScale *= Value;
foreach (ParticleEmitter _ParticleEmitter in ParticleEmitters)
{
_ParticleEmitter.minSize *= Value;
_ParticleEmitter.maxSize *= Value;
_ParticleEmitter.localVelocity *= Value;
_ParticleEmitter.rndAngularVelocity *= Value;
_ParticleEmitter.rndVelocity *= Value;
SerializedObject _SerializedObject = new SerializedObject(_ParticleEmitter);
_SerializedObject.FindProperty("m_Ellipsoid").vector3Value *= Value;
_SerializedObject.FindProperty("tangentVelocity").vector3Value *= Value;
_SerializedObject.ApplyModifiedProperties();
}
foreach (ParticleAnimator _ParticleAnimator in ParticleAnimators)
{
_ParticleAnimator.sizeGrow *= Value;
_ParticleAnimator.force *= Value;
_ParticleAnimator.rndForce *= Value;
}
foreach (ParticleRenderer _ParticleRenderer in ParticleRenderers)
{
_ParticleRenderer.maxParticleSize *= Value;
}
}
示例13: AddTag
void AddTag( string tag2add )
{
SerializedObject tagManager = new SerializedObject (AssetDatabase.LoadAllAssetsAtPath ("ProjectSettings/TagManager.asset")[0]);
SerializedProperty it = tagManager.FindProperty ("tags");
bool set = false;
for( int i = 0; i < it.arraySize; ++i )
{
SerializedProperty t = it.GetArrayElementAtIndex( i );
if( t.stringValue == tag2add )
{
set = true;
break;
}
if( t.stringValue == string.Empty )
{
t.stringValue = tag2add;
set = true;
break;
}
}
if( !set )
{
it.InsertArrayElementAtIndex (it.arraySize - 1);
it.GetArrayElementAtIndex (it.arraySize - 1).stringValue = tag2add;
}
tagManager.ApplyModifiedProperties ();
}
示例14: Draw
private void Draw(){
SerializedObject cacheObject = new SerializedObject (cache);
cacheObject.Update();
SerializedProperty property = cacheObject.FindProperty ("prefabs");
if (property != null) {
int removeIndex=-1;
for(int i=0;i< property.arraySize;i++){
GUILayout.BeginHorizontal();
SerializedProperty nameProperty=property.GetArrayElementAtIndex(i).FindPropertyRelative("name");
EditorGUILayout.PropertyField(nameProperty,GUIContent.none);
SerializedProperty prefabProperty=property.GetArrayElementAtIndex(i).FindPropertyRelative("prefab");
bool isNull=prefabProperty.objectReferenceValue==null;
EditorGUILayout.PropertyField(prefabProperty,GUIContent.none);
if(isNull && prefabProperty.objectReferenceValue!=null){
nameProperty.stringValue=prefabProperty.objectReferenceValue.name;
}
if(GUILayout.Button(EditorGUIUtility.FindTexture("Toolbar Minus"),"label",GUILayout.Width(20))){
removeIndex=i;
}
GUILayout.EndHorizontal();
}
if(removeIndex != -1){
property.DeleteArrayElementAtIndex(removeIndex);
}
}
cacheObject.ApplyModifiedProperties();
}
示例15: OnInspectorGUI
//OnInspectorGUI///////////////////////////////////////////////////////////
public override void OnInspectorGUI()
{
SerializedObject soTarget = new SerializedObject(target);
SerializedProperty spColSiz = soTarget.FindProperty("m_AnchorCollSize");
SerializedProperty spAncArr = soTarget.FindProperty("m_AnchorArr");
SerializedProperty spSpaArr = soTarget.FindProperty("m_SpawnArr");
SerializedProperty spGizmoLine = soTarget.FindProperty("onDrawGizmosLine");
SerializedProperty spGizmoColl = soTarget.FindProperty("onDrawGizmosColl");
SerializedProperty spGizmoSpDr = soTarget.FindProperty("onDrawGizmosSpDr");
this.GroupEditBox(spAncArr, spSpaArr);
EditorGUILayout.Space();
EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
GUILayout.Label("isDrowGimo", GUILayout.Width(76f));
GUILayout.Label("Line");
spGizmoLine.boolValue = EditorGUILayout.Toggle(spGizmoLine.boolValue);
GUILayout.Label("Coll");
spGizmoColl.boolValue = EditorGUILayout.Toggle(spGizmoColl.boolValue);
GUILayout.Label("Spaw");
spGizmoSpDr.boolValue = EditorGUILayout.Toggle(spGizmoSpDr.boolValue);
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space();
spColSiz.floatValue = EditorGUILayout.FloatField( "AnchorCollSize", spColSiz.floatValue);
this.ClassArrField(spAncArr, "AnchorData", ref sta_fAncFoldut, AnchorDataField);
this.ClassArrField(spSpaArr, "SpawnPoint", ref sta_fSpaFoldut, SpawnPointField);
//適用-----------------------------------------------------------------
soTarget.ApplyModifiedProperties();
}