Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Change of codes

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

  1. jerex

    jerex

    Joined:
    Jun 21, 2014
    Posts:
    28
    Hi guys. I need some help. I am using blender to create 3D objects. I know how to display image when button is click. but in blender the file name of the image i made is either .fbx or .obj it can't put in the texture. My question is what should i replace to display image from blender when the button is click? Any suggestions would 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.  
    12.     void OnGUI() {
    13.      
    14.         if(GUI.Button (new Rect (100, 100, 40, 40), "", B)) {
    15.             if(int.Parse(print) == 1){
    16.                 CorrectValue = true;
    17.             } else {
    18.                 CorrectValue = false;
    19.             }
    20.             if(int.Parse(print) == 2){
    21.                 a = true;
    22.             } else {
    23.                 a = false;
    24.             }
    25.         }
    26.      
    27.         if(CorrectValue) {
    28.             GUI.DrawTexture(new Rect(500,200,200,200),A);
    29.         }
    30.         if(a) {
    31.             GUI.DrawTexture(new Rect(300,200,200,200),C);
    32.             GUI.DrawTexture(new Rect(200,100,200,200),C);
    33.         }
    34.  
    35.     }
    36. }
     
    Last edited: Jul 27, 2014
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
  3. jerex

    jerex

    Joined:
    Jun 21, 2014
    Posts:
    28
    I'm done editting my post. :) thanks for info. I learn more on your reply. :)
     
  4. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I had a look at the code and your description and I have no clue what you would like to achieve. At the moment, you are using textures in the code. Would you like to replace them with 3d objects?
     
  5. jerex

    jerex

    Joined:
    Jun 21, 2014
    Posts:
    28
    yes dantus. that's my goal. we use blender to create 3d object but it has different extension. in texture you can only put images like jpeg or png but in blender it create extension .obj which is not available to put in the texture. do you have any idea on what to do so that we can have 3d objects?
     
  6. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You need to explain what you would like to achieve, because I am still unsure. What would you like to to with the 3d object in Unity?