• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by unity_2aPkpqA298SxQw · Apr 26, 2019 at 08:33 AM · 2dprefabspriterenderer

Prefab of SpriteShapeRenderer not rendered if first point not visible ?

Hello,

So my problem is that I have a prefab of a SpriteShapeController that I instantiate and generate points out of the field of view of the camera, and then it's supposed to appear in the field of view of the camera but the spriteShape is not rendered until the first point of the SpriteShape is in the field of view. After a long time of struggling and not understanding why the spriteShape were not visible (even in the scene view if the camera don't have in the field of view the first point the prefab is not visible in scene view) I came to this conclusion.

I don't really know what to do, maybe I'm not using well the SpriteShapeRenderer ? Does somebody already had this problem ?

Prefab : alt text

The spriteShape only have 2 points in the prefab then at the Instantiation of the prefab i create more points in the script SpriteShapeManagerBrackground :

     public void Start()
     {
 
         spriteShapeController = GetComponent<SpriteShapeController>();
         previousPoint = spriteShapeController.spline.GetPosition(0);
         newPoint = spriteShapeController.spline.GetPosition(1);
         firstPoint = previousPoint;
         for (int i = 0; i < 100; i++)
         {
             this.AddPoint();
         }
 
     }

And where I instantiate the prefab :

     public void AddBackgroundPath(float y, float z)
     {
         GameObject go = Instantiate(toClone, new Vector3(this.cameraScript.camera.transform.position.x+ 250, y + UnityEngine.Random.Range(-200, 200), z), Quaternion.identity);
         go.GetComponent<SpriteShapeManagerBackground>().camera = this.cameraScript;
 
     }
prefabunityforum.png (77.9 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RedHillbilly · Oct 29, 2020 at 06:08 PM 0
Share

I have the same issue, did you find a solution?

side note: I don't think you need the sprite renderer as the shape is rendered with the sprite shape renderer

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by RedHillbilly · Oct 29, 2020 at 08:50 PM

Found a possible solution by scrolling this thread: https://forum.unity.com/threads/tel...-with-sprite-shape.686305/page-3#post-6083610

But it only works if the shape doesn't change in time, otherwise you need to uncheck DestroyOnCompletion which might be heavy on computation.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

226 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Changing SpriteRenderer order in script 1 Answer

Sprite is missing in SpriteRenderer in some prefabs 0 Answers

Crop/Mask a Sprite on runtime 0 Answers

Is is possible to replace a prefab with a variant in script? 1 Answer

How to get the bounds of an actual sprite, not it's bounding box. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges