public static GearMesh AddGear(Vector3 position, float innerRadius, float rootRadius, float outerRadius, int sides, Material meshMatt = null, bool attachRigidbody = true)
        {
            MeshHelper.CheckMaterial(ref meshMatt);
            GameObject gear = new GameObject();

            gear.transform.position = position;

            GearMesh gearComponent = gear.AddComponent <GearMesh>();

            gearComponent.Build(innerRadius, rootRadius, outerRadius, sides, meshMatt);
            if (attachRigidbody)
            {
                gear.AddComponent <Rigidbody2D>();
            }
            return(gearComponent);
        }
Ejemplo n.º 2
0
        protected void BuildMesh(ref Material meshMatt)
        {
            if (!Validate || ValidateMesh())
            {
                MeshHelper.CheckMaterial(ref meshMatt);

                _Mesh = new Mesh();
                GetOrAddComponents();
                C_MR.material = meshMatt;

                BuildMeshComponents();
                UpdateMeshFilter();
                UpdateCollider();
            }
            else
            {
                Debug.LogError("MeshBase::BuildMesh: " + name + " generation failed");
            }
        }
        //assign variables, get components and build mesh
        public void Build(float innerRadius, float rootRadius, float outerRadius, int sides, Material meshMatt = null)
        {
            MeshHelper.CheckMaterial(ref meshMatt);
            name             = "Gear";
            this.innerRadius = innerRadius;
            this.rootRadius  = rootRadius;
            this.outerRadius = outerRadius;
            this.sides       = sides;

            _Mesh = new Mesh();
            GetOrAddComponents();

            C_MR.material = meshMatt;

            if (!Validate || ValidateMesh())
            {
                BuildMeshComponents();
                UpdateMeshFilter();
                UpdateCollider();
            }
        }