Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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
0
Question by Mailbot · Apr 14, 2015 at 11:02 PM · spritescript errorgeometryoverride

Sprite.OverrideGeometry() doesn't work?

Hey Guys! I'm trying to set the geometry on a Sprite but I'm getting this error every time I try and run the function.

"Not allowed to override geometry on sprite 'squidward__handsome_squidward_by_millegas-d61zr7o' UnityEngine.Sprite:OverrideGeometry(Vector2[], UInt16[]) SkewTest:Update() (at Assets/ScriptResources/Testing/SkewTest.cs:22)"

and my code is:

 Vector2[] m_MeshVerts = m_CurrentSprite.vertices;
 ushort[] m_MeshTris = m_CurrentSprite.triangles;
 m_CurrentSprite.OverrideGeometry(m_MeshVerts, m_MeshTris);

I've also found this description on the blog: "2D: Sprite geometry can now be overridden using Sprite.OverrideGeometry(Vector2[] vertices, UInt16[] triangles). Unity Pro only."

Does anyone know why I'm getting this error? I have Unity Pro.

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 nostyleguy · Apr 18, 2015 at 04:33 PM 0
Share

I would love an answer to this as well.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by ZimM · Apr 19, 2015 at 02:54 PM

Apparently, Sprite.OverrideGeometry() only works when called as a part of texture import process. In other words, you can only call it from within AssetPostprocessor. OnPostprocessSprites(Texture2D texture, Sprite[] sprites) or AssetPostProcessor.OnPostprocessAllAssets(...).

Comment
Add comment · Show 3 · 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
avatar image paraself · Jan 20, 2016 at 04:07 AM 0
Share

tested and its working! Thanks

avatar image JoeStrout · May 17, 2017 at 02:29 PM 1
Share

Well THAT sucks. How are we supposed to create triangle-mesh sprites at runtime?

avatar image mihakinova · Jan 23, 2018 at 10:07 AM 0
Share

This is not true for Unity 2017+, maybe event earlier versions (I'm currently on 2017.2.0f3, but I've been using it for a while now). You can run OverrideGeometry during runtime (in my case, it's called in a Start method). The only case where I found it not working is when the sprite you are trying to override is using FullRect as it's mesh type (in my case, the sprite is also created during runtime). Not sure if that's a bug or not though. Using Tight fixed the problem for me.

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.

Follow this Question

Answers Answers and Comments

8 People are following this question.

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

Related Questions

SphereCast doesn't work when I increase the radius. 1 Answer

AnimatorOverrideController runtime sprite problem 2 Answers

Bug with AnimatorOverrideController with Sprites 0 Answers

Problem with Scrip for sprites 1 Answer

How do you create complex collision geometry to match 2D sprites? 2 Answers


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