Unity3D 2D动画插件EasyMotion2D (之六)SpriteRenderer

What is SpriteRenderer

SpriteRenderer is a component inherited from MonoBehaviour. It can attach sprites and commit sprites to EasyMotion2D's sprite rendering pipeline.

How to use

  • Select the menu item EasyMotion2D > GameObject > Sprite to add a gameobject with a SpriteRenderer in scene hierarchy.

SpriteRenderer members in Inspector

  • Current frame
    • The first sprite attach to the SpriteRenderer. Usually use in a simply sprite.
    • Click the button in thumbnail field, you can open the Sprite Selector.
      • Sprite Selector
        • Click a sprite in sprite selector can be set the current frame to SpriteRenderer.
        • Double-click a sprite in sprite selector can set the current frame and close the selector window quickly.
        • Click the “None” button in right-top of selector window can set current frame to no select sprite.
  • Visible
    • Viisble decide a Sprite can be render in scene or not.
  • RenderMode
    • RenderMode decide how to rendering a sprite.
  • Color
    • The color of the sprite.
  • UpdateMode
    • Update Mode use to decide where to call the SpriteRenderer.Apply function.
    • The SpriteRenderer.Apply use to commit sprite's propertys change for rendering. That means if you change any property of SpriteRenderer or change transform's property on parent gameobject, you should call SpriteRenderer.Apply.
    • If update mode is none, then you need call SpriteRenderer.Apply manually in your code.
  • Depth
    • Depth decide how the sprites sorting in rendering pipeline in the same layer.
    • Depth value range is 0-512, value more less, it will rendering more late.
  • Plane
    • Decide which plane the sprite will rendering to.

How to define occlusion between SpriteRenderers

  • EasyMotion use the gameobject's   layer  and SpriteRenderer's   depth  to decide how a sprite's occlusion with others.
  • Use layer for occlusion between SpriteRenderer
    • EasyMotion2D use layer 16 to layer 32 decide sprite's depth.
    • If gameobject's layer less than 16, then it same as the layer 16.
    • If gameobject in the same layer, you should use the depth member in SpriteRenderer.
  • Use layer and depth of SpriteRenderer for occlusion between SpriteRenderer.

SpriteRenderer FAQ

  • I add a sprite in scene, but i can't see it in game view?
    • In this case, please check the SpriteRenderer follow steps:
      1. Is these a gameobject with a Camera2D component in the scene? If no, will not renderering any sprite in the Scene.
      2. Do you select a sprite to the current frame of the SpriteRenderer? If no, will skip this sprite when rendering.
      3. Do you select a RenderModeSetting to the renderMode of the SpriteRenderer? If no, will skip this sprite when rendering.
      4. Do you set a color with 0 alpha to the color of the SpriteRenderer? If yes, you will can not see the sprite, because it will full transparent.
      5. Do you set the cullFlag of Camera2D but sprite's layer not one of these layers? If yes, will skip this sprite when rendering.
      6. Do you set the clipping of Camera2D and sprite out of the viewport? If yes, will clipping this sprite when rendering.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值