//serialization constructor /*protected Object2PropertiesMapping(SerializationInfo info,StreamingContext context) { * savedStates = (OrderedDictionary<int,SavedState>)info.GetValue("savedStates",typeof(OrderedDictionary<int,SavedState>)); * isParentObj = info.GetBoolean("isParentObj"); * parentMapping = (Object2PropertiesMapping)info.GetValue("parentMapping",typeof(Object2PropertiesMapping)); * childNo = info.GetInt32("childNo"); * prefabLoadPath = info.GetString("prefabLoadPath"); * lastChangedFrame = info.GetInt32("lastChangedFrame"); * firstChangedFrame = info.GetInt32("firstChangedFrame"); * try { * childIdentificationMode = (ChildIdentificationMode)info.GetValue("childIdentificationMode",typeof(ChildIdentificationMode)); * } catch (SerializationException) { * //file was recorded using old version of this plugin * childIdentificationMode = ChildIdentificationMode.IDENTIFY_BY_ORDER; * } * try { * gameObjectName = info.GetString("gameObjectName"); * } catch (SerializationException) { * //file was recorded using old version of this plugin * childIdentificationMode = ChildIdentificationMode.IDENTIFY_BY_ORDER; * gameObjectName = "name_untraceable"; * } * }*/ public Object2PropertiesMapping(GameObject go, bool isParent, Object2PropertiesMapping parentMapping, int childNo, string prefabLoadPath, ChildIdentificationMode childIdentificationMode) : this(go, isParent, parentMapping, childNo, prefabLoadPath) { this.childIdentificationMode = childIdentificationMode; if (isParentObj) // if gameObject is a parent.. //..instantiate mappings for all children too { Transform[] allChildren = gameObject.GetComponentsInChildren <Transform>(); for (int i = 0; i < allChildren.Length; i++) { GameObject child = allChildren[i].gameObject; if (!EZReplayManager.get.gOs2propMappings.ContainsKey(child)) { if (child != gameObject) { EZReplayManager.get.gOs2propMappings.Add(child, new Object2PropertiesMapping(child, false, this, i, "", childIdentificationMode)); } } else if (EZReplayManager.showHints) { Debug.Log("EZReplayManager HINT: GameObject '" + child + "' is already being recorded. Will not be marked for recording again."); } } } }
public Object2PropertiesMapping(GameObject go,bool isParent, Object2PropertiesMapping parentMapping, int childNo, string prefabLoadPath, ChildIdentificationMode childIdentificationMode) : this(go,isParent,parentMapping, childNo, prefabLoadPath) { this.childIdentificationMode = childIdentificationMode; if (isParentObj) { // if gameObject is a parent.. //..instantiate mappings for all children too Transform[] allChildren = gameObject.GetComponentsInChildren<Transform>() ; for(int i=0;i<allChildren.Length;i++) { GameObject child = allChildren[i].gameObject; if (!EZReplayManager.get.gOs2propMappings.ContainsKey(child)) { if (child!=gameObject) EZReplayManager.get.gOs2propMappings.Add(child, new Object2PropertiesMapping(child,false,this,i,"",childIdentificationMode)); } else if (EZReplayManager.showHints) MonoBehaviour.print("EZReplayManager HINT: GameObject '"+child+"' is already being recorded. Will not be marked for recording again."); } } }
//serialization constructor protected Object2PropertiesMapping(SerializationInfo info, StreamingContext context) { savedStates = (SerializableDictionary <int, SavedState>)info.GetValue("savedStates", typeof(SerializableDictionary <int, SavedState>)); isParentObj = info.GetBoolean("isParentObj"); parentMapping = (Object2PropertiesMapping)info.GetValue("parentMapping", typeof(Object2PropertiesMapping)); childNo = info.GetInt32("childNo"); prefabLoadPath = info.GetString("prefabLoadPath"); lastChangedFrame = info.GetInt32("lastChangedFrame"); firstChangedFrame = info.GetInt32("firstChangedFrame"); try { childIdentificationMode = (ChildIdentificationMode)info.GetValue("childIdentificationMode", typeof(ChildIdentificationMode)); } catch (SerializationException e) { //file was recorded using old version of this plugin childIdentificationMode = ChildIdentificationMode.IDENTIFY_BY_ORDER; } try { gameObjectName = info.GetString("gameObjectName"); } catch (SerializationException e) { //file was recorded using old version of this plugin childIdentificationMode = ChildIdentificationMode.IDENTIFY_BY_ORDER; gameObjectName = "name_untraceable"; } }
//private object precachingLock = new object(); //mark an object for recording, can be done while recording and while game is running, but not while replaying a recording //v1.5: Specify "prefabLoadPath" if you know exactly where "go" is located as a prefab in "Resources" directory. public void mark4Recording(GameObject go, string prefabLoadPath, ChildIdentificationMode childIdentificationMode) { if (currentMode == ViewMode.LIVE) { if (currentAction != ActionMode.PLAY) { if (!gOs2propMappings.ContainsKey(go)) { //if not already existant if (!precacheGameobjects) { //if you dont need to precache: gOs2propMappings.Add(go, new Object2PropertiesMapping(go, true, null, 0, "", childIdentificationMode)); } else { //lock (precachingLock) { //prepare to precache: prefabLoadPath = generateCachePath(go.name, prefabLoadPath); #if UNITY_EDITOR || !( UNITY_DASHBOARD_WIDGET || UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_WII || UNITY_IPHONE || UNITY_ANDROID || UNITY_PS3 || UNITY_XBOX360 || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY || UNITY_WP8 || UNITY_METRO || UNITY_WINRT) cacheGOinResources(go, prefabLoadPath); Transform[] children = go.transform.GetComponentsInChildren<Transform>(); foreach (Transform t in children) { if (t != go.transform) cacheGOinResources(t.gameObject, ""); } #endif //add to map gOs2propMappings.Add(go, new Object2PropertiesMapping(go, true, null, 0, prefabLoadPath, childIdentificationMode)); //} } if (!markedGameObjects.Contains(go)) { //still needed? markedGameObjects.Add(go); } } else if (showHints) print("EZReplayManager HINT: GameObject '" + go + "' has already been marked for recording."); } else if (showWarnings) Debug.LogWarning("EZReplayManager WARNING: You cannot mark GameObject '" + go + "' for recording while a recording is being played."); } else { if (showWarnings) Debug.LogWarning("EZReplayManager WARNING: You cannot mark GameObject '" + go + "' for recording while in replay mode."); } }
//private object precachingLock = new object(); //mark an object for recording, can be done while recording and while game is running, but not while replaying a recording //v1.5: Specify "prefabLoadPath" if you know exactly where "go" is located as a prefab in "Resources" directory. public void mark4Recording(GameObject go, string prefabLoadPath, ChildIdentificationMode childIdentificationMode) { if (currentMode == ViewMode.LIVE) { if (currentAction != ActionMode.PLAY) { if (!gOs2propMappings.ContainsKey(go)) //if not already existant { if (!precacheGameobjects) { //if you dont need to precache: gOs2propMappings.Add(go, new Object2PropertiesMapping(go, true, null, 0, "", childIdentificationMode)); } else { //lock (precachingLock) { //prepare to precache: prefabLoadPath = generateCachePath(go.name, prefabLoadPath); #if UNITY_EDITOR || !(UNITY_STANDALONE_OSX || UNITY_DASHBOARD_WIDGET || UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_WII || UNITY_IPHONE || UNITY_ANDROID || UNITY_PS3 || UNITY_XBOX360 || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY || UNITY_WP8 || UNITY_METRO) cacheGOinResources(go, prefabLoadPath); Transform[] children = go.transform.GetComponentsInChildren <Transform>(); foreach (Transform t in children) { if (t != go.transform) { cacheGOinResources(t.gameObject, ""); } } #endif //add to map gOs2propMappings.Add(go, new Object2PropertiesMapping(go, true, null, 0, prefabLoadPath, childIdentificationMode)); //} } if (!markedGameObjects.Contains(go)) //still needed? { markedGameObjects.Add(go); } } else if (showHints) { print("EZReplayManager HINT: GameObject '" + go + "' has already been marked for recording."); } } else if (showWarnings) { print("EZReplayManager WARNING: You cannot mark GameObject '" + go + "' for recording while a recording is being played."); } } else { if (showWarnings) { print("EZReplayManager WARNING: You cannot mark GameObject '" + go + "' for recording while in replay mode."); } } }
//serialization constructor protected Object2PropertiesMapping(SerializationInfo info,StreamingContext context) { savedStates = (SerializableDictionary<int,SavedState>)info.GetValue("savedStates",typeof(SerializableDictionary<int,SavedState>)); isParentObj = info.GetBoolean("isParentObj"); parentMapping = (Object2PropertiesMapping)info.GetValue("parentMapping",typeof(Object2PropertiesMapping)); childNo = info.GetInt32("childNo"); prefabLoadPath = info.GetString("prefabLoadPath"); lastChangedFrame = info.GetInt32("lastChangedFrame"); firstChangedFrame = info.GetInt32("firstChangedFrame"); try { childIdentificationMode = (ChildIdentificationMode)info.GetValue("childIdentificationMode",typeof(ChildIdentificationMode)); } catch (SerializationException e) { //file was recorded using old version of this plugin childIdentificationMode = ChildIdentificationMode.IDENTIFY_BY_ORDER; } try { gameObjectName = info.GetString("gameObjectName"); } catch (SerializationException e) { //file was recorded using old version of this plugin childIdentificationMode = ChildIdentificationMode.IDENTIFY_BY_ORDER; gameObjectName = "name_untraceable"; } }