- Home /
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 </pre>
Apparently the code got cut off in my question, but the rest of the code isn't important to the question.
Answer by Mike 3 · Apr 08, 2011 at 09:23 PM
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
Your answer
Follow this Question
Related Questions
MonoBehaviour methods in non-MonoBehaviour class 1 Answer
If there is only 1 instance of a class, should it be Static? - C# 2 Answers
How to list all the properties and methods from the class? 1 Answer
cannot be assigned to (it is read-only) Problem 2 Answers
Update() in non-component script? 3 Answers