Search Unity

why mono dev or xamarin studio is not running a simple example, why???

Discussion in 'Immediate Mode GUI (IMGUI)' started by Ixquic, Apr 15, 2014.

  1. Ixquic

    Ixquic

    Joined:
    Apr 7, 2014
    Posts:
    8
    Hello all, i installed Unity 3.4.3 f1 and when i try to run a simple example using mono dev or xamarin studio the next messages appears:

    The type or namespace name 'UnityEngine' could not be found (are you missing a using directive or an assembly reference?)
    the same for MonoBehaviour line. So i reinstall this version again BUT the issue still appearing, any help will be appreciate.:cry:

    using UnityEngine;
    using System.Collections;

    public class Example : MonoBehaviour {


    void Start ( ) {

    Texture2D texture = new Texture2D (128,128);
    render.material.mainTexture = texture;

    }
    }
    }
     
  2. wondyr

    wondyr

    Joined:
    Nov 30, 2013
    Posts:
    36
    First you have 1 extra } at the bottom of the script. Second you didn't declare texture as a variable. Third, render is suppost to be renderer. The follow script is the correct setup I think.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Example : MonoBehaviour {
    5.  
    6.     void Start ()
    7.     {
    8.        
    9.         var texture = new Texture2D (128,128);
    10.         renderer.material.mainTexture = texture;
    11.                                            
    12.     }
    13. }
    14.  
    Also remember to use the code tags (under advance settings) so it doesn't turn some things to smileys ie: 8) is 8 )
     
  3. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Beside what wondyr wrote, you should always open MonoDevelop or XamarinStudio through Unity. That means you create an new project or open an existing one and then open MonoDevelop/XamarinStudio either by double clicking on a script in the project or by selecting "Assets -> Sync MonoDevelop Project" in the menu.
     
  4. Ixquic

    Ixquic

    Joined:
    Apr 7, 2014
    Posts:
    8
    View attachment 95903

    Hello all, what to do mono and xamarin are not compiling the example!!! i made modifications to the code lines because was wondyr wrote but is not running yet. Thank you and ;)
     
  5. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Hello, did you even try one of the steps I proposed?
     
  6. Ixquic

    Ixquic

    Joined:
    Apr 7, 2014
    Posts:
    8
    Yes Dantus, those are the steps:

    1. First double click on Unity icon
    2. Then go to Assets then select Sync Mono Dev Project
    3. Then Xamarin Studio opens and then i select a solution testgui.sln
    4. The solution is open and then a file Example.cs describes the test:

    using UnityEngine;
    using System.Collections;

    public class Example : MonoBehaviour {
    void Start() {
    var texture = new Texture2D (128, 128);
    renderer.material.mainTexture = texture;
    }
    }

    BUT when i make click F7 or Build > Build testgui, then the messages that i posted before appears and this is so annoying! :confused:
     
  7. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    If Xamarin Studio is open, you should not select any solution, the solution should automatically open. After you sync the project, try to double click on a script in the Unity project and try that.
    If that doesn't work, you should stick to Mono Develop. Even if Xamarin Studio is pretty close, the Unity support varies from version to version.
     
  8. wondyr

    wondyr

    Joined:
    Nov 30, 2013
    Posts:
    36
    The reason for the error is you are building the build in the wrong place. You are building inside Xamarin Studio. You need to build it inside of Unity for it to build correctly. I got the same errors you did when I tried to build in Xamarin Studio but not in Unity.
     
  9. Ixquic

    Ixquic

    Joined:
    Apr 7, 2014
    Posts:
    8
    Thank you all, now Unity is running!!