Exemple #1
0
 //---------------------------------------------------------------------------	PUBLIC MEMBERS
 public void SetEditMode(EEditMode eEditMode)
 {
     // Sets the edit mode safely.  (Needed if a hotspot is currently activated)
     if (_EditMode == eEditMode)
         return;
     if (_oHotSpotCurrent) {								// Temporarily deactivate current hotspot...
         _oHotSpotCurrent.OnDeactivate();
         _oHotSpotCurrent.OnHoverEnd();
     }
     _EditMode = eEditMode;								//... adopt the new mode...
     Debug.Log("Edit mode now set to '" + _EditMode.ToString() + "'");
     if (_oHotSpotCurrent) {								//... and re-activate hotspot with the new mode.  This will re-initialize correctly for gizmo operation with the new mode
         _oHotSpotCurrent.OnHoverBegin();
         _oHotSpotCurrent.OnActivate(true, false, false);
     }
 }
Exemple #2
0
    void Initialize(CHotSpot oHotSpot, bool bMiddleClickOp)
    {
        _oHotSpot = oHotSpot;
        _bMiddleClickOp = bMiddleClickOp;
        _eEditMode = CGame.INSTANCE._oCursor._EditMode;		// Our gizmo mode is the mode of the cursor edit mode at startup.
        gameObject.name = "Gizmo-" + _eEditMode.ToString();

        //=== Set the initializing gizmo the position and rotation of the hotspot.  We have to move/rotate both at every frame ===
        transform.parent = null;								// Note that we are NOT a child of our owning hotspot...
        transform.position = _oHotSpot.transform.position;
        if (_eEditMode != EEditMode.Move)				// Only start at the object's current location if we're rotate or scale.  we always move with axis-aliged gizmo
            transform.rotation = _oHotSpot.transform.rotation;
        transform.localScale = new Vector3(CCursor.C_GizmoScale, CCursor.C_GizmoScale, CCursor.C_GizmoScale);		// Gizmo is always drawn at the default scale regardless of hotspot scaling.
        if (_eEditMode == EEditMode.Rotate)				// Magnify the rotation cursor a given ratio as it frequently needs a bigger size for easy user manipulation
            transform.localScale *= CCursor.C_GizmoScale_RotationMultiplier;

        //=== Handling of special 'hidden helper object' mode = Hide gizmo and immediately begin move opeation along y,z axis ===
        if (CGame.INSTANCE._bGameModeBasicInteractions) {
            Renderer[] aRend = transform.GetComponentsInChildren<Renderer>();	//###IMPROVE? Instead of hiding all gizmo elements, would it be too tough to just not instantiate its prefab??
            foreach (Renderer oRend in aRend)
                oRend.enabled = false;
            _eModeGizmo = EModeGizmo.S2_UserDraggingGizmoPart;		// Direct fast-track to immediately drag gizmo...
            GizmoTransform_Begin(true);								// ... by forcing a move operation on YZ plane
        } else {
            _eModeGizmo = EModeGizmo.S1_WaitingLeftClickGizmoPart;
        }
    }