Why Doesn't This Work?

I recently downloaded the procedural unity example project and came across something that I can’t figure out. In one of their script theirs these lines:

private var perlin : Perlin;
private var fractal : FractalNoise;

I made them public but nothing showed up in the inspector. If you can’t assign something to it then whats the point of having it? What do these lines mean because I though you could only make variables ints, floats, booleans, ect… Then I put these lines of code in a new script and I got the error: The name ‘Perlin’ does not denote a valid type (‘not found’). Did you mean ‘TreeEditor.Perlin’? and The name ‘FractalNoise’ does not denote a valid type (‘not found’). Did you mean ‘TreeEditor.FractalNoise’?

Here is the whole script from the example project in case you need more info.

// This script is placed in public domain. The author takes no responsibility for any possible harm.

var gray = true;
var width = 128;
var height = 128;

var lacunarity = 6.18;
var h = 0.69;
var octaves = 8.379;
var offset = 0.75;
var scale = 0.09;

var offsetPos = 0.0;

private var texture : Texture2D;
private var perlin : Perlin;
private var fractal : FractalNoise;

function Start ()
	texture = new Texture2D(width, height, TextureFormat.RGB24, false);
	renderer.material.mainTexture = texture;

function Update()

function Calculate()
	if (perlin == null)
		perlin = new Perlin();
	fractal = new FractalNoise(h, lacunarity, octaves, perlin);
	for (var y = 0;y<height;y++)
		for (var x = 0;x<width;x++)
			if (gray)
				var value = fractal.HybridMultifractal(x*scale + Time.time, y * scale + Time.time, offset);
				texture.SetPixel(x, y, Color (value, value, value, value));
				offsetPos = Time.time;
				var valuex = fractal.HybridMultifractal(x*scale + offsetPos * 0.6, y*scale + offsetPos * 0.6, offset);
				var valuey = fractal.HybridMultifractal(x*scale + 161.7 + offsetPos * 0.2, y*scale + 161.7 + offsetPos * 0.3, offset);
				var valuez = fractal.HybridMultifractal(x*scale + 591.1 + offsetPos, y*scale + 591.1 + offsetPos * 0.1, offset);
				texture.SetPixel(x, y, Color (valuex, valuey, valuez, 1));

Also that script contains the line:

var valuex = fractal.HybridMultifractal(...);

If you search for this function you get nothing. This really stumps me because you can’t just make up functions! It cant be a .Net method because nothing is being imported.

Please help me under stand why there are made up functions and variables of type “Perlin” and “FractalNoise”.

Perlin and FractalNoise are custom classes defined by other scripts in the sample project (which most likely have the same names). If you’ve been groping along through unity scripting without knowing this much, I strongly recommend you review some basic tutorials on the subject. The javascript series from Walker Boys Studio would probably be a good place to start. Parts 22-25 goes over defining custom classes (which can be used as variable types, like Perlin) and class functions (like the HybridMultifractal function which is defined in the FractalNoise class)

I’m having the same problem. I can’t find those classes anywhere in the project. They just seem to come out of nowhere. Even when I use ‘Go To Declaration’ inside of Monodevelop, nothing comes up. It’s like their ghost classes.

The functions (HybridMultifractal and Perlin) and are located in the Perlin.cs script. You have to make sure to import this script as well, it is in the Plugins folder.