C#: Call a script from another script

I need to use PlayerPrefs arrays so I’m going with this solution: http://wiki.unity3d.com/index.php/ArrayPrefs2 . In some paragraph, it says:

Have this script somewhere in your
project. Ideally it should be in the
Standard Assets folder; this way it
can be called from C# and Boo scripts
.
Call it PlayerPrefsX, and then you can
use the following functions

How it supposed to be called? I know I can attached to the gameobject, but is written as I can use something like Using PlayerPrefsX (C++ equivalent #include , PHP equivalent include(‘playerprefsx’) )

Is that way?

You do not need to “include” a C# script before you call it, unless it belongs to a namespace, in which case you can include it with the using directive. In your case PlayerPrefsX does not belong to a namespace so, just call something like:

PlayerPrefsX.Foobar();

…and it works.

Hey there! I have used ArrayPrefs2 and I think it has bugs while retrieving arrays. I didn’t have the time to fix that bug. So, I made my own for a project few months ago. You can use it:

private static string GetSerializedString (string[] data)
{
	if (data.Length == 0) return string.Empty;
	
	string result = string.IsNullOrEmpty(data [0]) ? "Error" : data[0];
	for (int i = 1; i < data.Length; i++)
	{
		if (string.IsNullOrEmpty(data_)) data *= "Error";*_

_ result += (“|” + data*);
}
return result;
}*_

private static string GetSerializedString (int[] data)
{
* if (data.Length == 0) return string.Empty;*

* string result = data [0].ToString ();*
* for (int i = 1; i < data.Length; i++)*
* {*
_ result += (“|” + data*);
}
return result;
}*_

// When you want to store a string array
public static void SetSectionInfo (string[] info)
{
* PlayerPrefs.SetString (“SectionInfo”, GetSerializedString(info));*
}

// When you want to retrieve a string array
public static string[] GetSectionInfo ()
{
* return PlayerPrefs.GetString (“SectionInfo”, “Error”).Split (‘|’);*
}

// Note: I have used ‘|’ as a separator. You may want to use a different separator based on your requirement.