Search Unity

3D Objects Problem

Discussion in 'Scripting' started by jerex, Jul 29, 2014.

  1. jerex

    jerex

    Joined:
    Jun 21, 2014
    Posts:
    28
    Hi guys. Do you have idea on how to change texture to a 3d objects? My goal is to change the texture2d to a 3d object like image in blender but it has an extension .obj here is my code. Any suggestion will be appreciated. :)
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Text.RegularExpressions;
    4. public class test1 : MonoBehaviour {
    5.     public static string print = Try.aw;
    6.     public GUIStyle B;
    7.     public Texture2D A;
    8.     public Texture2D C;
    9.     bool CorrectValue;
    10.     bool a;
    11.     void OnGUI() {
    12.    
    13.         if(GUI.Button (new Rect (100, 100, 40, 40), "", B)) {
    14.             if(int.Parse(print) == 1){
    15.                 CorrectValue = true;
    16.             } else {
    17.                 CorrectValue = false;
    18.             }
    19.             if(int.Parse(print) == 2){
    20.                 a = true;
    21.             } else {
    22.                 a = false;
    23.             }
    24.         }
    25.    
    26.         if(CorrectValue) {
    27.             GUI.DrawTexture(new Rect(500,200,200,200),A);
    28.         }
    29.         if(a) {
    30.             GUI.DrawTexture(new Rect(300,200,200,200),C);
    31.             GUI.DrawTexture(new Rect(200,100,200,200),C);
    32.         }
    33.     }
    34. }
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    do you mean you want the 2d texture to display an image of a 3d object? as if a camera feed was showing the 3d object projected onto the texture?