The first script is very long, and I need to use only the top of it:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mBitmap2MeshV30a : MonoBehaviour
{
public Texture2D SourceTexture;
private float Pixel_vs_Unit_Scale = 1;
public float extrudeDepth = 1;
private Vector2 scanpoint;
private bool gotStart = false;
private int maxsteps = 512;
public bool invertFaces = false;
private Mesh srcMesh;
private mMeshExtrusion2.Edge[] precomputedEdges;
private List<ExtrudedTrailSectionBM3> sections;
public class ExtrudedTrailSectionBM3
{
public Vector3 point;
public Matrix4x4 matrix;
public float time;
}
I need to assign a value to SourceTexture
from another script. This is the other script:
void Start ()
{
text2d = new Texture2D(10, 10, TextureFormat.ARGB32, false);
System.Drawing.Font myf = new System.Drawing.Font(FontFamily.GenericSerif, 12);
Image myimage = DrawText("Hello", myf, System.Drawing.Color.Red, System.Drawing.Color.Black);
Bitmap mybitmap = new Bitmap(myimage);
MemoryStream msFinger = new MemoryStream();
mybitmap.Save(msFinger, mybitmap.RawFormat);
text2d.LoadImage(msFinger.ToArray());
filter.GetComponent<Renderer>().material.mainTexture = text2d;
mBitmap2MeshV30a bb = new mBitmap2MeshV30a();
bb.SourceTexture = text2d;
}
The problem is I can't make a new mBitmap2MeshV30a bb = new mBitmap2MeshV30a();
. Both scripts are attached to the same GameObject, in the hierarchy.
MonoBehaviours
withnew
. Are you looking forGetComponent
to access an existing component, orAddComponent
to attach a new component? \$\endgroup\$ – DMGregory♦ Sep 30 '17 at 0:36