SF Tool Documentation
Search Results for

    Show / Hide Table of Contents

    Class SFShapeComponent

    Base class for the component based classes used in the SF Metroidvania package.

    Inheritance
    System.Object
    SFShapeComponent
    SFCapsuleShape
    SFCircleShape
    SFRectangleShape
    SFTileMapShape
    Implements
    ITriggerShapeCallback
    IContactShapeCallback
    IPreSolveShapeCallback
    Namespace: SF.PhysicsLowLevel
    Assembly: cs.temp.dll.dll
    Syntax
    public abstract class SFShapeComponent : MonoBehaviour, ITriggerShapeCallback, IContactShapeCallback, IPreSolveShapeCallback
    Remarks

    Inherit from this class and implement your own custom Geometry shape or declare the vertexes for your own shape. For examples of geometry see Unity's built in types , , and . Create a custom implicit casting to a that calls one of the constructors for geometry.

    Fields

    _lastPhysicsPosition

    Declaration
    protected Vector2 _lastPhysicsPosition
    Field Value
    Type Description
    Vector2

    _shape

    Declaration
    protected PhysicsShape _shape
    Field Value
    Type Description
    PhysicsShape

    _useDelaunay

    Should the Delaunay algorithm be used for creating meshes using .

    Declaration
    protected bool _useDelaunay
    Field Value
    Type Description
    System.Boolean

    Body

    Declaration
    public PhysicsBody Body
    Field Value
    Type Description
    PhysicsBody

    BodyDefinition

    Declaration
    public PhysicsBodyDefinition BodyDefinition
    Field Value
    Type Description
    PhysicsBodyDefinition

    ContainedPhysicsShapes

    A list of objects that are currently contained inside of Shape

    Declaration
    public List<IPhysicsShapeContained> ContainedPhysicsShapes
    Field Value
    Type Description
    System.Collections.Generic.List<IPhysicsShapeContained>

    IsCompositeShape

    Is the Shape created by multiple separate ?

    Declaration
    public bool IsCompositeShape
    Field Value
    Type Description
    System.Boolean

    Offset

    Declaration
    public Vector2 Offset
    Field Value
    Type Description
    Vector2

    PhysicsWorld

    Declaration
    public PhysicsWorld PhysicsWorld
    Field Value
    Type Description
    PhysicsWorld

    ScaleSize

    Should the Shape size be scaled with the game objects transform.

    Declaration
    public bool ScaleSize
    Field Value
    Type Description
    System.Boolean

    ShapeCreatedHandler

    Declaration
    public Action ShapeCreatedHandler
    Field Value
    Type Description
    Action

    ShapeDefinition

    The definition for the Shape for the SFShapeComponent.

    Declaration
    public PhysicsShapeDefinition ShapeDefinition
    Field Value
    Type Description
    PhysicsShapeDefinition
    Remarks

    When adding this component to a GameObject it default's to the set in the LowLevelPhysics settings asset in the project settings.

    ShapeDestroyedHandler

    Declaration
    public Action ShapeDestroyedHandler
    Field Value
    Type Description
    Action

    ShapesInComposite

    Declaration
    public NativeList<PhysicsShape> ShapesInComposite
    Field Value
    Type Description
    NativeList<PhysicsShape>

    UpdateTransform

    Declaration
    public bool UpdateTransform
    Field Value
    Type Description
    System.Boolean

    Properties

    IsPositionChanged

    Declaration
    protected bool IsPositionChanged { get; }
    Property Value
    Type Description
    System.Boolean

    Shape

    The completed physics shape data struct for the SFShapeComponent.

    Declaration
    public ref PhysicsShape Shape { get; }
    Property Value
    Type Description
    PhysicsShape
    Remarks

    Keyword here is completed because you can use to merge shapes and vertexes into a single shape. If a SFShapeComponent is made from multiple individual shapes and a single shape is created this is the completed merged shape. SFTileMapShape for an example of this.

    ShapeProxy

    The generic proxy data container for the Shape Used to allow support for all types of shapes and geometry when doing queries and casting.

    for an example of use cases.

    Declaration
    public PhysicsShape.ShapeProxy ShapeProxy { get; }
    Property Value
    Type Description
    PhysicsShape.ShapeProxy

    World

    Declaration
    public PhysicsWorld World { get; }
    Property Value
    Type Description
    PhysicsWorld

    Methods

    AddContactCallbackTarget(IContactShapeCallback)

    Declaration
    public void AddContactCallbackTarget(IContactShapeCallback target)
    Parameters
    Type Name Description
    IContactShapeCallback target

    AddPreSolveCallbackTarget(IPreSolveShapeCallback)

    Declaration
    public void AddPreSolveCallbackTarget(IPreSolveShapeCallback target)
    Parameters
    Type Name Description
    IPreSolveShapeCallback target

    AddTriggerCallbackTarget(ITriggerShapeCallback)

    Declaration
    public void AddTriggerCallbackTarget(ITriggerShapeCallback target)
    Parameters
    Type Name Description
    ITriggerShapeCallback target

    ApplyTransform()

    Declaration
    public void ApplyTransform()

    CacheTransform()

    Declaration
    public void CacheTransform()

    CalculateAABB()

    Declaration
    public PhysicsAABB CalculateAABB()
    Returns
    Type Description
    PhysicsAABB

    CreateBody()

    Declaration
    protected virtual void CreateBody()

    CreateBodyShapeGeometry()

    Creates the Shape geometry to use when calling the method or other CreateShape method.

    Declaration
    protected virtual void CreateBodyShapeGeometry()

    CreateShape()

    Declaration
    protected virtual void CreateShape()

    DebugPhysics()

    If debugging is enabled in editor, a set of logs will be sent to console just in case something was not set right.

    Declaration
    [Conditional("UNITY_EDITOR")]
    public virtual void DebugPhysics()

    DebugPhysicsExtra()

    Override this to add custom debug log checking on top of the normal checks in DebugPhysics. This runs even when UsingDebugMode is set to false and is only ran inside of the editor at the current moment. Runtime support coming soon.

    Declaration
    [Conditional("UNITY_EDITOR")]
    protected virtual void DebugPhysicsExtra()

    DestroyBody()

    Declaration
    protected virtual void DestroyBody()

    DestroyShape()

    Declaration
    protected virtual void DestroyShape()

    FixedUpdate()

    Declaration
    protected void FixedUpdate()

    GetAABB(in PhysicsShape)

    Declaration
    public static PhysicsAABB GetAABB(in PhysicsShape physicsShape)
    Parameters
    Type Name Description
    PhysicsShape physicsShape
    Returns
    Type Description
    PhysicsAABB

    OnContactBegin2D(PhysicsEvents.ContactBeginEvent)

    Declaration
    public void OnContactBegin2D(PhysicsEvents.ContactBeginEvent beginEvent)
    Parameters
    Type Name Description
    PhysicsEvents.ContactBeginEvent beginEvent

    OnContactBegin2D(PhysicsEvents.ContactBeginEvent, SFShapeComponent)

    Declaration
    public void OnContactBegin2D(PhysicsEvents.ContactBeginEvent beginEvent, SFShapeComponent callingShapeComponent)
    Parameters
    Type Name Description
    PhysicsEvents.ContactBeginEvent beginEvent
    SFShapeComponent callingShapeComponent

    OnContactEnd2D(PhysicsEvents.ContactEndEvent)

    Declaration
    public void OnContactEnd2D(PhysicsEvents.ContactEndEvent endEvent)
    Parameters
    Type Name Description
    PhysicsEvents.ContactEndEvent endEvent

    OnContactEnd2D(PhysicsEvents.ContactEndEvent, SFShapeComponent)

    Declaration
    public void OnContactEnd2D(PhysicsEvents.ContactEndEvent endEvent, SFShapeComponent callingShapeComponent)
    Parameters
    Type Name Description
    PhysicsEvents.ContactEndEvent endEvent
    SFShapeComponent callingShapeComponent

    OnDisable()

    Declaration
    protected void OnDisable()

    OnEnable()

    Declaration
    protected void OnEnable()

    OnPreSolve2D(PhysicsEvents.PreSolveEvent)

    Declaration
    public bool OnPreSolve2D(PhysicsEvents.PreSolveEvent preSolveEvent)
    Parameters
    Type Name Description
    PhysicsEvents.PreSolveEvent preSolveEvent
    Returns
    Type Description
    System.Boolean

    OnPreSolve2D(PhysicsEvents.PreSolveEvent, SFShapeComponent)

    Declaration
    public bool OnPreSolve2D(PhysicsEvents.PreSolveEvent preSolveEvent, SFShapeComponent callingShapeComponent)
    Parameters
    Type Name Description
    PhysicsEvents.PreSolveEvent preSolveEvent
    SFShapeComponent callingShapeComponent
    Returns
    Type Description
    System.Boolean

    OnTriggerBegin2D(PhysicsEvents.TriggerBeginEvent)

    Declaration
    public void OnTriggerBegin2D(PhysicsEvents.TriggerBeginEvent beginEvent)
    Parameters
    Type Name Description
    PhysicsEvents.TriggerBeginEvent beginEvent

    OnTriggerBegin2D(PhysicsEvents.TriggerBeginEvent, SFShapeComponent)

    Declaration
    public void OnTriggerBegin2D(PhysicsEvents.TriggerBeginEvent beginEvent, SFShapeComponent callingShapeComponent)
    Parameters
    Type Name Description
    PhysicsEvents.TriggerBeginEvent beginEvent
    SFShapeComponent callingShapeComponent

    OnTriggerEnd2D(PhysicsEvents.TriggerEndEvent)

    Declaration
    public void OnTriggerEnd2D(PhysicsEvents.TriggerEndEvent endEvent)
    Parameters
    Type Name Description
    PhysicsEvents.TriggerEndEvent endEvent

    OnTriggerEnd2D(PhysicsEvents.TriggerEndEvent, SFShapeComponent)

    Declaration
    public void OnTriggerEnd2D(PhysicsEvents.TriggerEndEvent endEvent, SFShapeComponent callingShapeComponent)
    Parameters
    Type Name Description
    PhysicsEvents.TriggerEndEvent endEvent
    SFShapeComponent callingShapeComponent

    OnValidate()

    Declaration
    protected virtual void OnValidate()

    PreDisable()

    Used to clean up any resources before changing cleaning up the Shape and Body.

    Declaration
    protected virtual void PreDisable()

    PreEnabled()

    Override to set up required components when first adding a SFShapeComponent class to a gameobject. Example SFTileMapShape requires a TileMap component to be set before generating the Shape.

    Declaration
    protected virtual void PreEnabled()

    RemoveContactCallbackTarget(IContactShapeCallback)

    Declaration
    public void RemoveContactCallbackTarget(IContactShapeCallback target)
    Parameters
    Type Name Description
    IContactShapeCallback target

    RemoveTriggerCallbackTarget(ITriggerShapeCallback)

    Declaration
    public void RemoveTriggerCallbackTarget(ITriggerShapeCallback target)
    Parameters
    Type Name Description
    ITriggerShapeCallback target

    SetShape<TGeometryType>(TGeometryType)

    Declaration
    public virtual void SetShape<TGeometryType>(TGeometryType geometryType)
        where TGeometryType : struct
    Parameters
    Type Name Description
    TGeometryType geometryType
    Type Parameters
    Name Description
    TGeometryType

    UpdateShape()

    Called from editor tools to update the Shape after making changes using editor tools. Also can be used to force a shape update.

    Declaration
    public void UpdateShape()

    Implements

    ITriggerShapeCallback
    IContactShapeCallback
    IPreSolveShapeCallback
    In This Article
    Back to top Generated by DocFX