Search Unity

How to drag game object without moving for this texture?

Discussion in 'Scripting' started by Slyrfecso1, Oct 26, 2015.

  1. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    Hi,

    I can drag GO (window) and I have texture(outside of window) on this.
    How can I stop texture transform under dragging GO?

    Any help will be helpful.
    Thanks.
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    do you mean the texture is changing when you drag the gameobject?
     
  3. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    I have 3D windows and door on the wall.
    In the window is showing only a part of the panorama image.
    If I drag the window then I'd like to see only the part of the image.

     
  4. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    I have soled:)

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class TextureOffset : MonoBehaviour {
    5.  
    6.     float scrollSpeed = 0.05f;
    7.     Renderer rend;
    8.  
    9.  
    10.     // Use this for initialization
    11.     void Start () {
    12.         rend = GetComponent<Renderer> ();
    13.     }
    14.    
    15.     // Update is called once per frame
    16.     void Update () {
    17.         GameObject ajtoX = GameObject.Find("Ablak_ONE");
    18.         float offset = ajtoX.transform.position.x*scrollSpeed;
    19.         rend.material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
    20.     }
    21. }
    22.  
     
    Last edited: Oct 26, 2015