protected override void OnCopyDataTo(object targetObj, ICloneOperation operation) { base.OnCopyDataTo(targetObj, operation); Renderer target = targetObj as Renderer; target.visibilityGroup = this.visibilityGroup; }
/// <summary> /// /// </summary> /// <param name="target"></param> /// <param name="operation"></param> protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); XmlData targetXml = target as XmlData; targetXml.Validate(); }
public virtual void CreateTargetObjectLate(T source, ref T target, ICloneOperation operation) { Type objType = source.GetType(); TypeInfo objTypeInfo = objType.GetTypeInfo(); target = objTypeInfo.CreateInstanceOf() as T; }
void ICloneExplicit.CopyDataTo(object targetObj, ICloneOperation operation) { Component target = targetObj as Component; target.active = this.active; this.OnCopyDataTo(targetObj, operation); }
void ICloneExplicit.CopyDataTo(object targetObj, ICloneOperation operation) { GameObject target = targetObj as GameObject; // Copy plain old data target.name = this.name; target.active = this.active; target.initState = this.initState; if (!operation.Context.PreserveIdentity) { target.identifier = this.identifier; } // Copy Components from source to target for (int i = 0; i < this.compList.Count; i++) { operation.HandleObject(this.compList[i]); } // Copy child objects from source to target if (this.children != null) { for (int i = 0; i < this.children.Count; i++) { operation.HandleObject(this.children[i]); } } // Copy referenced and child objects operation.HandleObject(this.scene, ref target.scene, true); operation.HandleObject(this.prefabLink, ref target.prefabLink, true); }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); ShaderProgram targetShader = target as ShaderProgram; targetShader.Compile(); }
/// <summary> /// /// </summary> /// <param name="target"></param> /// <param name="operation"></param> protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); CsvData targetCsv = target as CsvData; targetCsv.Parse(); }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); RenderTarget c = target as RenderTarget; c.SetupNativeRes(); }
/// <summary> /// /// </summary> /// <param name="target"></param> /// <param name="operation"></param> protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); JsonData targetJson = target as JsonData; targetJson.Parse(); }
void ICloneSurrogate.LateSetup(object source, ref object target, ICloneOperation operation) { T targetObj = target as T; this.CreateTargetObjectLate(source as T, ref targetObj, operation); target = targetObj; }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); Texture c = target as Texture; c.LoadData(this.basePixmap, this.texSizeMode); }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); Font c = target as Font; c.GenerateCharLookup(); c.GenerateTexMat(); }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { if (target is GwenControl <T> control) { base.OnCopyDataTo(target, operation); control.AttachToParent(); } }
/// <summary> /// Special version of <see cref="ICloneOperation.HandleObject"/> for cases where the target object graph alreay /// exists and it is undesireable for a source value of null to overwrite a non-null target value. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="operation"></param> /// <param name="source"></param> /// <param name="target"></param> /// <param name="dontNullifyExternal"></param> /// <returns></returns> public static void HandleObject <T>(this ICloneOperation operation, T source, ref T target, bool dontNullifyExternal) where T : class { if (object.ReferenceEquals(source, null) && dontNullifyExternal && !operation.IsTarget(target)) { return; } operation.HandleObject(source, ref target); }
void ICloneExplicit.CopyDataTo(object targetObj, ICloneOperation operation) { ExplicitCloneTestObjectA target = targetObj as ExplicitCloneTestObjectA; target.StringField = this.StringField; target.DataField = this.DataField; operation.HandleObject(this.ListField, ref target.ListField); operation.HandleObject(this.ListField2, ref target.ListField2); operation.HandleObject(this.DictField, ref target.DictField); }
void ICloneExplicit.CopyDataTo(object target, ICloneOperation operation) { operation.HandleObject(this, target); // Only assign WeakReferencedObject, if it was cloned as well. Otherwise, discard. ReferenceBehaviourTestObject testTarget = target as ReferenceBehaviourTestObject; testTarget.WeakReferencedObject = operation.GetWeakTarget(this.WeakReferencedObject); }
void ICloneExplicit.CopyDataTo(object target, ICloneOperation operation) { operation.HandleObject(this, target); // If the source objects parent was cloned as well, assign its // cloned instance to our target object. WeakReferenceTestObject testTarget = target as WeakReferenceTestObject; testTarget.Parent = operation.GetWeakTarget(this.Parent); }
/// <summary> /// Retrieves a weak-referenced target object to the specified source. Will return null if the source /// wasn't cloned itself, but referenced only. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="operation"></param> /// <param name="source"></param> /// <returns></returns> public static T GetWeakTarget <T>(this ICloneOperation operation, T source) where T : class { T target = operation.GetTarget(source); if (object.ReferenceEquals(source, target)) { return(null); } return(target); }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); DrawTechnique targetTechnique = target as DrawTechnique; if (this.compiled) { targetTechnique.Compile(); } }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); Shader targetShader = target as Shader; if (this.compiled) { targetShader.Compile(); } }
public override void CopyDataTo(IDictionary source, IDictionary target, ICloneOperation operation) { Type dictType = source.GetType(); Type[] genArgs = dictType.GenericTypeArguments; TypeInfo firstGenArgInfo = genArgs[0].GetTypeInfo(); TypeInfo secondGenArgInfo = genArgs[1].GetTypeInfo(); // Determine unwrapping behavior to provide faster / more optimized loops. bool isKeyPlainOld = firstGenArgInfo.IsDeepCopyByAssignment(); bool isValuePlainOld = secondGenArgInfo.IsDeepCopyByAssignment(); // Copy all pairs. Don't check each pair, if the Type won't be unwrapped anyway. target.Clear(); if (!isKeyPlainOld && !isValuePlainOld) { foreach (DictionaryEntry pair in source) { object keyTarget = null; object valueTarget = null; operation.HandleObject(pair.Key, ref keyTarget); operation.HandleObject(pair.Value, ref valueTarget); target.Add(keyTarget, valueTarget); } } else if (!isKeyPlainOld) { foreach (DictionaryEntry pair in source) { object keyTarget = null; operation.HandleObject(pair.Key, ref keyTarget); target.Add(keyTarget, pair.Value); } } else if (!isValuePlainOld) { foreach (DictionaryEntry pair in source) { object valueTarget = null; operation.HandleObject(pair.Value, ref valueTarget); target.Add(pair.Key, valueTarget); } } else { foreach (DictionaryEntry pair in source) { target.Add(pair.Key, pair.Value); } } }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); Font c = target as Font; c.GenerateCharLookup(); c.GeneratePixmap(); c.GenerateTexture(); c.GenerateMaterial(); c.GenerateKerningLookup(); }
protected override void OnCopyDataTo(object targetObj, ICloneOperation operation) { base.OnCopyDataTo(targetObj, operation); VelocityTracker target = targetObj as VelocityTracker; target.lastPosition = this.lastPosition; target.lastAngle = this.lastAngle; target.posDiff = this.posDiff; target.angleDiff = this.angleDiff; target.velocity = this.velocity; target.angleVelocity = this.angleVelocity; }
protected override void OnCopyDataTo(object targetObj, ICloneOperation operation) { base.OnCopyDataTo(targetObj, operation); TextRenderer target = targetObj as TextRenderer; target.blockAlign = this.blockAlign; target.colorTint = this.colorTint; operation.HandleValue(ref this.iconMat, ref target.iconMat); operation.HandleObject(this.text, ref target.text); operation.HandleObject(this.customMat, ref target.customMat); }
protected override void OnCopyDataTo(object targetObj, ICloneOperation operation) { base.OnCopyDataTo(targetObj, operation); SpriteRenderer target = targetObj as SpriteRenderer; target.rect = this.rect; target.colorTint = this.colorTint; target.rectMode = this.rectMode; target.offset = this.offset; operation.HandleValue(ref this.sharedMat, ref target.sharedMat); operation.HandleObject(this.customMat, ref target.customMat); }
void ICloneExplicit.CopyDataTo(object targetObj, ICloneOperation operation) { Source target = targetObj as Source; target.looped = this.looped; target.paused = this.paused; target.volume = this.volume; target.pitch = this.pitch; target.offset = this.offset; target.hasBeenPlayed = this.hasBeenPlayed; operation.HandleValue(ref this.sound, ref target.sound); }
protected override void OnCopyDataTo(object targetObj, ICloneOperation operation) { base.OnCopyDataTo(targetObj, operation); AnimSpriteRenderer target = targetObj as AnimSpriteRenderer; target.animFirstFrame = this.animFirstFrame; target.animFrameCount = this.animFrameCount; target.animDuration = this.animDuration; target.animLoopMode = this.animLoopMode; target.animTime = this.animTime; target.animPaused = this.animPaused; operation.HandleObject(this.customFrameSequence, ref target.customFrameSequence); }
protected override void OnCopyDataTo(object targetObj, ICloneOperation operation) { base.OnCopyDataTo(targetObj, operation); Transform target = targetObj as Transform; target.ignoreParent = this.ignoreParent; target.pos = this.pos; target.angle = this.angle; target.scale = this.scale; target.posAbs = this.posAbs; target.angleAbs = this.angleAbs; target.scaleAbs = this.scaleAbs; target.rotationDirAbs = this.rotationDirAbs; // Update absolute transformation data, because the target is relative to a different parent. target.UpdateAbs(); }
void ICloneExplicit.CopyDataTo(object targetObj, ICloneOperation operation) { GameObjectCopy target = targetObj as GameObjectCopy; // Copy plain old data target.name = this.name; target.initState = this.initState; if (!operation.Context.PreserveIdentity) { target.identifier = this.identifier; } // Copy Components from source to target for (int i = 0; i < this.compList.Count; i++) { operation.HandleObject(this.compList[i]); } // Copy child objects from source to target if (this.children != null) { for (int i = 0; i < this.children.Count; i++) { operation.HandleObject(this.children[i]); } } // Copy the objects parent scene as a weak reference, i.e. // by assignment, and only when the the scene is itself part of the // copied object graph. That way, cloning a GameObject but not its // scene will result in a clone that doesn't reference a parent scene. SceneCopy targetScene = operation.GetWeakTarget(this.scene); if (targetScene != null) { target.scene = targetScene; } // Copy the objects prefab link operation.HandleObject(this.prefabLink, ref target.prefabLink, true); }
protected override void OnCopyDataTo(object targetObj, ICloneOperation operation) { base.OnCopyDataTo(targetObj, operation); Transform target = targetObj as Transform; target.deriveAngle = this.deriveAngle; target.ignoreParent = this.ignoreParent; target.pos = this.pos; target.angle = this.angle; target.scale = this.scale; target.posAbs = this.posAbs; target.angleAbs = this.angleAbs; target.scaleAbs = this.scaleAbs; target.rotationDirAbs = this.rotationDirAbs; target.tempVel = this.tempVel; target.tempVelAbs = this.tempVelAbs; target.tempAngleVel = this.tempAngleVel; target.tempAngleVelAbs = this.tempAngleVelAbs; target.velAbs = this.velAbs; target.vel = this.vel; target.angleVel = this.angleVel; target.angleVelAbs = this.angleVelAbs; // Initialize parentTransform, because it's required for UpdateAbs but is null until OnLoaded, which will be called after applying prefabs. if (target.gameobj != null && target.gameobj.Parent != null) { target.parentTransform = target.gameobj.Parent.Transform; } // Handle parentTransform manually to prevent null-overwrites operation.HandleObject(this.parentTransform, ref target.parentTransform, true); // Update absolute transformation data, because the target is relative to a different parent. target.UpdateAbs(); }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); AbstractShader targetShader = target as AbstractShader; if (this.compiled) targetShader.Compile(); }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { }
void ICloneExplicit.CopyDataTo(object targetObj, ICloneOperation operation) { }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); Font c = target as Font; c.ReloadData(); }
protected override void OnCopyDataTo(object targetObj, ICloneOperation operation) { base.OnCopyDataTo(targetObj, operation); RigidBody target = targetObj as RigidBody; // If we're cloning an initialized RigidBody, shut down the targets physics body. bool wasInitialized = target.bodyInitState == InitState.Initialized; if (wasInitialized) target.Shutdown(); target.bodyType = this.bodyType; target.linearDamp = this.linearDamp; target.angularDamp = this.angularDamp; target.fixedAngle = this.fixedAngle; target.ignoreGravity = this.ignoreGravity; target.continous = this.continous; target.linearVel = this.linearVel; target.angularVel = this.angularVel; target.revolutions = this.revolutions; target.explicitMass = this.explicitMass; target.colCat = this.colCat; target.colWith = this.colWith; if (this.shapes != null) { if (target.shapes == null) { target.shapes = new List<ShapeInfo>(this.shapes.Count); } else if (target.shapes.Count > this.shapes.Count) { // Remove exceeding shapes for (int i = target.shapes.Count - 1; i >= this.shapes.Count; i--) { target.RemoveShape(target.shapes[i]); } } // Synchronize existing shapes for (int i = 0; i < this.shapes.Count; i++) { bool isNew = (target.shapes.Count <= i); ShapeInfo sourceShape = this.shapes[i]; ShapeInfo targetShape = !isNew ? target.shapes[i] : null; if (operation.HandleObject(sourceShape, ref targetShape)) { if (isNew) target.shapes.Add(targetShape); else target.shapes[i] = targetShape; } } } else { target.ClearShapes(); } if (this.joints != null) { if (target.joints == null) { target.joints = new List<JointInfo>(this.joints.Count); } else if (target.joints.Count > this.joints.Count) { // Remove exceeding joints for (int i = target.joints.Count - 1; i >= this.joints.Count; i--) { target.RemoveJoint(target.joints[i]); } } // Synchronize existing joints for (int i = 0; i < this.joints.Count; i++) { bool isNew = (target.joints.Count <= i); JointInfo sourceJoint = this.joints[i]; JointInfo targetJoint = !isNew ? target.joints[i] : null; if (operation.HandleObject(sourceJoint, ref targetJoint)) { if (isNew) target.joints.Add(targetJoint); else target.joints[i] = targetJoint; } } } else { target.ClearJoints(); } // Make sure to re-initialize the targets body, if it was shut down if (wasInitialized) target.Initialize(); }
protected override void OnCopyDataTo(object target, ICloneOperation operation) { base.OnCopyDataTo(target, operation); RenderTarget c = target as RenderTarget; c.SetupOpenGLRes(); }
void ICloneExplicit.CopyDataTo(object targetObj, ICloneOperation operation) { FormattedText target = targetObj as FormattedText; operation.HandleObject(this.icons, ref target.icons); operation.HandleObject(this.flowAreas, ref target.flowAreas); operation.HandleObject(this.fonts, ref target.fonts); target.icons = this.icons != null ? this.icons.Clone() as Icon[] : null; target.flowAreas = this.flowAreas != null ? this.flowAreas.Clone() as FlowArea[] : null; target.fonts = this.fonts != null ? this.fonts.Clone() as ContentRef<Font>[] : null; target.sourceText = this.sourceText; target.maxWidth = this.maxWidth; target.maxHeight = this.maxHeight; target.wrapMode = this.wrapMode; target.lineAlign = this.lineAlign; target.ApplySource(target.sourceText); }
void ICloneExplicit.CopyDataTo(object targetObj, ICloneOperation operation) { operation.HandleObject(this, targetObj as ExplicitCloneTestObjectB); (targetObj as ExplicitCloneTestObjectB).SpecialSetupDone = true; }
protected override void OnCopyDataTo(object targetObj, ICloneOperation operation) { base.OnCopyDataTo(targetObj, operation); Transform target = targetObj as Transform; target.deriveAngle = this.deriveAngle; target.ignoreParent = this.ignoreParent; target.pos = this.pos; target.angle = this.angle; target.scale = this.scale; target.posAbs = this.posAbs; target.angleAbs = this.angleAbs; target.scaleAbs = this.scaleAbs; target.tempVel = this.tempVel; target.tempVelAbs = this.tempVelAbs; target.tempAngleVel = this.tempAngleVel; target.tempAngleVelAbs = this.tempAngleVelAbs; target.velAbs = this.velAbs; target.vel = this.vel; target.angleVel = this.angleVel; target.angleVelAbs = this.angleVelAbs; // Initialize parentTransform, because it's required for UpdateAbs but is null until OnLoaded, which will be called after applying prefabs. if (target.gameobj != null && target.gameobj.Parent != null) target.parentTransform = target.gameobj.Parent.Transform; // Handle parentTransform manually to prevent null-overwrites operation.HandleObject(this.parentTransform, ref target.parentTransform, true); // Update absolute transformation data, because the target is relative to a different parent. target.UpdateAbs(); }