internal override void Apply()
 {
     ModelImporterRigEditor.MappingRelevantSettings[] array = new ModelImporterRigEditor.MappingRelevantSettings[base.targets.Length];
     for (int i = 0; i < base.targets.Length; i++)
     {
         SerializedObject   serializedObject    = new SerializedObject(base.targets[i]);
         SerializedProperty serializedProperty  = serializedObject.FindProperty("m_AnimationType");
         SerializedProperty serializedProperty2 = serializedObject.FindProperty("m_CopyAvatar");
         array[i].humanoid       = (serializedProperty.intValue == 3);
         array[i].hasNoAnimation = (serializedProperty.intValue == 0);
         array[i].copyAvatar     = serializedProperty2.boolValue;
     }
     ModelImporterRigEditor.MappingRelevantSettings[] array2 = new ModelImporterRigEditor.MappingRelevantSettings[base.targets.Length];
     Array.Copy(array, array2, base.targets.Length);
     for (int j = 0; j < base.targets.Length; j++)
     {
         if (!this.m_AnimationType.hasMultipleDifferentValues)
         {
             array2[j].humanoid = (this.m_AnimationType.intValue == 3);
         }
         if (!this.m_CopyAvatar.hasMultipleDifferentValues)
         {
             array2[j].copyAvatar = this.m_CopyAvatar.boolValue;
         }
     }
     base.serializedObject.ApplyModifiedProperties();
     for (int k = 0; k < base.targets.Length; k++)
     {
         if (array[k].usesOwnAvatar && !array2[k].usesOwnAvatar)
         {
             SerializedObject serializedObject2 = new SerializedObject(base.targets[k]);
             AvatarSetupTool.ClearAll(serializedObject2);
             serializedObject2.ApplyModifiedProperties();
         }
         if (!array[k].usesOwnAvatar && array2[k].usesOwnAvatar)
         {
             ModelImporter modelImporter = base.targets[k] as ModelImporter;
             if (array[k].hasNoAnimation)
             {
                 AssetDatabase.ImportAsset(modelImporter.assetPath);
             }
             SerializedObject serializedObject3 = new SerializedObject(base.targets[k]);
             GameObject       gameObject        = AssetDatabase.LoadMainAssetAtPath(modelImporter.assetPath) as GameObject;
             Animator         component         = gameObject.GetComponent <Animator>();
             bool             flag = component && !component.hasTransformHierarchy;
             if (flag)
             {
                 gameObject = UnityEngine.Object.Instantiate <GameObject>(gameObject);
                 AnimatorUtility.DeoptimizeTransformHierarchy(gameObject);
             }
             AvatarSetupTool.AutoSetupOnInstance(gameObject, serializedObject3);
             this.m_IsBiped = AvatarBipedMapper.IsBiped(gameObject.transform, this.m_BipedMappingReport);
             if (flag)
             {
                 UnityEngine.Object.DestroyImmediate(gameObject);
             }
             serializedObject3.ApplyModifiedProperties();
         }
     }
 }
Esempio n. 2
0
 internal override void Apply()
 {
     ModelImporterRigEditor.MappingRelevantSettings[] relevantSettingsArray1 = new ModelImporterRigEditor.MappingRelevantSettings[this.targets.Length];
     for (int index = 0; index < this.targets.Length; ++index)
     {
         SerializedObject   serializedObject = new SerializedObject(this.targets[index]);
         SerializedProperty property1        = serializedObject.FindProperty("m_AnimationType");
         SerializedProperty property2        = serializedObject.FindProperty("m_CopyAvatar");
         relevantSettingsArray1[index].humanoid       = property1.intValue == 3;
         relevantSettingsArray1[index].hasNoAnimation = property1.intValue == 0;
         relevantSettingsArray1[index].copyAvatar     = property2.boolValue;
     }
     ModelImporterRigEditor.MappingRelevantSettings[] relevantSettingsArray2 = new ModelImporterRigEditor.MappingRelevantSettings[this.targets.Length];
     Array.Copy((Array)relevantSettingsArray1, (Array)relevantSettingsArray2, this.targets.Length);
     for (int index = 0; index < this.targets.Length; ++index)
     {
         if (!this.m_AnimationType.hasMultipleDifferentValues)
         {
             relevantSettingsArray2[index].humanoid = this.m_AnimationType.intValue == 3;
         }
         if (!this.m_CopyAvatar.hasMultipleDifferentValues)
         {
             relevantSettingsArray2[index].copyAvatar = this.m_CopyAvatar.boolValue;
         }
     }
     this.serializedObject.ApplyModifiedProperties();
     for (int index = 0; index < this.targets.Length; ++index)
     {
         if (relevantSettingsArray1[index].usesOwnAvatar && !relevantSettingsArray2[index].usesOwnAvatar)
         {
             SerializedObject serializedObject = new SerializedObject(this.targets[index]);
             AvatarSetupTool.ClearAll(serializedObject);
             serializedObject.ApplyModifiedProperties();
         }
         if (!relevantSettingsArray1[index].usesOwnAvatar && relevantSettingsArray2[index].usesOwnAvatar)
         {
             ModelImporter target = this.targets[index] as ModelImporter;
             if (relevantSettingsArray1[index].hasNoAnimation)
             {
                 AssetDatabase.ImportAsset(target.assetPath);
             }
             SerializedObject modelImporterSerializedObject = new SerializedObject(this.targets[index]);
             GameObject       gameObject = AssetDatabase.LoadMainAssetAtPath(target.assetPath) as GameObject;
             Animator         component  = gameObject.GetComponent <Animator>();
             bool             flag       = (bool)((UnityEngine.Object)component) && !component.hasTransformHierarchy;
             if (flag)
             {
                 gameObject = UnityEngine.Object.Instantiate <GameObject>(gameObject);
                 AnimatorUtility.DeoptimizeTransformHierarchy(gameObject);
             }
             AvatarSetupTool.AutoSetupOnInstance(gameObject, modelImporterSerializedObject);
             this.m_IsBiped = AvatarBipedMapper.IsBiped(gameObject.transform, this.m_BipedMappingReport);
             if (flag)
             {
                 UnityEngine.Object.DestroyImmediate((UnityEngine.Object)gameObject);
             }
             modelImporterSerializedObject.ApplyModifiedProperties();
         }
     }
 }
		internal override void Apply()
		{
			ModelImporterRigEditor.MappingRelevantSettings[] array = new ModelImporterRigEditor.MappingRelevantSettings[base.targets.Length];
			for (int i = 0; i < base.targets.Length; i++)
			{
				SerializedObject serializedObject = new SerializedObject(base.targets[i]);
				SerializedProperty serializedProperty = serializedObject.FindProperty("m_AnimationType");
				SerializedProperty serializedProperty2 = serializedObject.FindProperty("m_CopyAvatar");
				array[i].humanoid = (serializedProperty.intValue == 3);
				array[i].hasNoAnimation = (serializedProperty.intValue == 0);
				array[i].copyAvatar = serializedProperty2.boolValue;
			}
			ModelImporterRigEditor.MappingRelevantSettings[] array2 = new ModelImporterRigEditor.MappingRelevantSettings[base.targets.Length];
			Array.Copy(array, array2, base.targets.Length);
			for (int j = 0; j < base.targets.Length; j++)
			{
				if (!this.m_AnimationType.hasMultipleDifferentValues)
				{
					array2[j].humanoid = (this.m_AnimationType.intValue == 3);
				}
				if (!this.m_CopyAvatar.hasMultipleDifferentValues)
				{
					array2[j].copyAvatar = this.m_CopyAvatar.boolValue;
				}
			}
			base.serializedObject.ApplyModifiedProperties();
			for (int k = 0; k < base.targets.Length; k++)
			{
				if (array[k].usesOwnAvatar && !array2[k].usesOwnAvatar)
				{
					SerializedObject serializedObject2 = new SerializedObject(base.targets[k]);
					AvatarSetupTool.ClearAll(serializedObject2);
					serializedObject2.ApplyModifiedProperties();
				}
				if (!array[k].usesOwnAvatar && array2[k].usesOwnAvatar)
				{
					ModelImporter modelImporter = base.targets[k] as ModelImporter;
					if (array[k].hasNoAnimation)
					{
						AssetDatabase.ImportAsset(modelImporter.assetPath);
					}
					SerializedObject serializedObject3 = new SerializedObject(base.targets[k]);
					GameObject gameObject = AssetDatabase.LoadMainAssetAtPath(modelImporter.assetPath) as GameObject;
					Animator component = gameObject.GetComponent<Animator>();
					bool flag = component && !component.hasTransformHierarchy;
					if (flag)
					{
						gameObject = UnityEngine.Object.Instantiate<GameObject>(gameObject);
						AnimatorUtility.DeoptimizeTransformHierarchy(gameObject);
					}
					AvatarSetupTool.AutoSetupOnInstance(gameObject, serializedObject3);
					if (flag)
					{
						UnityEngine.Object.DestroyImmediate(gameObject);
					}
					serializedObject3.ApplyModifiedProperties();
				}
			}
		}
 internal override void Apply()
 {
   ModelImporterRigEditor.MappingRelevantSettings[] relevantSettingsArray1 = new ModelImporterRigEditor.MappingRelevantSettings[this.targets.Length];
   for (int index = 0; index < this.targets.Length; ++index)
   {
     SerializedObject serializedObject = new SerializedObject(this.targets[index]);
     SerializedProperty property1 = serializedObject.FindProperty("m_AnimationType");
     SerializedProperty property2 = serializedObject.FindProperty("m_CopyAvatar");
     relevantSettingsArray1[index].humanoid = property1.intValue == 3;
     relevantSettingsArray1[index].hasNoAnimation = property1.intValue == 0;
     relevantSettingsArray1[index].copyAvatar = property2.boolValue;
   }
   ModelImporterRigEditor.MappingRelevantSettings[] relevantSettingsArray2 = new ModelImporterRigEditor.MappingRelevantSettings[this.targets.Length];
   Array.Copy((Array) relevantSettingsArray1, (Array) relevantSettingsArray2, this.targets.Length);
   for (int index = 0; index < this.targets.Length; ++index)
   {
     if (!this.m_AnimationType.hasMultipleDifferentValues)
       relevantSettingsArray2[index].humanoid = this.m_AnimationType.intValue == 3;
     if (!this.m_CopyAvatar.hasMultipleDifferentValues)
       relevantSettingsArray2[index].copyAvatar = this.m_CopyAvatar.boolValue;
   }
   this.serializedObject.ApplyModifiedProperties();
   for (int index = 0; index < this.targets.Length; ++index)
   {
     if (relevantSettingsArray1[index].usesOwnAvatar && !relevantSettingsArray2[index].usesOwnAvatar)
     {
       SerializedObject serializedObject = new SerializedObject(this.targets[index]);
       AvatarSetupTool.ClearAll(serializedObject);
       serializedObject.ApplyModifiedProperties();
     }
     if (!relevantSettingsArray1[index].usesOwnAvatar && relevantSettingsArray2[index].usesOwnAvatar)
     {
       ModelImporter target = this.targets[index] as ModelImporter;
       if (relevantSettingsArray1[index].hasNoAnimation)
         AssetDatabase.ImportAsset(target.assetPath);
       SerializedObject modelImporterSerializedObject = new SerializedObject(this.targets[index]);
       GameObject gameObject = AssetDatabase.LoadMainAssetAtPath(target.assetPath) as GameObject;
       Animator component = gameObject.GetComponent<Animator>();
       bool flag = (bool) ((UnityEngine.Object) component) && !component.hasTransformHierarchy;
       if (flag)
       {
         gameObject = UnityEngine.Object.Instantiate<GameObject>(gameObject);
         AnimatorUtility.DeoptimizeTransformHierarchy(gameObject);
       }
       AvatarSetupTool.AutoSetupOnInstance(gameObject, modelImporterSerializedObject);
       this.m_IsBiped = AvatarBipedMapper.IsBiped(gameObject.transform, this.m_BipedMappingReport);
       if (flag)
         UnityEngine.Object.DestroyImmediate((UnityEngine.Object) gameObject);
       modelImporterSerializedObject.ApplyModifiedProperties();
     }
   }
 }