C# static class not in Plugins folder

I found this MD5 code somewhere around here. Why won't this work if I don't put it in the Plugins folder? With Javascript I can make classes with static functions & variables and put it anywhere I want in the project and still reference it. I generally stick to Javascript in Unity so I'm not familiar with the quirks of C# in Unity.

using UnityEngine;
using System.Collections;

public class MD5 : MonoBehaviour
{
    public static string encode(string strToEncrypt)
    {
        System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding();
        byte[] bytes = ue.GetBytes(strToEncrypt);

        // encrypt bytes
        System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
        byte[] hashBytes = md5.ComputeHash(bytes);

        // Convert the encrypted bytes back to a string (base 16)
        string hashString = "";

        for (int i = 0; i 

Apparently the code got cut off in my question, but the rest of the code isn't important to the question.

1 Answer

1

If you're trying to use c# scripts from js, you'll pretty much always need to put the file into plugins. This is the same as trying to use js scripts from c#, it's an inherent issue with cross language compilation.

If you were coding solely in c#, the location of the file wouldn't matter at all

http://unity3d.com/support/documentation/ScriptReference/index.Script_compilation_28Advanced29.html

Ok, good to know. Thanks.