Exemple #1
0
	public void CopyToStaticBody(JelloBody oldBody, JelloBody newBody) //TODO make sure these all are up to date with any new variables that need assigning
	{
		newBody.affectedByGravity = oldBody.affectedByGravity;
		newBody.disabled = oldBody.disabled;
		newBody.gravity = oldBody.gravity;
		newBody.IsAwake = oldBody.IsAwake;
		newBody.IsKinematic = oldBody.IsKinematic;
		newBody.IsStatic = tar.IsStatic;
		newBody.IsStatic = true;
		newBody.IsTrigger = oldBody.IsTrigger;
		newBody.overrideWorldGravity = oldBody.overrideWorldGravity;
		newBody.pivotOffset = oldBody.pivotOffset;
		newBody.setComponentReferences();
		newBody.polyCollider = oldBody.polyCollider;
		
		if(oldBody.meshLink != null)
		{
			newBody.meshLink = oldBody.meshLink;
			newBody.meshLink.body = newBody;
		}
		
		if(oldBody.Shape != null)
		{
			newBody.setShape(oldBody.Shape, shapeSettingOptions);
			newBody.Mass = Mathf.Infinity;
		}
		
		for(int i = 0; i < oldBody.EdgePointMassCount; i++)
		{
			newBody.setEdgePointMass(oldBody.getEdgePointMass(i), i);
			newBody.getEdgePointMass(i).Mass = Mathf.Infinity;
			newBody.getEdgePointMass(i).body = newBody;
		}
		for(int i = 0; i < oldBody.InternalPointMassCount; i++)
		{
			newBody.setInternalPointMass(oldBody.getInternalPointMass(i), i);
			newBody.getInternalPointMass(i).Mass = Mathf.Infinity;
			newBody.getInternalPointMass(i).body = newBody;
		}
		for(int i = 0; i < oldBody.AttachPointCount; i++)
		{
			newBody.AddAttachPoint(oldBody.GetAttachPoint(i));
			newBody.GetAttachPoint(i).body = newBody;
		}
		for(int i = 0; i < oldBody.JointCount; i++)
		{
			newBody.AddJoint(oldBody.GetJoint(i));
			newBody.GetJoint(i).bodyA = newBody;
		}
		
		EditorUtility.SetDirty(newBody);
	}
    //TODO make sure these all are up to date with any new variables that need assigning
    public void CopyToStaticBody(JelloBody oldBody, JelloBody newBody)
    {
        newBody.affectedByGravity = oldBody.affectedByGravity;
        newBody.disabled = oldBody.disabled;
        newBody.gravity = oldBody.gravity;
        newBody.IsAwake = oldBody.IsAwake;
        newBody.IsKinematic = oldBody.IsKinematic;
        newBody.IsStatic = tar.IsStatic;
        newBody.IsStatic = true;
        newBody.IsTrigger = oldBody.IsTrigger;
        newBody.overrideWorldGravity = oldBody.overrideWorldGravity;
        newBody.pivotOffset = oldBody.pivotOffset;
        newBody.setComponentReferences();
        newBody.polyCollider = oldBody.polyCollider;

        if(oldBody.meshLink != null)
        {
            newBody.meshLink = oldBody.meshLink;
            newBody.meshLink.body = newBody;
        }

        if(oldBody.Shape != null)
        {
            newBody.setShape(oldBody.Shape, shapeSettingOptions);
            newBody.Mass = Mathf.Infinity;
        }

        for(int i = 0; i < oldBody.EdgePointMassCount; i++)
        {
            newBody.setEdgePointMass(oldBody.getEdgePointMass(i), i);
            newBody.getEdgePointMass(i).Mass = Mathf.Infinity;
            newBody.getEdgePointMass(i).body = newBody;
        }
        for(int i = 0; i < oldBody.InternalPointMassCount; i++)
        {
            newBody.setInternalPointMass(oldBody.getInternalPointMass(i), i);
            newBody.getInternalPointMass(i).Mass = Mathf.Infinity;
            newBody.getInternalPointMass(i).body = newBody;
        }
        for(int i = 0; i < oldBody.AttachPointCount; i++)
        {
            newBody.AddAttachPoint(oldBody.GetAttachPoint(i));
            newBody.GetAttachPoint(i).body = newBody;
        }
        for(int i = 0; i < oldBody.JointCount; i++)
        {
            newBody.AddJoint(oldBody.GetJoint(i));
            newBody.GetJoint(i).bodyA = newBody;
        }

        EditorUtility.SetDirty(newBody);
    }