Ejemplo n.º 1
0
    LoadData(MecanimEventData data)
    {
        var retData = new Dictionary <int, Dictionary <int, Dictionary <int, List <MecanimEvent> > > >();

        var entries = data.data;

        foreach (var entry in entries)
        {
            var animatorControllerId = entry.animatorController.GetInstanceID();

            if (!retData.ContainsKey(animatorControllerId))
            {
                retData[animatorControllerId] = new Dictionary <int, Dictionary <int, List <MecanimEvent> > >();
            }

            if (!retData[animatorControllerId].ContainsKey(entry.layer))
            {
                retData[animatorControllerId][entry.layer] = new Dictionary <int, List <MecanimEvent> >();
            }

            retData[animatorControllerId][entry.layer][entry.stateNameHash] = new List <MecanimEvent>(entry.events);
        }

        return(retData);
    }
Ejemplo n.º 2
0
 private static void LoadGlobalData()
 {
     if (MecanimEventManager.eventDataSources == null)
     {
         return;
     }
     MecanimEventManager.globalLoadedData = new Dictionary <int, Dictionary <int, Dictionary <int, List <MecanimEvent> > > >();
     MecanimEventData[] array = MecanimEventManager.eventDataSources;
     for (int i = 0; i < array.Length; i++)
     {
         MecanimEventData mecanimEventData = array[i];
         if (!(mecanimEventData == null))
         {
             MecanimEventDataEntry[] data   = mecanimEventData.data;
             MecanimEventDataEntry[] array2 = data;
             for (int j = 0; j < array2.Length; j++)
             {
                 MecanimEventDataEntry mecanimEventDataEntry = array2[j];
                 int instanceID = mecanimEventDataEntry.animatorController.GetInstanceID();
                 if (!MecanimEventManager.globalLoadedData.ContainsKey(instanceID))
                 {
                     MecanimEventManager.globalLoadedData[instanceID] = new Dictionary <int, Dictionary <int, List <MecanimEvent> > >();
                 }
                 if (!MecanimEventManager.globalLoadedData[instanceID].ContainsKey(mecanimEventDataEntry.layer))
                 {
                     MecanimEventManager.globalLoadedData[instanceID][mecanimEventDataEntry.layer] = new Dictionary <int, List <MecanimEvent> >();
                 }
                 MecanimEventManager.globalLoadedData[instanceID][mecanimEventDataEntry.layer][mecanimEventDataEntry.stateNameHash] = new List <MecanimEvent>(mecanimEventDataEntry.events);
             }
         }
     }
 }
Ejemplo n.º 3
0
	public static void SetEventDataSource(MecanimEventData dataSource) {
		if (dataSource != null) {
			eventDataSources = new MecanimEventData[1];
			eventDataSources[0] = dataSource;
			
			LoadDataInGame();
		}
	}
	public static void SetEventDataSource(MecanimEventData[] dataSources) {
		if (dataSources != null) {
			
			eventDataSources = dataSources;
			
			LoadGlobalData();
		}
	}
	public static void SetEventDataSource(MecanimEventData dataSource) {
		if (dataSource != null) {
			eventDataSources = new MecanimEventData[1];
			eventDataSources[0] = dataSource;
			
			LoadGlobalData();
		}
	}
Ejemplo n.º 6
0
 public static void SetEventDataSource(MecanimEventData dataSource)
 {
     if (dataSource != null)
     {
         MecanimEventManager.eventDataSources    = new MecanimEventData[1];
         MecanimEventManager.eventDataSources[0] = dataSource;
         MecanimEventManager.LoadGlobalData();
     }
 }
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal(); {
            EditorGUI.BeginChangeCheck();

            transferFrom = EditorGUILayout.ObjectField("Transfer From", transferFrom, typeof(MecanimEventData), false) as MecanimEventData;

            if (EditorGUI.EndChangeCheck())
            {
                toggleTable = new Dictionary <Object, bool>();
            }

            transferTo = EditorGUILayout.ObjectField("Transfer To", transferTo, typeof(MecanimEventData), false) as MecanimEventData;
        }
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal(); {
            EditorGUILayout.BeginVertical("Window", GUILayout.MaxWidth(position.width / 2));
            leftWindowScroll = EditorGUILayout.BeginScrollView(leftWindowScroll); {
                DisplayDataSource();
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Window", GUILayout.MaxWidth(position.width / 2));
            rightWindowScroll = EditorGUILayout.BeginScrollView(rightWindowScroll); {
                DisplayDataDest();
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal(); {
            GUILayout.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(transferFrom == null || transferTo == null ||
                                         transferFrom.GetInstanceID() == transferTo.GetInstanceID());

            if (GUILayout.Button("Transfer", GUILayout.Width(80), GUILayout.Height(30)))
            {
                Transfer();
            }

            EditorGUI.EndDisabledGroup();

            if (GUILayout.Button("Cancel", GUILayout.Width(80), GUILayout.Height(30)))
            {
                Close();
            }
        }
        EditorGUILayout.EndHorizontal();
    }
    private void LoadData()
    {
        MecanimEventData dataSource = target as MecanimEventData;

        data = new Dictionary <UnityEditor.Animations.AnimatorController, Dictionary <int, Dictionary <int, List <MecanimEvent> > > >();

        if (dataSource.data == null || dataSource.data.Length == 0)
        {
            return;
        }

        foreach (MecanimEventDataEntry entry in dataSource.data)
        {
            UnityEditor.Animations.AnimatorController animatorController = entry.animatorController as UnityEditor.Animations.AnimatorController;

            if (animatorController == null)
            {
                return;
            }

            if (!data.ContainsKey(animatorController))
            {
                data[animatorController] = new Dictionary <int, Dictionary <int, List <MecanimEvent> > >();
            }

            if (!data[animatorController].ContainsKey(entry.layer))
            {
                data[animatorController][entry.layer] = new Dictionary <int, List <MecanimEvent> >();
            }

            List <MecanimEvent> events = new List <MecanimEvent>();

            if (entry.events != null)
            {
                foreach (MecanimEvent e in entry.events)
                {
                    events.Add(new MecanimEvent(e));
                }
            }

            data[animatorController][entry.layer][entry.stateNameHash] = events;
        }
    }
    public void SaveData()
    {
        MecanimEventData targetData = target as MecanimEventData;

        Undo.RecordObject(target, "Mecanim Event Data");

        List <MecanimEventDataEntry> entries = new List <MecanimEventDataEntry>();

        foreach (UnityEditor.Animations.AnimatorController controller in data.Keys)
        {
            foreach (int layer in data[controller].Keys)
            {
                foreach (int stateNameHash in data[controller][layer].Keys)
                {
                    if (data[controller][layer][stateNameHash].Count == 0)
                    {
                        continue;
                    }

                    if (!IsValidState(controller.GetInstanceID(), layer, stateNameHash))
                    {
                        continue;
                    }

                    MecanimEventDataEntry entry = new MecanimEventDataEntry();
                    entry.animatorController = controller;
                    entry.layer         = layer;
                    entry.stateNameHash = stateNameHash;
                    entry.events        = data[controller][layer][stateNameHash].ToArray();;

                    entries.Add(entry);
                }
            }
        }

        targetData.data = entries.ToArray();

        EditorUtility.SetDirty(target);
    }
Ejemplo n.º 10
0
 public void SetData(MecanimEventData data)
 {
     this.data  = data;
     loadedData = MecanimEventManager.LoadData(data);
 }
Ejemplo n.º 11
0
 public void Initialize(RuntimeAnimatorController animatorController, MecanimEventData mecanimEventData)
 {
     this.animatorController = animatorController;
     this.data = mecanimEventData;
     Initialize();
 }
	void OnGUI() {
		
		EditorGUILayout.BeginHorizontal(); {
		
			EditorGUI.BeginChangeCheck();
			
			transferFrom = EditorGUILayout.ObjectField("Transfer From", transferFrom, typeof(MecanimEventData), false) as MecanimEventData;
			
			if (EditorGUI.EndChangeCheck()) {
				toggleTable = new Dictionary<Object, bool>();
			}
			
			transferTo = EditorGUILayout.ObjectField("Transfer To", transferTo, typeof(MecanimEventData), false) as MecanimEventData;
			
		}
		EditorGUILayout.EndHorizontal();
	
		
		EditorGUILayout.BeginHorizontal(); {
			
			EditorGUILayout.BeginVertical("Window", GUILayout.MaxWidth(position.width/2));
			leftWindowScroll = EditorGUILayout.BeginScrollView(leftWindowScroll); {
			
				DisplayDataSource();
				
			}
			EditorGUILayout.EndScrollView();
			EditorGUILayout.EndVertical();	
			
			EditorGUILayout.BeginVertical("Window", GUILayout.MaxWidth(position.width/2));
			rightWindowScroll = EditorGUILayout.BeginScrollView(rightWindowScroll); {
			
				DisplayDataDest();
				
			}
			EditorGUILayout.EndScrollView();
			EditorGUILayout.EndVertical();	
			
		}
		EditorGUILayout.EndHorizontal();
		
		
		EditorGUILayout.BeginHorizontal(); {
			
			GUILayout.FlexibleSpace();
			
			EditorGUI.BeginDisabledGroup(transferFrom == null || transferTo == null || 
											transferFrom.GetInstanceID() == transferTo.GetInstanceID());
			
			if (GUILayout.Button("Transfer", GUILayout.Width(80), GUILayout.Height(30))) {
				Transfer();
			}
			
			EditorGUI.EndDisabledGroup();
			
			if (GUILayout.Button("Cancel", GUILayout.Width(80), GUILayout.Height(30))) {
				Close();
			}
		}
		EditorGUILayout.EndHorizontal();
	}
	public static Dictionary<int, Dictionary<int, Dictionary<int, List<MecanimEvent>>>> LoadData(MecanimEventData data)
	{
		Dictionary<int, Dictionary<int, Dictionary<int, List<MecanimEvent>>>> retData = new Dictionary<int, Dictionary<int, Dictionary<int, List<MecanimEvent>>>>();
		
		MecanimEventDataEntry[] entries = data.data;
		
		foreach(MecanimEventDataEntry entry in entries) {
			int animatorControllerId = entry.animatorController.GetInstanceID();
			
			if (!retData.ContainsKey(animatorControllerId))
				retData[animatorControllerId] = new Dictionary<int, Dictionary<int, List<MecanimEvent>>>();
			
			if (!retData[animatorControllerId].ContainsKey(entry.layer)) {
				retData[animatorControllerId][entry.layer] = new Dictionary<int, List<MecanimEvent>>();
			}
			
			retData[animatorControllerId][entry.layer][entry.stateNameHash] = new List<MecanimEvent>(entry.events);
		}

		return retData;
	}
Ejemplo n.º 14
0
    public static Dictionary <int, Dictionary <int, Dictionary <int, List <MecanimEvent> > > > LoadData(MecanimEventData data)
    {
        Dictionary <int, Dictionary <int, Dictionary <int, List <MecanimEvent> > > > dictionary = new Dictionary <int, Dictionary <int, Dictionary <int, List <MecanimEvent> > > >();

        MecanimEventDataEntry[] data2 = data.data;
        foreach (MecanimEventDataEntry mecanimEventDataEntry in data2)
        {
            int instanceID = mecanimEventDataEntry.animatorController.GetInstanceID();
            if (!dictionary.ContainsKey(instanceID))
            {
                dictionary[instanceID] = new Dictionary <int, Dictionary <int, List <MecanimEvent> > >();
            }
            if (!dictionary[instanceID].ContainsKey(mecanimEventDataEntry.layer))
            {
                dictionary[instanceID][mecanimEventDataEntry.layer] = new Dictionary <int, List <MecanimEvent> >();
            }
            dictionary[instanceID][mecanimEventDataEntry.layer][mecanimEventDataEntry.stateNameHash] = new List <MecanimEvent>(mecanimEventDataEntry.events);
        }
        return(dictionary);
    }
Ejemplo n.º 15
0
    public static Dictionary <int, Dictionary <int, Dictionary <int, List <MecanimEvent> > > > LoadData(MecanimEventData data)
    {
        Dictionary <int, Dictionary <int, Dictionary <int, List <MecanimEvent> > > > dictionary = new Dictionary <int, Dictionary <int, Dictionary <int, List <MecanimEvent> > > >();

        MecanimEventDataEntry[] data2 = data.data;
        MecanimEventDataEntry[] array = data2;
        for (int i = 0; i < array.Length; i++)
        {
            MecanimEventDataEntry mecanimEventDataEntry = array[i];
            int instanceID = mecanimEventDataEntry.animatorController.GetInstanceID();
            if (!dictionary.ContainsKey(instanceID))
            {
                dictionary[instanceID] = new Dictionary <int, Dictionary <int, List <MecanimEvent> > >();
            }
            if (!dictionary[instanceID].ContainsKey(mecanimEventDataEntry.layer))
            {
                dictionary[instanceID][mecanimEventDataEntry.layer] = new Dictionary <int, List <MecanimEvent> >();
            }
            dictionary[instanceID][mecanimEventDataEntry.layer][mecanimEventDataEntry.stateNameHash] = new List <MecanimEvent>(mecanimEventDataEntry.events);
        }
        return(dictionary);
    }