Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 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 /
  • Help Room /
avatar image
0
Question by nyanpath · Sep 03, 2018 at 07:56 AM · meshfbxuvoffsetuv coordinates

How can I check if the UV forms a triangle, and get their UV-coordinates?

I have an FBX I have imported from the Blenders, and that FBX has a lot of individually unwrapped triangles that are assigned to coloured squares on the texture. By using texture offset I can change the palette of the mesh. However, I want to be able to offset just parts of the unwrapped UV on the texture.

The things I have looked at are here:

https://docs.unity3d.com/ScriptReference/Mesh-uv.html https://docs.unity3d.com/ScriptReference/Mesh-subMeshCount.html https://answers.unity.com/questions/46788/painting-on-a-texture-without-crossing-mesh-triang.html?childToView=46816#answer-46816 https://answers.unity.com/questions/1105729/find-uv-coordinates-of-mesh-without-a-raycast.html

I found that UV is a Vector2, but to get an area you can texture, you need an area, which is a Vector3. So I want to be able to find which UVs on the texture fall within a certain area, and change their offset position, leaving the rest in their current positions.

It would seem to be possible to do, but this is not my area of expertise. Thank you all very much in advance for helping me out.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by nyanpath · Sep 03, 2018 at 02:12 PM

I solved this myself. The example code to offset one triangle is as follows (this uses a tetrahedron as a base mesh imported from an .FBX into the Unities):

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PartiallyOffsetUV : MonoBehaviour {
 
     private Mesh _pacito;
 
     private Vector3[] _vertices;
 
     private Vector2[] _uvs;
 
     void Start ()
     {
         _pacito = GetComponent<MeshFilter>().mesh;
 
         _vertices = _pacito.vertices;
 
         _uvs = new Vector2[_vertices.Length];
 
         for (int c = 0; c < _uvs.Length; c++)
         {
             Debug.Log(_pacito.uv[c].x + " : " + _pacito.uv[c].y);
 
             //if (c > 2 && c < 6)
             if (_pacito.uv[c].x < 0.5f && _pacito.uv[c].y < 0.5f)
             {
                 _uvs[c] = new Vector2(_pacito.uv[c].x + 0.5f, _pacito.uv[c].y);
             }
             else
             {
                 _uvs[c] = new Vector2(_pacito.uv[c].x, _pacito.uv[c].y);
             }
         }
 
         _pacito.uv = _uvs;
     }
 }
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.

Follow this Question

Answers Answers and Comments

158 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

Related Questions

Assigning uv's to multiple faces 1 Answer

Help setting UV coordinates for code-generated plane 0 Answers

Animated rigged blender model generating colliders problem 1 Answer

Tiling a noise texture 1:1 over each triangle without creating extra vertices 1 Answer

Mesh.uv assign in Unity 5.6 is 5x slower than in 5.5 0 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