예제 #1
0
        //En la escena
        void OnSceneGUI()
        {
            Damager damager = (Damager)target;

            //si Damager no esta activo retorne y apague el cuadrito verde que se dibuja en la escena
            if (!damager.enabled)
            {
                return;
            }
            //en una matrix asigne la posicion local del transform del damager
            Matrix4x4 handleMatrix = damager.transform.localToWorldMatrix;

            handleMatrix.SetRow(0, Vector4.Scale(handleMatrix.GetRow(0), new Vector4(1f, 1f, 0f, 1f)));
            handleMatrix.SetRow(1, Vector4.Scale(handleMatrix.GetRow(1), new Vector4(1f, 1f, 0f, 1f)));
            handleMatrix.SetRow(2, new Vector4(0f, 0f, 1f, damager.transform.position.z));
            using (new Handles.DrawingScope(handleMatrix))
            {   //asigno a la variable s_Box.. declarada arriba las opciones dadas en el inspector
                s_BoxBoundsHandle.center = damager.offset;
                s_BoxBoundsHandle.size   = damager.size;

                s_BoxBoundsHandle.SetColor(s_EnabledColor); //Asigno el color dado arriba
                EditorGUI.BeginChangeCheck();               //Comprueba si algo a cambiado en el bloque de codigo
                s_BoxBoundsHandle.DrawHandle();
                if (EditorGUI.EndChangeCheck())             //finaliza los cambios echos en beginchangeCheck
                {
                    Undo.RecordObject(damager, "Modify Damager");

                    damager.size   = s_BoxBoundsHandle.size;
                    damager.offset = s_BoxBoundsHandle.center;
                }
            }
        }
예제 #2
0
    private void OnSceneGUI()
    {
        TileControl tileControl = (TileControl)target;

        if (!tileControl.enabled)
        {
            return;
        }

        Matrix4x4 handleMatrix = tileControl.transform.localToWorldMatrix;

        handleMatrix.SetRow(0, Vector4.Scale(handleMatrix.GetRow(0), new Vector4(1f, 1f, 0f, 1f)));
        handleMatrix.SetRow(1, Vector4.Scale(handleMatrix.GetRow(1), new Vector4(1f, 1f, 0f, 1f)));
        handleMatrix.SetRow(2, new Vector4(0f, 0f, 1f, tileControl.transform.position.z));

        using (new Handles.DrawingScope(handleMatrix))
        {
            boxBoundsHandle.center = tileControl.center;
            boxBoundsHandle.size   = tileControl.dimensions;

            boxBoundsHandle.SetColor(enabledColor);
            EditorGUI.BeginChangeCheck();
            boxBoundsHandle.DrawHandle();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(tileControl, "Modify Tile Control");

                tileControl.dimensions = new Vector2((int)boxBoundsHandle.size.x, (int)boxBoundsHandle.size.y);
            }
        }
    }
        public override void OnEnable()
        {
            base.OnEnable();

            m_Materials         = serializedObject.FindProperty("m_Materials");
            m_BlendShapeWeights = serializedObject.FindProperty("m_BlendShapeWeights");
            m_AABB      = serializedObject.FindProperty("m_AABB");
            m_DirtyAABB = serializedObject.FindProperty("m_DirtyAABB");

            m_BoundsHandle.SetColor(Handles.s_BoundingBoxHandleColor);

            InitializeProbeFields();
            InitializeLightingFields();

            List <string> excludedProperties = new List <string>();

            excludedProperties.AddRange(new[]
            {
                "m_CastShadows",
                "m_ReceiveShadows",
                "m_MotionVectors",
                "m_Materials",
                "m_BlendShapeWeights",
                "m_AABB",
                "m_LightmapParameters",
                "m_DynamicOccludee"
            });
            excludedProperties.AddRange(Probes.GetFieldsStringArray());
            m_ExcludedProperties = excludedProperties.ToArray();
        }
예제 #4
0
    public void OnSceneGUI()
    {
        _bounds = (CameraBounds2D)target;
        Matrix4x4 handleMatrix = _bounds.transform.localToWorldMatrix;

        handleMatrix.SetRow(0, Vector4.Scale(handleMatrix.GetRow(0), new Vector4(1f, 1f, 0f, 1f)));
        handleMatrix.SetRow(1, Vector4.Scale(handleMatrix.GetRow(1), new Vector4(1f, 1f, 0f, 1f)));
        handleMatrix.SetRow(2, new Vector4(0f, 0f, 1f, _bounds.transform.position.z));

        using (new Handles.DrawingScope(handleMatrix))
        {
            m_BoundsHandle.center = _bounds.offset;
            m_BoundsHandle.size   = _bounds.scaleBound;
            m_BoundsHandle.SetColor(Color.white);
            EditorGUI.BeginChangeCheck();
            m_BoundsHandle.DrawHandle();
            Rect rect = new Rect(m_BoundsHandle.center.x - (m_BoundsHandle.size.x / 2), m_BoundsHandle.center.y - (m_BoundsHandle.size.y / 2), m_BoundsHandle.size.x, m_BoundsHandle.size.y);
            Handles.DrawSolidRectangleWithOutline(rect, new Color(1, 1, 1, 0.1f), Color.yellow);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(_bounds, string.Format("Modify {0}", ObjectNames.NicifyVariableName(_bounds.GetType().Name)));

                // test for size change after using property setter in case input data was sanitized
                Vector2 oldSize = _bounds.scaleBound;
                _bounds.scaleBound = m_BoundsHandle.size;

                // because projection of offset is a lossy operation, only do it if the size has actually changed
                // this check prevents drifting while dragging handle when size is zero (case 863949)
                if (_bounds.scaleBound != oldSize)
                {
                    _bounds.offset = m_BoundsHandle.center;
                }
            }
        }
    }
예제 #5
0
        private void OnSceneGUI()
        {
            Damager damager = (Damager)target;

            if (!damager.enabled)
                return;

            Matrix4x4 handleMatrix = damager.transform.localToWorldMatrix;
            handleMatrix.SetRow(0, Vector4.Scale(handleMatrix.GetRow(0), new Vector4(1f, 1f, 0f, 1f)));
            handleMatrix.SetRow(1, Vector4.Scale(handleMatrix.GetRow(1), new Vector4(1f, 1f, 0f, 1f)));
            handleMatrix.SetRow(2, new Vector4(0f, 0f, 1f, damager.transform.position.z));
            using (new Handles.DrawingScope(handleMatrix))
            {
                s_BoxBoundsHandle.center = damager.offset;
                s_BoxBoundsHandle.size = damager.size;

                s_BoxBoundsHandle.SetColor(s_EnabledColor);
                EditorGUI.BeginChangeCheck();
                s_BoxBoundsHandle.DrawHandle();
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(damager, "Modify Damager");

                    damager.size = s_BoxBoundsHandle.size;
                    damager.offset = s_BoxBoundsHandle.center;
                }
            }
        }
예제 #6
0
        private void OnEnable()
        {
            m_Comp = (GridSensorComponent2D)target;
            Undo.undoRedoPerformed += OnUndoRedo;

            m_BoundsHandle = new BoxBoundsHandle();
            m_BoundsHandle.SetColor(Color.white);
        }
예제 #7
0
        private void OnEnable()
        {
#if UNITY_2017_1_OR_NEWER
            placementBoundsHandle = new BoxBoundsHandle();
#else
            placementBoundsHandle = new BoxBoundsHandle(0);
#endif
            placementBoundsHandle.SetColor(Color.magenta);
        }
        protected virtual void OnSceneGUI()
        {
            if (!editingCollider)
            {
                return;
            }

            BoxCollider2D collider = (BoxCollider2D)target;

            if (Mathf.Approximately(collider.transform.lossyScale.sqrMagnitude, 0f))
            {
                return;
            }

            // collider matrix is 2d projection of transform's rotation onto x/y plane about transform's origin
            Matrix4x4 handleMatrix = collider.transform.localToWorldMatrix;

            handleMatrix.SetRow(0, Vector4.Scale(handleMatrix.GetRow(0), new Vector4(1f, 1f, 0f, 1f)));
            handleMatrix.SetRow(1, Vector4.Scale(handleMatrix.GetRow(1), new Vector4(1f, 1f, 0f, 1f)));
            handleMatrix.SetRow(2, new Vector4(0f, 0f, 1f, collider.transform.position.z));
            if (collider.usedByComposite && collider.composite != null)
            {
                // composite offset is rotated by composite's transformation matrix and projected back onto 2D plane
                var compositeOffset = collider.composite.transform.rotation * collider.composite.offset;
                compositeOffset.z = 0f;
                handleMatrix      = Matrix4x4.TRS(compositeOffset, Quaternion.identity, Vector3.one) * handleMatrix;
            }
            using (new Handles.DrawingScope(handleMatrix))
            {
                m_BoundsHandle.center = collider.offset;
                m_BoundsHandle.size   = collider.size;

                m_BoundsHandle.SetColor(collider.enabled ? Handles.s_ColliderHandleColor : Handles.s_ColliderHandleColorDisabled);
                EditorGUI.BeginChangeCheck();
                m_BoundsHandle.DrawHandle();
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(collider, string.Format("Modify {0}", ObjectNames.NicifyVariableName(target.GetType().Name)));

                    // test for size change after using property setter in case input data was sanitized
                    Vector2 oldSize = collider.size;
                    collider.size = m_BoundsHandle.size;

                    // because projection of offset is a lossy operation, only do it if the size has actually changed
                    // this check prevents drifting while dragging handle when size is zero (case 863949)
                    if (collider.size != oldSize)
                    {
                        collider.offset = m_BoundsHandle.center;
                    }
                }
            }
        }
예제 #9
0
        private void OnEnable()
        {
            m_SpriteSkin             = (SpriteSkin)target;
            m_RootBoneProperty       = serializedObject.FindProperty("m_RootBone");
            m_BoneTransformsProperty = serializedObject.FindProperty("m_BoneTransforms");
            m_BoundsProperty         = serializedObject.FindProperty("m_Bounds");
            m_CurrentSprite          = m_SpriteSkin.spriteRenderer.sprite;
            m_BoundsHandle.axes      = BoxBoundsHandle.Axes.X | BoxBoundsHandle.Axes.Y;
            m_BoundsHandle.SetColor(s_BoundingBoxHandleColor);

            SetupReorderableList();

            Undo.undoRedoPerformed += UndoRedoPerformed;
        }
예제 #10
0
        public override void OnEnable()
        {
            base.OnEnable();

            m_AABB                = serializedObject.FindProperty("m_AABB");
            m_DirtyAABB           = serializedObject.FindProperty("m_DirtyAABB");
            m_BlendShapeWeights   = serializedObject.FindProperty("m_BlendShapeWeights");
            m_Quality             = serializedObject.FindProperty("m_Quality");
            m_UpdateWhenOffscreen = serializedObject.FindProperty("m_UpdateWhenOffscreen");
            m_Mesh                = serializedObject.FindProperty("m_Mesh");
            m_RootBone            = serializedObject.FindProperty("m_RootBone");

            m_BoundsHandle.SetColor(Handles.s_BoundingBoxHandleColor);
        }
예제 #11
0
    private void OnSceneGUI()
    {
        Bullet bullet = (Bullet)target;

        boxBoundHandle.size   = bullet.damageSize;
        boxBoundHandle.center = bullet.transform.position;
        boxBoundHandle.SetColor(Color.red);

        EditorGUI.BeginChangeCheck();
        boxBoundHandle.DrawHandle();
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(bullet, "Modify bullet Area");

            bullet.damageSize = boxBoundHandle.size;
        }
    }
예제 #12
0
    private void OnSceneGUI()
    {
        Damager damager = (Damager)target;

        boxBoundHandle.size   = damager.size;
        boxBoundHandle.center = damager.transform.position;
        boxBoundHandle.SetColor(Color.red);

        EditorGUI.BeginChangeCheck();
        boxBoundHandle.DrawHandle();
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(damager, "Modify Damager Area");

            damager.size = boxBoundHandle.size;
        }
    }
예제 #13
0
        private void OnEnable()
        {
            m_SpriteSkin       = (SpriteSkin)target;
            m_RootBoneProperty = serializedObject.FindProperty("m_RootBone");
#if ENABLE_ANIMATION_PERFORMANCE
            m_UseBatching = serializedObject.FindProperty("m_UseBatching");
#endif
            m_BoneTransformsProperty = serializedObject.FindProperty("m_BoneTransforms");
            m_AlwaysUpdateProperty   = serializedObject.FindProperty("m_AlwaysUpdate");
            m_CurrentSprite          = m_SpriteSkin.spriteRenderer.sprite;
            m_BoundsHandle.axes      = BoxBoundsHandle.Axes.X | BoxBoundsHandle.Axes.Y;
            m_BoundsHandle.SetColor(s_BoundingBoxHandleColor);

            SetupReorderableList();

            Undo.undoRedoPerformed += UndoRedoPerformed;
        }
예제 #14
0
        private void OnEnable()
        {
            allowRotation = serializedObject.FindProperty("AllowRotation");
            repeatMode    = serializedObject.FindProperty("RepeatMode");
            overrideAutomaticTileBounds = serializedObject.FindProperty("OverrideAutomaticTileBounds");
            tileBoundsOverride          = serializedObject.FindProperty("TileBoundsOverride");
            entrance = serializedObject.FindProperty("Entrance");
            exit     = serializedObject.FindProperty("Exit");


#if UNITY_2017_1_OR_NEWER
            overrideBoundsHandle = new BoxBoundsHandle();
#else
            overrideBoundsHandle = new BoxBoundsHandle(0);
#endif

            overrideBoundsHandle.SetColor(Color.red);
        }
        void OnSceneGUI()
        {
            Damager damager = (Damager)target;

            if (!damager.enabled || m_UseTriggerColliderProp.boolValue)
            {
                return;
            }

            Matrix4x4 handleMatrix = damager.transform.localToWorldMatrix;

            handleMatrix.SetRow(0, Vector4.Scale(handleMatrix.GetRow(0), new Vector4(1f, 1f, 0f, 1f)));
            handleMatrix.SetRow(1, Vector4.Scale(handleMatrix.GetRow(1), new Vector4(1f, 1f, 0f, 1f)));
            handleMatrix.SetRow(2, new Vector4(0f, 0f, 1f, damager.transform.position.z));
            using (new Handles.DrawingScope(handleMatrix))
            {
                s_BoxBoundsHandle.center = damager.offset;
                s_BoxBoundsHandle.size   = damager.size;

                s_BoxBoundsHandle.SetColor(s_EnabledColor);

                //Check if any control was changed inside a block of code.
                EditorGUI.BeginChangeCheck();

                // Block of code with controls
                // this may set GUI.changed to true.
                s_BoxBoundsHandle.DrawHandle();

                //if true, GUI.changed was set to true
                if (EditorGUI.EndChangeCheck())
                {
                    // Code to execute if GUI.changed
                    // was set to true inside the block of code above.

                    //Records any changes done on the object after the RecordObject function
                    //name: The title of the action to appear in the undo history (i.e. visible in the undo menu).
                    Undo.RecordObject(damager, "Modify Damager");

                    damager.size   = s_BoxBoundsHandle.size;
                    damager.offset = s_BoxBoundsHandle.center;
                }
            }
        }
예제 #16
0
    void OnSceneGUI()
    {
        TakeDamager damager = (TakeDamager)target;

        if (!damager.enabled)
        {
            return;
        }

        Matrix4x4 handleMatrix = damager.transform.localToWorldMatrix;

        ////Hotkang 2018.7.24 疑问: 用处何在? 注释掉后暂未发现区别
        ////Debug.Log(handleMatrix);
        handleMatrix.SetRow(0, Vector4.Scale(handleMatrix.GetRow(0), new Vector4(1f, 1f, 0f, 1f)));
        handleMatrix.SetRow(1, Vector4.Scale(handleMatrix.GetRow(1), new Vector4(1f, 1f, 0f, 1f)));
        handleMatrix.SetRow(2, new Vector4(0f, 0f, 1f, damager.transform.position.z));
        ////Debug.Log(handleMatrix);
        using (new Handles.DrawingScope(handleMatrix))
        {
            s_BoxBoundsHandle.center = damager.offset;
            s_BoxBoundsHandle.size   = damager.size;

            s_BoxBoundsHandle.SetColor(s_EnabledColor);
            EditorGUI.BeginChangeCheck();
            s_BoxBoundsHandle.DrawHandle();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(damager, "Modify Damager");

                damager.size   = s_BoxBoundsHandle.size;
                damager.offset = s_BoxBoundsHandle.center;
            }
        }
        // 画点
        //Handles.DotHandleCap(0, damager.hitPoint+ new Vector2(10, 0), Quaternion.identity, 2, EventType.DragUpdated);
        //Handles.DotHandleCap(0, damager.hitPoint + new Vector2(0, 5), Quaternion.identity, 2, EventType.DragUpdated);
        //Debug.Log("drow nice");
    }
예제 #17
0
 private void OnEnable()
 {
     m_BoundsHandle = new BoxBoundsHandle();
     m_BoundsHandle.SetColor(Color.white);
 }
예제 #18
0
 protected virtual void OnEnable()
 {
     m_BoundsHandle.SetColor(Handles.s_ColliderHandleColor);
 }