객체가 있는 위치의 UV 가져오기
                                            
                                                
                                                
                                                
                                                
                                                
                                                 4374 단어  textureCoordSharderRaycastUnity
                    
이런 느낌. 
 
※ 화면을 클릭하여 표시 위치를 변경합니다.
단계 
기타 노트(조사하고 싶은 일 등) 
아니, 메시 콜리더가 안 맞았어?안 날아, 레이 몰라?참고 자료 
Splatoon의 발라주는 그런 것을 재현하고 싶어요.
http://esprog.hatenablog.com/entry/2016/05/08/212355 
소스 코드 
MousePainter.cs
public class MousePainter : MonoBehaviour
{
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            // クリックされたスクリーンの位置からRayを飛ばす
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitInfo;
            // Rayとの当たり判定
            if (Physics.Raycast(ray, out hitInfo))
            {
                #region Use_textureCoord
                // シェーダにUVを渡す
                var material = hitInfo.transform.gameObject.GetComponent<Renderer>().material;
                Vector4[] _Pos = new Vector4[2];
                _Pos[0] = new Vector4(hitInfo.textureCoord.x, hitInfo.textureCoord.y, 0, 0);
                material.SetVectorArray("_Pos", _Pos);
                #endregion Use_textureCoord
            }
        }
    }
}
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(객체가 있는 위치의 UV 가져오기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/mintiatian/items/f37df6c2c83a7bf8985e
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
Splatoon의 발라주는 그런 것을 재현하고 싶어요.
http://esprog.hatenablog.com/entry/2016/05/08/212355
소스 코드 
MousePainter.cs
public class MousePainter : MonoBehaviour
{
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            // クリックされたスクリーンの位置からRayを飛ばす
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitInfo;
            // Rayとの当たり判定
            if (Physics.Raycast(ray, out hitInfo))
            {
                #region Use_textureCoord
                // シェーダにUVを渡す
                var material = hitInfo.transform.gameObject.GetComponent<Renderer>().material;
                Vector4[] _Pos = new Vector4[2];
                _Pos[0] = new Vector4(hitInfo.textureCoord.x, hitInfo.textureCoord.y, 0, 0);
                material.SetVectorArray("_Pos", _Pos);
                #endregion Use_textureCoord
            }
        }
    }
}
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(객체가 있는 위치의 UV 가져오기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/mintiatian/items/f37df6c2c83a7bf8985e
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
public class MousePainter : MonoBehaviour
{
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            // クリックされたスクリーンの位置からRayを飛ばす
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitInfo;
            // Rayとの当たり判定
            if (Physics.Raycast(ray, out hitInfo))
            {
                #region Use_textureCoord
                // シェーダにUVを渡す
                var material = hitInfo.transform.gameObject.GetComponent<Renderer>().material;
                Vector4[] _Pos = new Vector4[2];
                _Pos[0] = new Vector4(hitInfo.textureCoord.x, hitInfo.textureCoord.y, 0, 0);
                material.SetVectorArray("_Pos", _Pos);
                #endregion Use_textureCoord
            }
        }
    }
}
Reference
이 문제에 관하여(객체가 있는 위치의 UV 가져오기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/mintiatian/items/f37df6c2c83a7bf8985e텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)