예제 #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(false);

                UnityEditor.EditorApplication.delayCall += DelayCreateCall;
                m_buttonWasPressed = false;
            }

            HandleDragAndDrop(currentEvent, position);

            UnityEditor.EditorGUI.EndProperty();
        }