calling a function from another c# script

I’m trying to call a function from another script into a main script but it doesn’t seem to work no matter what i try.

using UnityEngine;
using System.Collections;

public class testbackground : MonoBehaviour {
	public int[] y;
	public int[] x;
	// Use this for initialization
	public void Start () {
	
	
	y[0] = 1;
	y[1] = 2;
	y[2] = 3;

	x[0] = 1;
    x[1] = 2;
	x[2] = 3;



	Cube();

	}
	

	public void Cube(){


		GameObject cube1 = GameObject.CreatePrimitive (PrimitiveType.Cube);
		cube1.renderer.material.mainTexture = Resources.Load<Texture2D>("00");
		cube1.transform.position = new Vector3 (0.5f, 0, 0);
		cube1.transform.localScale = new Vector3 (370f, 240f, 1f);
		cube1.transform.Rotate(new Vector3(0f, 180f, 0f));
		
	}
	// Update is called once per frame
	void Update () {
	
	}
}

So in this script i want to call Start into this script:

using UnityEngine;
using System.Collections;

public class Main : MonoBehaviour {
	public testbackground Tilemap;
	void Start () {
		Screen.showCursor = false;
		Tilemap = gameObject.AddComponent ("testbackground") as testbackground;
		Tilemap.Start();
	
	
	}
	


	// Update is called once per frame
	void Update () {
	
	}
}

but nothing happens on screen, the cube never gets created. but if i moved the Cube function into the main script it works when i call it.

PLs help, what am i doing wrong in calling the class from the other script ?

You shouldn’t call Start methods in classes that inherits monobehaviour. However you can always write a simple init function.

using UnityEngine;
using System.Collections;
 
public class testbackground : MonoBehaviour {
    public int[] y;
    public int[] x;

    void Start()
    {
        Init();
    }

    public void Init() 
    {
        y[0] = 1;
        y[1] = 2;
        y[2] = 3;
 
        x[0] = 1;
        x[1] = 2;
        x[2] = 3;
 
        Cube();
 
    }

    Cube()
    {
        ...
    }

Now you can easily call Init method to do what you do when you start running testbackground class.

And your code is ugly. Why not use a simple loop to fill your arrays?

int index = 0;
for(int i = 1; i < 4; i++)
{
    y[index] = i;
    x[index] = i;
    index++;
}

Plus, declare classes with uppercase initials while declaring variables with lowercase initials in C#.