protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);

            this.mouseoverAction = ObjectAction.None;
            this.mouseoverObject = null;
            this.mouseoverSelect = false;
        }
 protected override void OnSceneChanged()
 {
     base.OnSceneChanged();
     if (this.mouseoverObject != null && this.mouseoverObject.IsInvalid)
     {
         this.mouseoverObject = null;
     }
 }
Ejemplo n.º 3
0
            public override bool Equals(SelObj other)
            {
                if (other is SelVertex)
                {
                    return(this == (SelVertex)other);
                }

                return(this == (SelObj)other);
            }
Ejemplo n.º 4
0
    static void ExportResource()
    {
        string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d");

        if (path.Length != 0)
        {
            Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

            Debug.Log("Select Cnt : " + selection.Length);

            foreach (Object SelObj in selection)
            {
                Debug.Log("Select Name : " + SelObj.ToString());
            }

#if UNITY_ANDROID
            BuildPipeline.BuildAssetBundle(Selection.activeObject,
                                           selection, path,
                                           BuildAssetBundleOptions.CollectDependencies |
                                           BuildAssetBundleOptions.CompleteAssets |
                                           BuildAssetBundleOptions.DeterministicAssetBundle,
                                           BuildTarget.Android);
#endif


#if UNITY_IPHONE
            BuildPipeline.BuildAssetBundle(Selection.activeObject,
                                           selection, path,
                                           BuildAssetBundleOptions.CollectDependencies |
                                           BuildAssetBundleOptions.CompleteAssets |
                                           BuildAssetBundleOptions.DeterministicAssetBundle,
                                           BuildTarget.iPhone);
#endif

            Selection.objects = selection;
            selection         = null;
        }
    }
            public override bool Equals(SelObj other)
            {
                if (other is SelVertex)
                    return this == (SelVertex)other;

                return this == (SelObj)other;
            }
        protected void UpdateMouseover(Point mouseLoc)
        {
            bool         lastMouseoverSelect = this.mouseoverSelect;
            SelObj       lastMouseoverObject = this.mouseoverObject;
            ObjectAction lastMouseoverAction = this.mouseoverAction;

            if (this.actionAllowed && !this.CamActionRequiresCursor && this.CamAction == CameraAction.None)
            {
                this.ValidateSelectionStats();

                // Determine object at mouse position
                this.mouseoverObject = this.PickSelObjAt(mouseLoc.X, mouseLoc.Y);

                // Determine action variables
                Vector3     mouseSpaceCoord     = this.GetSpaceCoord(new Vector3(mouseLoc.X, mouseLoc.Y, this.selectionCenter.Z));
                float       scale               = this.GetScaleAtZ(this.selectionCenter.Z);
                const float boundaryThickness   = 10.0f;
                bool        tooSmall            = this.selectionRadius * scale <= boundaryThickness * 2.0f;
                bool        mouseOverBoundary   = MathF.Abs((mouseSpaceCoord - this.selectionCenter).Length - this.selectionRadius) * scale < boundaryThickness;
                bool        mouseInsideBoundary = !mouseOverBoundary && (mouseSpaceCoord - this.selectionCenter).Length < this.selectionRadius;
                bool        mouseAtCenterAxis   =
                    MathF.Abs(mouseSpaceCoord.X - this.selectionCenter.X) * scale < boundaryThickness ||
                    MathF.Abs(mouseSpaceCoord.Y - this.selectionCenter.Y) * scale < boundaryThickness;
                bool shift = (Control.ModifierKeys & Keys.Shift) != Keys.None;
                bool ctrl  = (Control.ModifierKeys & Keys.Control) != Keys.None;

                bool anySelection = this.actionObjSel.Count > 0;
                bool canMove      = this.actionObjSel.Any(s => s.IsActionAvailable(ObjectAction.Move));
                bool canRotate    = (canMove && this.actionObjSel.Count > 1) || this.actionObjSel.Any(s => s.IsActionAvailable(ObjectAction.Rotate));
                bool canScale     = (canMove && this.actionObjSel.Count > 1) || this.actionObjSel.Any(s => s.IsActionAvailable(ObjectAction.Scale));

                // Select which action to propose
                this.mouseoverSelect = false;
                if (ctrl)
                {
                    this.mouseoverAction = ObjectAction.RectSelect;
                }
                else if (anySelection && !tooSmall && mouseOverBoundary && mouseAtCenterAxis && this.selectionRadius > 0.0f && canScale)
                {
                    this.mouseoverAction = ObjectAction.Scale;
                }
                else if (anySelection && !tooSmall && mouseOverBoundary && canRotate)
                {
                    this.mouseoverAction = ObjectAction.Rotate;
                }
                else if (anySelection && mouseInsideBoundary && canMove)
                {
                    this.mouseoverAction = ObjectAction.Move;
                }
                else if (shift)                 // Lower prio than Ctrl, because Shift also modifies mouse actions
                {
                    this.mouseoverAction = ObjectAction.RectSelect;
                }
                else if (this.mouseoverObject != null && this.mouseoverObject.IsActionAvailable(ObjectAction.Move))
                {
                    this.mouseoverAction = ObjectAction.Move;
                    this.mouseoverSelect = true;
                }
                else
                {
                    this.mouseoverAction = ObjectAction.RectSelect;
                }
            }
            else
            {
                this.mouseoverObject = null;
                this.mouseoverSelect = false;
                this.mouseoverAction = ObjectAction.None;
            }

            // If mouseover changed..
            if (this.mouseoverObject != lastMouseoverObject ||
                this.mouseoverSelect != lastMouseoverSelect ||
                this.mouseoverAction != lastMouseoverAction)
            {
                // Adjust mouse cursor based on proposed action
                if (this.mouseoverAction == ObjectAction.Move)
                {
                    this.Cursor = CursorHelper.ArrowActionMove;
                }
                else if (this.mouseoverAction == ObjectAction.Rotate)
                {
                    this.Cursor = CursorHelper.ArrowActionRotate;
                }
                else if (this.mouseoverAction == ObjectAction.Scale)
                {
                    this.Cursor = CursorHelper.ArrowActionScale;
                }
                else
                {
                    this.Cursor = CursorHelper.Arrow;
                }
            }

            // Redraw if action gizmos might be visible
            if (this.actionAllowed)
            {
                this.Invalidate();
            }
        }