コード例 #1
0
    static public CustomPhysicsShape RequestCustomShapeAccess(Sprite originalSprite)
    {
        CustomPhysicsShape shape = null;

        bool exist = instance.dictionary_CustomShape.TryGetValue(originalSprite, out shape);

        if (exist)
        {
            if (shape == null || shape.sprite.texture == null)
            {
                instance.dictionary_CustomShape.Remove(originalSprite);

                shape = AddShape(originalSprite);

                instance.dictionary_CustomShape.Add(originalSprite, shape);
            }
            return(shape);
        }
        else
        {
            shape = AddShape(originalSprite);

            instance.dictionary_CustomShape.Add(originalSprite, shape);

            return(shape);
        }
    }
コード例 #2
0
 public CustomPhysicsShape GetPhysicsShape()
 {
     if (customPhysicsShape == null)
     {
         customPhysicsShape = SpriteAtlasManager.RequesCustomShape(originalSprite);
     }
     return(customPhysicsShape);
 }
コード例 #3
0
    static private CustomPhysicsShape AddShape(Sprite sprite)
    {
        if (sprite == null || sprite.texture == null)
        {
            return(null);
        }

        CustomPhysicsShape shape = new CustomPhysicsShape();

        shape.sprite = sprite;

        return(shape);
    }
コード例 #4
0
    public void ResetLocal()
    {
        polygons_collider_local = null;
        meshDistance_collider   = -1f;
        mesh_collider           = null;

        polygons_shape_local = null;
        meshDistance_shape   = -1f;
        mesh_shape           = null;

        customPhysicsShape = null;

        ResetWorld();
    }
コード例 #5
0
    public List <Polygon2D> GetShapePolygons()
    {
        if (shapePolygons == null)
        {
            shapePolygons = new List <Polygon2D>();

            if (originalSprite == null)
            {
                return(shapePolygons);
            }

                        #if UNITY_2018_1_OR_NEWER
            if (customPhysicsShape == null)
            {
                customPhysicsShape = SpriteAtlasManager.RequesCustomShape(originalSprite);
            }
            shapePolygons = customPhysicsShape.GetShape();
                        #endif
        }
        return(shapePolygons);
    }
コード例 #6
0
    public List <Polygon2D> GetPolygons_Shape_Local()
    {
        if (polygons_shape_local == null)
        {
            LightingDebug.ShadowColliderTotalGenerationsLocal_shape++;

            polygons_shape_local = new List <Polygon2D>();

                        #if UNITY_2018_1_OR_NEWER
            if (customPhysicsShape == null)
            {
                if (originalSprite == null)
                {
                    return(polygons_shape_local);
                }

                customPhysicsShape = GetPhysicsShape();

                polygons_shape_local = customPhysicsShape.GetShape();
            }
                        #endif
        }
        return(polygons_shape_local);
    }