Beispiel #1
0
 	void OnEnable(){
		_gs = (GearSupport) target;
		undoManager = new HOEditorUndoManager( _gs, "Gear Editor" );
		
	}
Beispiel #2
0
    public void CreateGear(GameObject Gear)
    {
        GearRenderer g = new GearRenderer();
        Vector3      origin;

        var sv = SceneView.currentDrawingSceneView;

        if (sv == null && SceneView.lastActiveSceneView != null)
        {
            sv = SceneView.lastActiveSceneView;
        }

        if (sv == null)
        {
            Debug.LogError("No Scene present!");
            return;
        }

        Camera cam = SceneView.lastActiveSceneView.camera;

        Ray ray = cam.ScreenPointToRay(new Vector3(cam.pixelWidth / 2.0f, cam.pixelHeight / 2.0f, 0));

        origin = ray.GetPoint(5.0f);

        g.Height          = Height;
        g.HubSides        = HubSides;
        g.HubHeight       = Height;
        g.HubRadius       = HubRadius;
        g.InnerRadius     = InnerToothRadius;
        g.OuterRadius     = OutsideToothRadius;
        g.RingRadius      = RingRadius;
        g.OuterWidthPct   = ToothWidthPct / 100.0f;
        g.ToothRotation   = ToothRotation;
        g.TopScale        = TopScalePct / 100.0f;
        g.TopRotation     = TopRotation;
        g.SpokeCount      = SpokeCount;
        g.QtyTeeth        = QtyTeeth;
        g.SpokeWidthInner = SpokeWidthInner;
        g.SpokeWidthOuter = SpokeWidthOuter;
        g.SpokeType       = SpokeType;
        g.SpokeIndent     = SpokeIndent;
        g.HubHeight       = hubHeight;


        GearSupport gs = Gear.GetComponent <GearSupport>();

        if (gs == null)
        {
            gs = Gear.AddComponent <GearSupport>();
        }

        gs.GearMaterial = GearMaterial;
        gs.RenderedGear = g;

        gs.OutsideToothRadius = this.OutsideToothRadius;
        gs.InnerToothRadius   = this.InnerToothRadius;
        gs.ToothRotation      = this.ToothRotation;
        gs.QtyTeeth           = this.QtyTeeth;
        gs.ToothWidthPct      = this.ToothWidthPct;
        gs.RingRadius         = this.RingRadius;
        gs.GearMaterial       = this.GearMaterial;
        gs.Height             = this.Height;
        gs.TopRotation        = this.TopRotation;
        gs.TopScalePct        = this.TopScalePct;

        gs.SpokeCount      = this.SpokeCount;
        gs.SpokeIndent     = this.SpokeIndent;
        gs.SpokeType       = this.SpokeType;
        gs.hubHeight       = this.hubHeight;
        gs.HubRadius       = this.HubRadius;
        gs.HubSides        = this.HubSides;
        gs.SpokeWidthInner = this.SpokeWidthInner;
        gs.SpokeWidthOuter = this.SpokeWidthOuter;
        gs.LockRatio       = this.LockRatio;

        //gs.DebugTextMaterial = this.DebugTextMaterial;
        //gs.DebugTextFont = this.DebugTextFont;

        gs.ProcessGear(Gear, origin);

        Gear.transform.position = origin;

        Debug.Log("Gear Rendered " + origin.ToString());
    }
Beispiel #3
0
 void OnEnable()
 {
     _gs         = (GearSupport)target;
     undoManager = new HOEditorUndoManager(_gs, "Gear Editor");
 }
Beispiel #4
0
    public void CreateGear()
    {
        GameObject o = new GameObject(GearSupport.GetGearName());

        CreateGear(o);
    }