Inheritance: MonoBehaviour
Exemple #1
0
    static void Create()
    {
        GameObject         gameObject = new GameObject("ProceduralCylinder");
        ProceduralCylinder c          = gameObject.AddComponent <ProceduralCylinder>();
        MeshFilter         meshFilter = gameObject.GetComponent <MeshFilter>();

        meshFilter.mesh = new Mesh();
        c.Rebuild();
        c.AssignDefaultShader();
    }
Exemple #2
0
    private void OnEnable()
    {
        shape         = (ProceduralCylinder)target;
        pivotPosition = serializedObject.FindProperty("pivotPosition");
        smoothNormals = serializedObject.FindProperty("smoothNormals");
        height        = serializedObject.FindProperty("height");
        radius        = serializedObject.FindProperty("radius");
        segments      = serializedObject.FindProperty("segments");
        sectors       = serializedObject.FindProperty("sectors");

        var meshFilter = shape.GetComponent <MeshFilter>();
        var mesh       = meshFilter.sharedMesh;

        if (mesh == null)
        {
            shape.UpdateMesh();
        }
    }
    Planet InitPlanet(Vector3 pos)
    {
        Planet planet = Instantiate(planetPrefab).GetComponent <Planet>();

        planet.transform.position += pos;
        PlanetFiller filler = planet.gameObject.GetComponent <PlanetFiller>();

        Planetdata pd = planetBlueprints[Random.Range(0, planetBlueprints.Length)];

        planet.maxTime    = pd.timelimit;
        planet.grassColor = pd.grasscolor;

        filler.m_Prefabs = pd.props;

        ProceduralCylinder body = planet.gameObject.GetComponent <ProceduralCylinder>();

        body.minRadius = pd.minRadius;
        body.maxRadius = pd.maxRadius;

        body.Init();

        return(planet);
    }