Exemplo n.º 1
0
    GameObject createSky()
    {
        GameObject skyGo = PrimitiveHelper.CreatePrimitive(PrimitiveType.Quad, false, "Sky");

        // Mesh meshCube =  PrimitiveHelper.GetPrimitiveMesh(PrimitiveType.Cube);

        skyGo.transform.position   = new Vector3(0, 100, 790);
        skyGo.transform.localScale = new Vector3(1700, 1200, 1);
        skyGo.transform.parent     = gameObject.transform;

        //9) Give it a Material
        // Material material = new Material(PrimitiveHelper.GetMaterialStandard());
        Material skyMa = new Material(Shader.Find("Aviator/LinearGradientColor"));

        skyMa.SetColor("_color1", AviatorColors.Sky);
        skyMa.SetColor("_color2", AviatorColors.Fog);
        MeshRenderer skyMr = skyGo.GetComponent <MeshRenderer>();

        skyMr.material          = skyMa;
        skyMr.shadowCastingMode = ShadowCastingMode.Off;
        skyMr.receiveShadows    = false;

        skyGo.isStatic = true;

        return(skyGo);
    }
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         var go = PrimitiveHelper.CreatePrimitive(PrimitiveType.Cube, true);
         var gP = Camera.main.ScreenPointToRay(Input.mousePosition).GetGridPosition();
         go.transform.position = gP;
         Debug.Log(gP);
     }
 }
Exemplo n.º 3
0
    GameObject createCabin()
    {
        GameObject engineGo = PrimitiveHelper.CreatePrimitive(PrimitiveType.Cube, false, "Cabin");
        Mesh       meshCube = engineGo.GetComponent <MeshFilter>().mesh;

        messWithCube(meshCube, new Vector4(-.2f, .6f, -.4f, .4f));

        // Material: assign color
        Material engineMa = engineGo.GetComponent <MeshRenderer>().material;

        engineMa.SetColor("_Color", AviatorColors.Red);

        engineGo.transform.localScale = new Vector3(80, 50, 50);
        // engineGo.transform.position = position;
        engineGo.transform.parent = parent.transform;

        return(engineGo);
    }
Exemplo n.º 4
0
    public GameObject createPropeller()
    {
        GameObject propeller = PrimitiveHelper.CreatePrimitive(PrimitiveType.Cube, false, "Propeller");
        Mesh       meshCube  = propeller.GetComponent <MeshFilter>().mesh;

        messWithCube(meshCube, new Vector4(-.5f, .5f, -.5f, .5f));

        // Material: assign color
        Material engineMa = propeller.GetComponent <MeshRenderer>().material;

        // engineMa.SetColor("_Color", AviatorColors.Brown);
        engineMa.color = AviatorColors.Brown;

        propeller.transform.localScale = new Vector3(20, 10, 10);
        // engineGo.transform.position = position;
        propeller.transform.parent = parent.transform;

        return(propeller);
    }
Exemplo n.º 5
0
        void ResetSegments()
        {
            if (segments != null && segments.Count > 0)
            {
                for (int i = 0; i < segments.Count; i += 0)
                {
                    GameObject tempSegment = segments[0];
                    segments.RemoveAt(0);
                    Destroy(tempSegment);
                }
            }
            if (shaderOverride == null)
            {
                segmentMaterial = new Material(Shader.Find("Unlit/Color"));
            }
            else
            {
                segmentMaterial = new Material(shaderOverride);
            }

            segmentMaterial.color = ValidColor;

            for (int i = 0; i < numSegments; i++)
            {
                var primitive = PrimitiveHelper.CreatePrimitive(shapeType, false);

                Transform segParent = new GameObject($"Segment {i}").transform;
                segParent.SetParent(transform);
                segParent.localPosition = Vector3.zero;

                primitive.transform.SetParent(segParent);

                primitive.GetComponent <MeshRenderer>().material = segmentMaterial;

                primitive.transform.forward =
                    segParent.rotation * PointerUtils.GetPrimitiveForward(shapeType);

                primitive.transform.localScale = PointerUtils.GetPrimitiveScale(shapeType);

                segments.Add(segParent.gameObject);
            }
        }
Exemplo n.º 6
0
    // Material seaMa = seaMr.material;
    // seaMa.SetColor("_Color", AviatorColors.Blue);
    // PrimitiveHelper.SetMaterialTransparent(seaMa);

    GameObject createCubeWithName(string name, Vector3 localScale, Vector3 position, Color color, GameObject p)
    {
        //1) Create an empty GameObject with the required Components
        GameObject engineGo = PrimitiveHelper.CreatePrimitive(PrimitiveType.Cube, false, name);
        // Mesh meshCube =  PrimitiveHelper.GetPrimitiveMesh(PrimitiveType.Cube);

        //9) Give it a Material
        Material engineMa = engineGo.GetComponent <MeshRenderer>().material;

        // todo should Material be saved for future use;
        // but definately create a instance for same color on the same render; like in primitivehelper;
        if (color.a < 1)
        {
            PrimitiveHelper.SetMaterialTransparent(engineMa);
        }
        engineMa.SetColor("_Color", color);

        engineGo.transform.localScale = localScale;
        engineGo.transform.position   = position;
        engineGo.transform.parent     = p.transform;

        return(engineGo);
    }