How Adding reference of new DLL?

How can I add a reference of an dll to Unity3D ??

I added the dll to the Plugins folder in my project, and everything is fine. But when I compile this doesn’t work.

I guess that’s because the added dll doesn’t exist in the compiled game, but I don’t know why.

Please clarify the type of DLL, is this a C++ DLL or a C# DLL? If this is C#, just call the methods like you would if you wrote the class in the engine itself, if this is C++ you have to create a carbon bundle and have an .A file like mylib.a vs mylib.dll, pro has instructions on how to set this up.

hi zumwalt
the type of DLL’s is a C#

I try calling the methods how to saying in editor fine works but in buildgame doesn’t work;

this is the code than try use

the dlls :MySql.Data.dll System.Data.dll

using UnityEngine; 
using System; 
using System.Collections; 
//using System.Data; 
//using MySql.Data.MySqlClient; 

public class Program : MonoBehaviour { 
	private string query = " SELECT * FROM `EventManagerData` LIMIT 0 , 30 ";
	private string strdata = string.Empty;
    // Global variables 
	private static [color=#444444][color=orang[/color]e]System.Data.[/color]IDbConnection dbConnection;
    
    // Initialisation 
    public void Start() { 
        openSqlConnection();	
    } 
    
    // On quit 
    public void OnApplicationQuit() { 
        closeSqlConnection(); 
    } 

    // Connect to database 
    private static void openSqlConnection() { 
        string connectionString = "Server=localhost;" + 
            "Database=MainGame;" + 
            "User ID=root;" + 
            "Password=;" + 
            "Pooling=false"; 
        dbConnection = new [b][color=#444444][color=orange]MySql.Dat[/color]a.MySqlClient.[/color][/b]MySqlConnection(connectionString); 
        dbConnection.Open();
        Debug.Log("Connected to database.");
    } 
    
    // Disconnect from database 
    private static void closeSqlConnection() { 
        dbConnection.Close(); 
        dbConnection = null; 
        Debug.Log("Disconnected from database."); 
    } 
	
	void OnGUI()
	{
		query = GUI.TextArea(new Rect(30, 99, 200, 100),query);
		GUI.TextArea(new Rect(30, 199, 200, 100),strdata);
		if(GUI.Button(new Rect(30,10,90,90),"Lanza Query"))
		{
			doQuery(query);
		}
	}
	
	
	// MySQL Query 
    public void doQuery(string sqlQuery) 
    { 
        IDbCommand dbCommand = dbConnection.CreateCommand(); 
        dbCommand.CommandText = sqlQuery; 
        S[color=#444444][color=oran[/color]ge]ystem.Data.[/color]IDataReader reasder = dbCommand.ExecuteReader(); 
		while (reasder.Read())
		{
			Debug.Log("GetString  :: " + reasder.GetString(2));
			strdata = reasder.GetString(2);
		}
        reasder.Close(); 
        reasder = null; 
        dbCommand.Dispose(); 
        dbCommand = null; 
    }
}

[/code]

The client needs to have MySQL installed on the machine for this to work or have a DNS configured, you might be better off doing what is posted at this wiki:

http://www.unifycommunity.com/wiki/index.php?title=Server_Side_Highscores

Or

Other than just placing the DLL in the asset folder, I don’t think you need to do anything else with it other than calling the public methods.

I want to use Mono.CSharp.Evaluator in the script for conversation actions depending the answers

http://www.go-mono.com/docs/index.aspx?link=T%3AMono.CSharp.Evaluator

I need to use it this way

if(Evaluator.Run ("keyconversation1==true"))
{
     actions;
}

You can do this. (It bloats your webplayer like crazy). Just add the .dll files to your asset folder.
Mono.CSharp.dll I think contains a c# compiler with a .net api. I am totally enjoying being able to parse c# at runtime.

Bye, Lucas

Thank you Lucas,

It comforts me that you are parsing c# at runtime… that’s exactly what i am aiming to do.

I would really appreciate if you could provide me with a quick step by step, or an example for that matter showing us how you get to do it.

Adding the dlls to our asset folder is the first step, but i am kinda lost in what’s next on putting into use those dlls to parse c# at runtime. I CAN do this in the editor, but the problem shows up when we use the Web Player… i can’t parse c# in runtime.

I would really appreciate help, for your time, thank you.

Thank you Lucas,

I try parsing C# runtime in the webplayer yell eureca!! :smile:

i can evaluate strings :smile::smile:

but not cant

int intone = 34;

int inttwo = 33;

string cadena = "inttwo < intone";

if(Evaluator.Evaluate(cadena))
{
   Debug.Log(inttwo+"<"+intone);
}

you can?

how?

You can’t access local variables like that. You can however pass them trough static variables in a class.
Try something along the lines of below.
(email code, might need some tweaks to compile, but that’s the idea)

Bye, Lucas

public class DataHolder
{
	  public static int HeyThere = 4;
}


public class Test
{
	static void Main()
	{
		
		Mono.CSharp.Evaluator.Init(new string[] {} );
		Assembly a = Assembly.GetExecutingAssembly();
    Mono.CSharp.Evaluator.ReferenceAssembly(a);

		Debug.Log("result2: "+Mono.CSharp.Evaluator.Evaluate("DataHolder.HeyThere+5"));
  }
}