GetLastRectAbsolute() public static method

public static GetLastRectAbsolute ( ) : Rect
return Rect
Example #1
0
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property,
                                   UnityEngine.GUIContent label)
        {
            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            UnityEditor.EditorGUI.BeginProperty(position, label, property);

            SetupSerializedProperties(property);

            // Draw label
            position = UnityEditor.EditorGUI.PrefixLabel(position,
                                                         UnityEngine.GUIUtility.GetControlID(UnityEngine.FocusType.Passive), label);

            /************************************************Update Properties**************************************************/
            var componentGuid = new System.Guid[m_guidProperty.Length];

            for (var i = 0; i < componentGuid.Length; i++)
            {
                var guidBytes = AkUtilities.GetByteArrayProperty(m_guidProperty[i]);
                componentGuid[i] = guidBytes == null ? System.Guid.Empty : new System.Guid(guidBytes);
            }

            var componentName = UpdateIds(componentGuid);
            /*******************************************************************************************************************/

            /********************************************Draw GUI***************************************************************/
            var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.button);

            style.alignment = UnityEngine.TextAnchor.MiddleLeft;
            style.fontStyle = UnityEngine.FontStyle.Normal;

            if (string.IsNullOrEmpty(componentName))
            {
                SetEmptyComponentName(ref componentName, ref style);
            }

            if (UnityEngine.GUI.Button(position, componentName, style))
            {
                m_pressedPosition  = position;
                m_buttonWasPressed = true;

                // We don't want to set object as dirty only because we clicked the button.
                // It will be set as dirty if the wwise object has been changed by the tree view.
                UnityEngine.GUI.changed = false;
            }

            var currentEvent = UnityEngine.Event.current;

            if (currentEvent.type == UnityEngine.EventType.Repaint && m_buttonWasPressed && m_pressedPosition.Equals(position))
            {
                m_serializedObject = property.serializedObject;
                m_pickerPos        = AkUtilities.GetLastRectAbsolute(position);
                UnityEditor.EditorApplication.delayCall += DelayCreateCall;
                m_buttonWasPressed = false;
            }

            HandleDragAndDrop(currentEvent, position);

            UnityEditor.EditorGUI.EndProperty();
        }
Example #2
0
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property,
                                   UnityEngine.GUIContent label)
        {
            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            UnityEditor.EditorGUI.BeginProperty(position, label, property);

            SetupSerializedProperties(property);

            // Draw label
            position = UnityEditor.EditorGUI.PrefixLabel(position,
                                                         UnityEngine.GUIUtility.GetControlID(UnityEngine.FocusType.Passive), label);

            var componentGuid = new System.Guid[m_guidProperty.Length];

            for (var i = 0; i < componentGuid.Length; i++)
            {
                var guidBytes = AkUtilities.GetByteArrayProperty(m_guidProperty[i]);
                componentGuid[i] = guidBytes == null ? System.Guid.Empty : new System.Guid(guidBytes);
            }

            var componentName = UpdateIds(componentGuid);
            var style         = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.button);

            style.alignment = UnityEngine.TextAnchor.MiddleLeft;
            style.fontStyle = UnityEngine.FontStyle.Normal;

            if (string.IsNullOrEmpty(componentName))
            {
                SetEmptyComponentName(ref componentName, ref style);
            }

            if (UnityEngine.GUI.Button(position, componentName, style))
            {
                new AkWwiseComponentPicker.PickerCreator
                {
                    objectType       = m_objectType,
                    guidProperty     = m_guidProperty,
                    idProperty       = m_IDProperty,
                    pickerPosition   = AkUtilities.GetLastRectAbsolute(position),
                    serializedObject = property.serializedObject
                };

                AkWwiseComponentPicker.LastFocusedWindow = UnityEditor.EditorWindow.focusedWindow;
            }

            HandleDragAndDrop(position);

            UnityEditor.EditorGUI.EndProperty();
        }
Example #3
0
    public override void OnInspectorGUI()
    {
        if (m_AkEventPlayable != null && m_AkEventPlayable.OwningClip != null)
        {
            m_AkEventPlayable.OwningClip.displayName = name;
        }
        serializedObject.Update();

        UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);

        using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
        {
            UnityEditor.EditorGUILayout.PropertyField(overrideTrackEmitterObject,
                                                      new UnityEngine.GUIContent("Override Track Object: "));
            if (overrideTrackEmitterObject.boolValue)
            {
                UnityEditor.EditorGUILayout.PropertyField(emitterObjectRef, new UnityEngine.GUIContent("Emitter Object Ref: "));
            }
            UnityEditor.EditorGUILayout.PropertyField(retriggerEvent, new UnityEngine.GUIContent("Retrigger Event: "));
            UnityEditor.EditorGUILayout.PropertyField(akEvent, new UnityEngine.GUIContent("Event: "));
        }

        if (m_AkEventPlayable != null && m_AkEventPlayable.OwningClip != null)
        {
            var componentName = GetEventName(m_AkEventPlayable.akEvent.valueGuid);
            m_AkEventPlayable.OwningClip.displayName = componentName;
        }

        serializedObject.ApplyModifiedProperties();

        if (!m_AkEventPlayable.akEvent.IsValid())
        {
            new AkWwiseComponentPicker.PickerCreator
            {
                objectType       = AkWwiseProjectData.WwiseObjectType.EVENT,
                guidProperty     = m_guidProperty,
                idProperty       = m_IDProperty,
                pickerPosition   = AkUtilities.GetLastRectAbsolute(UnityEngine.GUILayoutUtility.GetLastRect()),
                serializedObject = akEvent.serializedObject
            };
        }
    }
    public override void OnInspectorGUI()
    {
        if (m_AkEventPlayable != null && m_AkEventPlayable.OwningClip != null)
        {
            m_AkEventPlayable.OwningClip.displayName = name;
        }
        serializedObject.Update();

        UnityEngine.GUILayout.Space(2);

        UnityEngine.GUILayout.BeginVertical("Box");
        {
            UnityEditor.EditorGUILayout.PropertyField(overrideTrackEmitterObject,
                                                      new UnityEngine.GUIContent("Override Track Object: "));
            if (overrideTrackEmitterObject.boolValue)
            {
                UnityEditor.EditorGUILayout.PropertyField(emitterObjectRef, new UnityEngine.GUIContent("Emitter Object Ref: "));
            }
            UnityEditor.EditorGUILayout.PropertyField(retriggerEvent, new UnityEngine.GUIContent("Retrigger Event: "));
            UnityEditor.EditorGUILayout.PropertyField(akEvent, new UnityEngine.GUIContent("Event: "));
        }

        if (m_AkEventPlayable != null && m_AkEventPlayable.OwningClip != null)
        {
            var componentName = GetEventName(new System.Guid(m_AkEventPlayable.akEvent.valueGuid));
            m_AkEventPlayable.OwningClip.displayName = componentName;
        }

        UnityEngine.GUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();

        var currentEvent = UnityEngine.Event.current;

        if (currentEvent.type == UnityEngine.EventType.Repaint)
        {
            m_pickerPos = AkUtilities.GetLastRectAbsolute(false);
        }
    }
Example #5
0
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            UnityEditor.EditorGUI.BeginProperty(position, label, property);

            var wwiseObjectReference = property.FindPropertyRelative("WwiseObjectReference");

            HandleDragAndDrop(wwiseObjectReference, position);

            position = UnityEditor.EditorGUI.PrefixLabel(position,
                                                         UnityEngine.GUIUtility.GetControlID(UnityEngine.FocusType.Passive), label);

            var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.button);

            style.alignment = UnityEngine.TextAnchor.MiddleLeft;
            style.fontStyle = UnityEngine.FontStyle.Normal;

            var componentName = GetComponentName(wwiseObjectReference);

            if (string.IsNullOrEmpty(componentName))
            {
                componentName          = "No " + WwiseObjectType + " is currently selected";
                style.normal.textColor = UnityEngine.Color.red;
            }

            if (UnityEngine.GUI.Button(position, componentName, style))
            {
                new AkWwiseComponentPicker.PickerCreator
                {
                    objectType           = WwiseObjectType,
                    wwiseObjectReference = wwiseObjectReference,
                    pickerPosition       = AkUtilities.GetLastRectAbsolute(position),
                    serializedObject     = property.serializedObject
                };
            }

            UnityEditor.EditorGUI.EndProperty();
        }
Example #6
0
    public abstract string  UpdateIds(Guid[] in_guid);          //set object properties and return its name

    public override void OnInspectorGUI()
    {
        serializedObject.ApplyModifiedProperties();

        /***************************************Handle Drag and Drop********************************************************/
        object[] DDInfo = (object[])DragAndDrop.GetGenericData("AKWwiseDDInfo");
        if (DDInfo != null && DDInfo.Length >= 4)
        {
            string DDTypeName = (string)DDInfo[3];
            if (DDTypeName.Equals(m_typeName))
            {
                if (Event.current.type == EventType.DragUpdated)
                {
                    //mousePosition is not available during DragExited event but is available during the DragUpdated event.
                    m_isInDropArea = m_dropAreaRelativePos.Contains(Event.current.mousePosition);

                    if (m_isInDropArea)
                    {
                        DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                        DragAndDrop.AcceptDrag();
                    }
                    return;
                }
                if (Event.current.type == EventType.DragExited && m_isInDropArea)
                {
                    Guid DDGuid = (Guid)DDInfo[1];
                    AkUtilities.SetByteArrayProperty(m_guidProperty[0], DDGuid.ToByteArray());

                    //needed for the undo operation to work
                    GUIUtility.hotControl = 0;

                    m_isInDropArea = false;
                    return;
                }
            }
        }
        /*******************************************************************************************************************/


        /************************************************Update Properties**************************************************/
        Guid[] componentGuid = new Guid[m_guidProperty.Length];
        for (int i = 0; i < componentGuid.Length; i++)
        {
            byte[] guidBytes = AkUtilities.GetByteArrayProperty(m_guidProperty[i]);
            componentGuid[i] = guidBytes == null ? Guid.Empty : new Guid(guidBytes);
        }

        string componentName = UpdateIds(componentGuid);

        /*******************************************************************************************************************/


        /********************************************Draw GUI***************************************************************/
        OnChildInspectorGUI();

        GUILayout.Space(3);

        GUILayout.BeginHorizontal("box");
        {
            float inspectorWidth = Screen.width - GUI.skin.box.margin.left - GUI.skin.box.margin.right - 19;
            GUILayout.Label(m_typeName + " Name: ", GUILayout.Width(inspectorWidth * 0.4f));

            GUIStyle style = new GUIStyle(GUI.skin.button);
            style.alignment = TextAnchor.MiddleLeft;
            if (componentName.Equals(String.Empty))
            {
                componentName          = "No " + m_typeName + " is currently selected";
                style.normal.textColor = Color.red;
            }

            if (GUILayout.Button(componentName, style, GUILayout.MaxWidth(inspectorWidth * 0.6f - GUI.skin.box.margin.right)))
            {
                m_buttonWasPressed = true;

                // We don't want to set object as dirty only because we clicked the button.
                // It will be set as dirty if the wwise object has been changed by the tree view.
                GUI.changed = false;
            }

            //GUILayoutUtility.GetLastRect and AkUtilities.GetLastRectAbsolute must be called in repaint mode
            if (Event.current.type == EventType.Repaint)
            {
                m_dropAreaRelativePos = GUILayoutUtility.GetLastRect();

                if (m_buttonWasPressed)
                {
                    m_pickerPos = AkUtilities.GetLastRectAbsolute();
                    EditorApplication.delayCall += DelayCreateCall;
                    m_buttonWasPressed           = false;
                }
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(5);
        /***********************************************************************************************************************/

        if (GUI.changed)
        {
            EditorUtility.SetDirty(serializedObject.targetObject);
        }
    }
Example #7
0
    public override void OnInspectorGUI()
    {
        UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);

        OnChildInspectorGUI();

        serializedObject.ApplyModifiedProperties();

        var currentEvent = UnityEngine.Event.current;

        HandleDragAndDrop(currentEvent, m_dropAreaRelativePos);

        /************************************************Update Properties**************************************************/
        string componentName = "---";

        var hasMultipleDifferentValues = false;

        for (var i = 0; i < m_guidProperty.Length; i++)
        {
            hasMultipleDifferentValues = hasMultipleDifferentValues || m_guidProperty[i].hasMultipleDifferentValues;
        }

        if (!hasMultipleDifferentValues)
        {
            var componentGuid = new System.Guid[m_guidProperty.Length];
            for (var i = 0; i < componentGuid.Length; i++)
            {
                var guidBytes = AkUtilities.GetByteArrayProperty(m_guidProperty[i]);
                componentGuid[i] = guidBytes == null ? System.Guid.Empty : new System.Guid(guidBytes);
            }
            componentName = UpdateIds(componentGuid);
        }

        /*******************************************************************************************************************/

        /********************************************Draw GUI***************************************************************/

        UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);

        UnityEngine.GUILayout.BeginHorizontal("box");
        {
            float inspectorWidth = UnityEngine.Screen.width - UnityEngine.GUI.skin.box.margin.left -
                                   UnityEngine.GUI.skin.box.margin.right - 19;
            UnityEngine.GUILayout.Label(m_typeName + " Name: ", UnityEngine.GUILayout.Width(inspectorWidth * 0.4f));

            var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.button);
            style.alignment = UnityEngine.TextAnchor.MiddleLeft;
            if (componentName.Equals(string.Empty))
            {
                componentName          = "No " + m_typeName + " is currently selected";
                style.normal.textColor = UnityEngine.Color.red;
            }

            if (UnityEngine.GUILayout.Button(new UnityEngine.GUIContent(componentName, hasMultipleDifferentValues ? "Mixed Values" : ""), style,
                                             UnityEngine.GUILayout.MaxWidth(inspectorWidth * 0.6f - UnityEngine.GUI.skin.box.margin.right)))
            {
                m_buttonWasPressed = true;

                // We don't want to set object as dirty only because we clicked the button.
                // It will be set as dirty if the wwise object has been changed by the tree view.
                UnityEngine.GUI.changed = false;
            }

            //GUILayoutUtility.GetLastRect and AkUtilities.GetLastRectAbsolute must be called in repaint mode
            if (currentEvent.type == UnityEngine.EventType.Repaint)
            {
                m_dropAreaRelativePos = UnityEngine.GUILayoutUtility.GetLastRect();

                if (m_buttonWasPressed)
                {
                    m_pickerPos = AkUtilities.GetLastRectAbsolute(UnityEngine.GUILayoutUtility.GetLastRect());
                    UnityEditor.EditorApplication.delayCall += DelayCreateCall;
                    m_buttonWasPressed = false;
                }
            }
        }
        UnityEngine.GUILayout.EndHorizontal();

        /***********************************************************************************************************************/

        if (UnityEngine.GUI.changed)
        {
            UnityEditor.EditorUtility.SetDirty(serializedObject.targetObject);
        }
    }
Example #8
0
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            // Get unique control Id
            int controlId = UnityEngine.GUIUtility.GetControlID(label, UnityEngine.FocusType.Passive);

            UnityEditor.EditorGUI.BeginProperty(position, label, property);

            var wwiseObjectReference = property.FindPropertyRelative("WwiseObjectReference");

            HandleDragAndDrop(wwiseObjectReference, position);

            position = UnityEditor.EditorGUI.PrefixLabel(position, controlId, label);

            var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.button);

            style.alignment = UnityEngine.TextAnchor.MiddleLeft;
            style.fontStyle = UnityEngine.FontStyle.Normal;

            var componentName = GetComponentName(wwiseObjectReference);

            if (string.IsNullOrEmpty(componentName))
            {
                componentName          = "No " + WwiseObjectType + " is currently selected";
                style.normal.textColor = UnityEngine.Color.red;
            }

            if (UnityEngine.GUI.Button(position, componentName, style))
            {
                new AkWwiseComponentPicker.PickerCreator
                {
                    objectType           = WwiseObjectType,
                    wwiseObjectReference = wwiseObjectReference,
                    serializedObject     = property.serializedObject,
                    //Current selected object
                    currentWwiseObjectReference = GetWwiseObjectReference(wwiseObjectReference),
                    //We're currently clicking focus windows must be the right
                    pickedSourceEditorWindow = UnityEditor.EditorWindow.focusedWindow,
                    //Useful to control event source
                    pickedSourceControlId = controlId,
                    pickerPosition        = AkUtilities.GetLastRectAbsolute(position),
                };
            }

            // Check picker window close event and we're in the right drawer instance using control ID
            if (UnityEngine.Event.current.commandName == AkWwiseComponentPicker.PickerClosedEventName &&
                controlId == AkWwiseComponentPicker.GetObjectPickerControlID())
            {
                var oldValue = GetWwiseObjectReference(wwiseObjectReference);
                var newValue = AkWwiseComponentPicker.GetObjectPickerObjectReference();

                if (oldValue != newValue)
                {
                    // Serialized object updating
                    wwiseObjectReference.serializedObject.Update();
                    SetSerializedObject(wwiseObjectReference, newValue);
                    wwiseObjectReference.serializedObject.ApplyModifiedProperties();

                    // Force GUI modification, to send back to the base component drawer
                    UnityEngine.GUI.changed = true;
                }
            }

            UnityEditor.EditorGUI.EndProperty();
        }
Example #9
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);

        OnChildInspectorGUI();

        serializedObject.ApplyModifiedProperties();

        var currentEvent = Event.current;

        HandleDragAndDrop(currentEvent, m_dropAreaRelativePos);

        /************************************************Update Properties**************************************************/
        Guid[] componentGuid = new Guid[m_guidProperty.Length];
        for (int i = 0; i < componentGuid.Length; i++)
        {
            byte[] guidBytes = AkUtilities.GetByteArrayProperty(m_guidProperty[i]);
            componentGuid[i] = guidBytes == null ? Guid.Empty : new Guid(guidBytes);
        }

        string componentName = UpdateIds(componentGuid);

        /*******************************************************************************************************************/


        /********************************************Draw GUI***************************************************************/

        GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);

        GUILayout.BeginHorizontal("box");
        {
            float inspectorWidth = Screen.width - GUI.skin.box.margin.left - GUI.skin.box.margin.right - 19;
            GUILayout.Label(m_typeName + " Name: ", GUILayout.Width(inspectorWidth * 0.4f));

            GUIStyle style = new GUIStyle(GUI.skin.button);
            style.alignment = TextAnchor.MiddleLeft;
            if (componentName.Equals(String.Empty))
            {
                componentName          = "No " + m_typeName + " is currently selected";
                style.normal.textColor = Color.red;
            }

            if (GUILayout.Button(componentName, style, GUILayout.MaxWidth(inspectorWidth * 0.6f - GUI.skin.box.margin.right)))
            {
                m_buttonWasPressed = true;

                // We don't want to set object as dirty only because we clicked the button.
                // It will be set as dirty if the wwise object has been changed by the tree view.
                GUI.changed = false;
            }

            //GUILayoutUtility.GetLastRect and AkUtilities.GetLastRectAbsolute must be called in repaint mode
            if (currentEvent.type == EventType.Repaint)
            {
                m_dropAreaRelativePos = GUILayoutUtility.GetLastRect();

                if (m_buttonWasPressed)
                {
                    m_pickerPos = AkUtilities.GetLastRectAbsolute();
                    EditorApplication.delayCall += DelayCreateCall;
                    m_buttonWasPressed           = false;
                }
            }
        }
        GUILayout.EndHorizontal();

        /***********************************************************************************************************************/

        if (GUI.changed)
        {
            EditorUtility.SetDirty(serializedObject.targetObject);
        }
    }