Dispose() private méthode

private Dispose ( ) : void
Résultat void
Exemple #1
0
        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();
            }
        }
 public void OnDisable()
 {
     if (m_LightingSettings != null)
     {
         m_LightingSettings.Dispose();
     }
 }
Exemple #3
0
        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();
        }
	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();
		}
	}
Exemple #5
0
        private void CopyHumanDescriptionFromOtherModel(Avatar sourceAvatar)
        {
            SerializedObject serializedObject = ModelImporterRigEditor.GetModelImporterSerializedObject(AssetDatabase.GetAssetPath((UnityEngine.Object)sourceAvatar));

            ModelImporterRigEditor.CopyHumanDescriptionToDestination(serializedObject, this.serializedObject);
            serializedObject.Dispose();
        }
        private void CopyHumanDescriptionFromOtherModel(Avatar sourceAvatar)
        {
            string           srcAssetPath = AssetDatabase.GetAssetPath(sourceAvatar);
            SerializedObject srcImporter  = GetModelImporterSerializedObject(srcAssetPath);

            CopyHumanDescriptionToDestination(srcImporter, serializedObject);
            srcImporter.Dispose();
        }
        private void CopyHumanDescriptionFromOtherModel(Avatar sourceAvatar)
        {
            string           assetPath = AssetDatabase.GetAssetPath(sourceAvatar);
            SerializedObject modelImporterSerializedObject = ModelImporterRigEditor.GetModelImporterSerializedObject(assetPath);

            ModelImporterRigEditor.CopyHumanDescriptionToDestination(modelImporterSerializedObject, base.serializedObject);
            modelImporterSerializedObject.Dispose();
        }
Exemple #8
0
 internal void CleanupPropertyEditor()
 {
     if (m_SerializedObject != null)
     {
         m_SerializedObject.Dispose();
         m_SerializedObject = null;
     }
 }
Exemple #9
0
        private static bool DoesHumanDescriptionMatch(ModelImporter importer, ModelImporter otherImporter)
        {
            UnityEngine.Object[] objs = new UnityEngine.Object[] { importer, otherImporter };
            SerializedObject     obj2 = new SerializedObject(objs);
            bool flag = !obj2.FindProperty("m_HumanDescription").hasMultipleDifferentValues;

            obj2.Dispose();
            return(flag);
        }
Exemple #10
0
 public static void ChangeVersionControlMode(VersionControlMods vcm, AssetSerializationMods asm)
 {
     var editorSettings =
         new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/EditorSettings.asset")[0]);
     editorSettings.FindProperty("m_ExternalVersionControlSupport").stringValue = vcm.ToString().Replace("_", " ");
     editorSettings.FindProperty("m_SerializationMode").intValue = (int) asm;
     editorSettings.ApplyModifiedProperties();
     editorSettings.Dispose();
 }
Exemple #11
0
        private static bool DoesHumanDescriptionMatch(ModelImporter importer, ModelImporter otherImporter)
        {
            SerializedObject serializedObject = new SerializedObject(new UnityEngine.Object[2] {
                (UnityEngine.Object)importer, (UnityEngine.Object)otherImporter
            });
            bool flag = !serializedObject.FindProperty("m_HumanDescription").hasMultipleDifferentValues;

            serializedObject.Dispose();
            return(flag);
        }
        static bool DoesHumanDescriptionMatch(ModelImporter importer, ModelImporter otherImporter)
        {
            SerializedObject so = new SerializedObject(new Object[] { importer, otherImporter });

            so.maxArraySizeForMultiEditing = Math.Max(importer.transformPaths.Length, otherImporter.transformPaths.Length);
            SerializedProperty prop = so.FindProperty("m_HumanDescription");
            bool matches            = !prop.hasMultipleDifferentValues;

            so.Dispose();

            return(matches);
        }
 private void CleanupPropertyEditor()
 {
     if (m_OptimizedBlock != null)
     {
         m_OptimizedBlock.Dispose();
         m_OptimizedBlock = null;
     }
     if (m_SerializedObject != null)
     {
         m_SerializedObject.Dispose();
         m_SerializedObject = null;
     }
 }
        private static bool DoesHumanDescriptionMatch(ModelImporter importer, ModelImporter otherImporter)
        {
            SerializedObject serializedObject = new SerializedObject(new UnityEngine.Object[]
            {
                importer,
                otherImporter
            });
            SerializedProperty serializedProperty = serializedObject.FindProperty("m_HumanDescription");
            bool result = !serializedProperty.hasMultipleDifferentValues;

            serializedObject.Dispose();
            return(result);
        }
        private static bool DoesHumanDescriptionMatch(ModelImporter importer, ModelImporter otherImporter)
        {
            SerializedObject serializedObject = new SerializedObject(new UnityEngine.Object[]
            {
                importer,
                otherImporter
            });

            serializedObject.maxArraySizeForMultiEditing = Math.Max(importer.transformPaths.Length, otherImporter.transformPaths.Length);
            SerializedProperty serializedProperty = serializedObject.FindProperty("m_HumanDescription");
            bool result = !serializedProperty.hasMultipleDifferentValues;

            serializedObject.Dispose();
            return(result);
        }
Exemple #16
0
            public void Dispose()
            {
                foreach (var prop in m_Properties)
                {
                    if (prop != null)
                    {
                        prop.Dispose();
                    }
                }

                m_SerializedObject.Dispose();

                m_Object           = null;
                m_SerializedObject = null;
                m_Properties       = null;
            }
		private int	GetEditorId( Object obj )
		{
			int editorId = 0;

			PropertyInfo inspectorModeInfo = typeof(UnityEditor.SerializedObject).GetProperty("inspectorMode", BindingFlags.NonPublic | BindingFlags.Instance);
			SerializedObject sObj = new SerializedObject(obj);
			inspectorModeInfo.SetValue( sObj, UnityEditor.InspectorMode.Debug, null );

			SerializedProperty sProp = sObj.FindProperty( "m_LocalIdentfierInFile" );
			if ( sProp != null )
			{
				editorId = sProp.intValue;
				sProp.Dispose();
			}

			sObj.Dispose();

			return editorId;
		}
Exemple #18
0
        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();
            }
        }
Exemple #19
0
		/// <summary> 
        /// Disconnect a property from a prefab.
        /// <param name="target">The target Object.</param>
        /// <param name="propertyPath">The target property to be disconnect.</param>
        /// </summary>
		public static void DisconnectPropertyFromPrefab (UnityEngine.Object target, string propertyPath) {
			var serialObj = new SerializedObject(target);
			var targetProperty = serialObj.FindProperty(propertyPath);

			if (targetProperty != null) {
				var endProperty = targetProperty.GetEndProperty();
				do {
					if (!targetProperty.prefabOverride) {
						switch (targetProperty.propertyType) {
							case SerializedPropertyType.Integer:
								if (targetProperty.intValue == 0)
									targetProperty.intValue = 1;
								else
									targetProperty.intValue = 0;
								break;
							case SerializedPropertyType.String:
								var stringValue = targetProperty.stringValue;
								if (stringValue.Equals(" "))
									targetProperty.stringValue = string.Empty;
								else
									targetProperty.stringValue = " ";
								break;
							case SerializedPropertyType.Float:
								if (targetProperty.floatValue == 0f)
									targetProperty.floatValue = 1f;
								else
									targetProperty.floatValue = 0f;
								break;
							case SerializedPropertyType.Boolean:
								targetProperty.boolValue = !targetProperty.boolValue;
								break;
							case SerializedPropertyType.Color:
								targetProperty.colorValue = ChangeColor(targetProperty.colorValue);
								break;
							case SerializedPropertyType.Enum:
								targetProperty.enumValueIndex = targetProperty.enumValueIndex + 1;
								break;
							case SerializedPropertyType.ObjectReference:
								if (targetProperty.objectReferenceValue == null || targetProperty.objectReferenceValue != target)
									targetProperty.objectReferenceValue = target;
								else
									targetProperty.objectReferenceValue = null;
								break;
						}
					}
				} while (targetProperty.Next(true) && !SerializedProperty.EqualContents(targetProperty, endProperty));

				serialObj.ApplyModifiedProperties();
				PrefabUtility.RecordPrefabInstancePropertyModifications(target);
				// targetProperty.Dispose();

				// Edit array size == 0
				serialObj.Update();
				targetProperty = serialObj.FindProperty(propertyPath);
				endProperty = targetProperty.GetEndProperty();
				do {
					if (!targetProperty.prefabOverride && targetProperty.propertyType == SerializedPropertyType.ArraySize)
						targetProperty.arraySize = 1;
				} while (targetProperty.Next(true) && !SerializedProperty.EqualContents(targetProperty, endProperty));	

				serialObj.ApplyModifiedProperties();
				PrefabUtility.RecordPrefabInstancePropertyModifications(target);
				targetProperty.Dispose();
			}
			serialObj.Dispose();
		}
	void ClearMaterialCrum(Material mat) {

		var so = new SerializedObject(mat);

		so.Update();

		var textures = so.FindProperty("m_SavedProperties.m_TexEnvs");
		ClearMaterialArray(PropType.Texture, textures);

		var floats = so.FindProperty("m_SavedProperties.m_Floats");
		ClearMaterialArray(PropType.Float, floats);

		var colors = so.FindProperty("m_SavedProperties.m_Colors");
		ClearMaterialArray(PropType.Color, colors);
		so.ApplyModifiedProperties();

		so.Dispose();

	}
		private static bool DoesHumanDescriptionMatch(ModelImporter importer, ModelImporter otherImporter)
		{
			SerializedObject serializedObject = new SerializedObject(new UnityEngine.Object[]
			{
				importer,
				otherImporter
			});
			SerializedProperty serializedProperty = serializedObject.FindProperty("m_HumanDescription");
			bool result = !serializedProperty.hasMultipleDifferentValues;
			serializedObject.Dispose();
			return result;
		}
 void EditElement(CGElement element,CreateGUI main)
 {
     GUILayout.BeginHorizontal("helpbox");
     GUILayout.Label(element.GetType()+" - "+element.name+"","BoldLabel");
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal("helpbox");
     element.name = EditorGUILayout.TextField("Name",element.name);
     GUILayout.EndHorizontal();
     GUILayout.BeginVertical();
     FieldInfo [] fields = element.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
     foreach(FieldInfo fi in fields){
         if(!fi.IsNotSerialized){
             GUILayout.BeginHorizontal("helpbox");
             char[] propertyName = fi.Name.ToCharArray();
             if(propertyName.Length>0) propertyName[0] = char.ToUpper(propertyName[0]);
             SerializedObject tempSerializedObj = new SerializedObject(element);
             SerializedProperty targetProperty = tempSerializedObj.FindProperty(fi.Name);
             EditorGUILayout.PropertyField(targetProperty,true);
             tempSerializedObj.ApplyModifiedProperties();
             tempSerializedObj.Dispose();
             GUILayout.EndHorizontal();
         }
     }
     GUILayout.EndVertical();
     GUILayout.Space(10);
 }
 private static bool DoesHumanDescriptionMatch(ModelImporter importer, ModelImporter otherImporter)
 {
     UnityEngine.Object[] objs = new UnityEngine.Object[] { importer, otherImporter };
     SerializedObject obj2 = new SerializedObject(objs);
     bool flag = !obj2.FindProperty("m_HumanDescription").hasMultipleDifferentValues;
     obj2.Dispose();
     return flag;
 }
        static void SetStartStateContextMenu( object obj )
        {
            State state = obj as State;

            ArborFSMInternal stateMachine = state.stateMachine;

            SerializedObject serializedObject = new SerializedObject( stateMachine );

            serializedObject.Update();

            SerializedProperty startStateIDPropery = serializedObject.FindProperty( "_StartStateID" );

            startStateIDPropery.intValue = state.stateID;

            serializedObject.ApplyModifiedProperties();

            serializedObject.Dispose();
        }
Exemple #25
0
	/// <summary>
	/// Sets the name of the root motion bone.
	/// </summary>
	/// <param name="imp">Imp.</param>
	/// <param name="szValue">Size value.</param>
	public static void 		ApplyRootMotionBoneName(ModelImporter imp, string szValue)
	{
		SerializedObject impSO 			= new SerializedObject(imp);
		SerializedProperty rootMotion 	= impSO.FindProperty(PType.m_HumanDescription.ToString()).FindPropertyRelative(PType.m_RootMotionBoneName.ToString());
		rootMotion.stringValue 			= szValue;

		SerializedProperty type			= impSO.FindProperty(PType.m_AnimationType.ToString());
		type.enumValueIndex				= 2;

		impSO.ApplyModifiedProperties();
		impSO.Dispose();
	}
        public static void StateTitlebar( Rect position,State state )
        {
            int controlId = GUIUtility.GetControlID(s_StateTitlebarHash,EditorGUIUtility.native, position);

            Event current = Event.current;

            EventType typeForControl = current.GetTypeForControl(controlId);

            //		position.x -= 4;
            //		position.width += 3+5;
            position.y -= 5;
            position.height += 5+3;

            Rect namePosition = s_StateTitlebar.padding.Remove(position);
            namePosition.height = 16;
            namePosition.width -= 16+8;

            Rect popupPosition = new Rect( namePosition.xMax+8 , namePosition.y , 16 , namePosition.height );

            if( current.type == EventType.Repaint )
            {
                s_StateTitlebar.Draw( position,GUIContent.none,controlId,false );
            }

            string name = EditorGUI.TextField( namePosition,state.name );
            if( name != state.name )
            {
                ArborFSMInternal stateMachine = state.stateMachine;

                Undo.RecordObject( stateMachine,"Rename State" );

                state.name = name;

                EditorUtility.SetDirty( stateMachine );
            }

            switch (typeForControl)
            {
            case EventType.MouseDown:
                if( popupPosition.Contains( current.mousePosition ) )
                {
                    GenericMenu menu = new GenericMenu();

                    SerializedObject serializedObject = new SerializedObject( state.stateMachine );

                    SerializedProperty startStateIDPropery = serializedObject.FindProperty( "_StartStateID" );

                    if( startStateIDPropery.intValue == state.stateID )
                    {
                        menu.AddDisabledItem( GetTextContent("Set Start State") );
                    }
                    else
                    {
                        menu.AddItem( GetTextContent("Set Start State"),false,SetStartStateContextMenu,state );
                    }

                    BehaviourMenuUtility.AddMenu( state,menu );

                    if( _CopyBehaviour != null )
                    {
                        menu.AddItem( GetTextContent("Paste Behaviour"),false,PasteBehaviourToStateContextMenu,state );
                    }
                    else
                    {
                        menu.AddDisabledItem( GetTextContent("Paste Behaviour") );
                    }

                    serializedObject.Dispose();

                    menu.DropDown( popupPosition );

                    current.Use();
                }
                break;
            case EventType.Repaint:
                s_BehaviourTitlebarText.Draw(popupPosition, s_ContextPopupContent, controlId, false);
                break;
            }
        }
        static void CopyBehaviour( StateBehaviour source,StateBehaviour dest,bool checkStateLink )
        {
            if( dest == null )
            {
                return;
            }

            ArborFSMInternal stateMachine = dest.stateMachine;
            int stateID = dest.stateID;
            bool expanded = dest.expanded;

            EditorUtility.CopySerialized( source,dest );

            dest.expanded = expanded;

            SerializedObject serializedObject = new SerializedObject( dest );

            serializedObject.Update();

            SerializedProperty stateMachineProperty = serializedObject.FindProperty( "_StateMachine" );
            stateMachineProperty.objectReferenceValue = stateMachine;

            SerializedProperty stateIDProperty = serializedObject.FindProperty( "_StateID" );
            stateIDProperty.intValue = stateID;

            if( checkStateLink )
            {
                SerializedProperty iterator = serializedObject.GetIterator();
                while( iterator.NextVisible(true) )
                {
                    if( iterator.type == "StateLink" )
                    {
                        if( iterator.isArray )
                        {
                            for( int i=0;i<iterator.arraySize;i++ )
                            {
                                SerializedProperty stateLinkProperty = iterator.GetArrayElementAtIndex( i );

                                SerializedProperty property = stateLinkProperty.FindPropertyRelative( "stateID" );
                                if( property.intValue == stateID || stateMachine != source.stateMachine || stateMachine.GetStateFromID( property.intValue ) == null )
                                {
                                    property.intValue = 0;
                                }
                            }
                        }
                        else
                        {
                            SerializedProperty property = iterator.FindPropertyRelative( "stateID" );
                            if( property.intValue == stateID || stateMachine != source.stateMachine || stateMachine.GetStateFromID( property.intValue ) == null )
                            {
                                property.intValue = 0;
                            }
                        }
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();
            serializedObject.Dispose();
        }
Exemple #28
0
        /// <summary> 
        /// Paste the state in StateUtility.stateToPaste in the supplied fsm.
        /// <param name="gameObject">The target gameObject.</param>
        /// <param name="originalStates">The original states.</param>
        /// <param name="parent">Optionally parent for the cloned states.</param>
        /// </summary>
        public static void CloneStates (GameObject gameObject, InternalStateBehaviour[] originalStates, ParentBehaviour parent) {
            if (gameObject != null && originalStates != null && originalStates.Length > 0) {
                var orginalClone = new Dictionary<InternalStateBehaviour, InternalStateBehaviour>();
                var originalFsm = parent != null ? originalStates[0].parent as InternalStateMachine : null;
                var newFsm = parent as InternalStateMachine;
                InternalStateBehaviour startState = null, concurrentState = null;
                InternalAnyState anyState = null;

                // Copy blackboard data?
                var newBlackboard = gameObject.GetComponent<InternalBlackboard>();
                if (newBlackboard == null) {
                    // Get the original blackboard
                    InternalBlackboard originalBlackboard = originalStates[0].GetComponent<InternalBlackboard>();

                    #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2
                    Undo.RegisterSceneUndo("Paste State");
                    // Create the new blacbkoard
                    newBlackboard = gameObject.AddComponent(originalBlackboard.GetType()) as InternalBlackboard;
                    #else
                    // Create the new blacbkoard
                    newBlackboard = gameObject.AddComponent(originalBlackboard.GetType()) as InternalBlackboard;
                    if (newBlackboard != null)
                        Undo.RegisterCreatedObjectUndo(newBlackboard, "Paste State");
                    #endif

                    // Copy serialized values
                    EditorUtility.CopySerialized(originalBlackboard, newBlackboard);
                }

                foreach (InternalStateBehaviour state in originalStates) {
                    // Don't clone AnyState in StateMachines
                    if (state != null && (newFsm == null || !(state is InternalAnyState) || newFsm.anyState == null)) {
                        #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2
                        Undo.RegisterSceneUndo("Paste State");
                        // Create a new state
                        var newState = gameObject.AddComponent(state.GetType()) as InternalStateBehaviour;
                        #else
                        // Create a new state
                        var newState = gameObject.AddComponent(state.GetType()) as InternalStateBehaviour;
                        if (newState != null)
                            Undo.RegisterCreatedObjectUndo(newState, "Paste State");
                        #endif

                        if (newState != null) {
                            // Store state
                            orginalClone.Add(state, newState);

                            // Copy serialized values
                            EditorUtility.CopySerialized(state, newState);
                            
                            // Update blackboard
                            if (state.gameObject != newState.gameObject) {
                                var serialObj = new SerializedObject(newState);
                                serialObj.FindProperty("m_Blackboard").objectReferenceValue = newBlackboard;
                                serialObj.ApplyModifiedProperties();
                                serialObj.Dispose();
                            }

                            // Update the AnyState, StartState and ConcurrentState
                            if (newState is InternalStateMachine) {
                                var fsm = newState as InternalStateMachine;
                                fsm.startState = null;
                                fsm.concurrentState = null;
                                fsm.anyState = null;
                            }

                            EditorUtility.SetDirty(newState);

                            // Set new parent
                            if (parent != null) {
                                newState.parent = parent;

                                // Update position
                                if (parent == state.parent)
                                    newState.position += new Vector2(20f, 20f);
                            }
                            else
                                newState.parent = null;

                            // Saves state and sets dirty flag
                            INodeOwner nodeOwner = newState as INodeOwner;
                            if (nodeOwner != null) {
                                nodeOwner.LoadNodes();
                                StateUtility.SetDirty(nodeOwner);
                            }
                            else
                                EditorUtility.SetDirty(newState);

                            // Try to get the StartState, AnyState and ConcurrentState
                            if (originalFsm != null) {
                                if (originalFsm.startState == state)
                                    startState = newState;
                                if (anyState == null)
                                    anyState = newState as InternalAnyState;
                                if (originalFsm.concurrentState == state)
                                    concurrentState = newState;
                            }
                        }
                    }
                }

                // Set StartState, AnyState and ConcurrentState
                if (newFsm != null) {
                    if (newFsm.startState == null)
                        newFsm.startState = startState;
                    if (newFsm.anyState == null)
                        newFsm.anyState = anyState;
                    if (newFsm.concurrentState == null)
                        newFsm.concurrentState = concurrentState;
                    EditorUtility.SetDirty(newFsm);
                }

                // Try to update the transitions' destination
                foreach (KeyValuePair<InternalStateBehaviour, InternalStateBehaviour> pair in orginalClone) {
                    InternalStateBehaviour state = pair.Key;
                    InternalStateBehaviour newState = pair.Value;

                    // Update the newState transition
                    for (int i = 0; i < newState.transitions.Length && i < state.transitions.Length; i++) {
                        // The original destination is valid?
                        if (state.transitions[i].destination != null && orginalClone.ContainsKey(state.transitions[i].destination))
                            newState.transitions[i].destination = orginalClone[state.transitions[i].destination];
                    }

                    if (newState is ParentBehaviour) {
                        var stateAsParent = state as ParentBehaviour;
                        
                        // Removes the newState from the children state to avoid an infinite loop
                        List<InternalStateBehaviour> children = stateAsParent.states;
                        if (children.Contains(newState))
                            children.Remove(newState);

                        StateUtility.CloneStates(newState.gameObject, children.ToArray(), newState as ParentBehaviour);
                    }

                    EditorUtility.SetDirty(newState);
                }

                EditorUtility.SetDirty(gameObject);
            }
        }
		/// <summary>
		/// Populate a reference map that goes SerializedProperty -> Object
		/// </summary>
		/// <param name="map">The map to populate entries into</param>
		/// <param name="allObjects">The objects to read in order to determine the references</param>
		private static void PopulateReferenceMap( List<KeyValuePair<SerializedProperty, Object>> map, IEnumerable<Object> allObjects )
		{
			foreach( var obj in allObjects )
			{
				// Flags that indicate we aren't rooted in the scene
				if ( obj.hideFlags == HideFlags.HideAndDontSave )
					continue;

				SerializedObject so = new SerializedObject(obj);
				SerializedProperty sp = so.GetIterator();

                bool bCanDispose = true;
				while ( sp.Next(true) )
				{
					// Only care about object references
					if ( sp.propertyType != SerializedPropertyType.ObjectReference )
						continue;

					// Skip the nulls
					if ( sp.objectReferenceInstanceIDValue == 0 )
						continue;

					map.Add( new KeyValuePair<SerializedProperty,Object>(sp.Copy(), sp.objectReferenceValue) );
                    bCanDispose = false;
				}

                // This will help relieve memory pressure (thanks llde_chris)
                if ( bCanDispose )
                {
                    sp.Dispose();
                    so.Dispose();
                }
			}
		}
 void OnDisable()
 {
     m_Object.Dispose();
     m_Object = null;
 }
 private static bool DoesHumanDescriptionMatch(ModelImporter importer, ModelImporter otherImporter)
 {
   SerializedObject serializedObject = new SerializedObject(new UnityEngine.Object[2]{ (UnityEngine.Object) importer, (UnityEngine.Object) otherImporter });
   bool flag = !serializedObject.FindProperty("m_HumanDescription").hasMultipleDifferentValues;
   serializedObject.Dispose();
   return flag;
 }