public static GetByteArrayProperty ( UnityEditor.SerializedProperty property ) : byte[] | ||
property | UnityEditor.SerializedProperty | |
Результат | byte[] |
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(); }
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(); }
private void DelayCall() { if (s_componentPicker != null) { return; } s_componentPicker = CreateInstance <AkWwiseComponentPicker>(); //position the window below the button var pos = new UnityEngine.Rect(pickerPosition.x, pickerPosition.yMax, 0, 0); //If the window gets out of the screen, we place it on top of the button instead if (pickerPosition.yMax > UnityEngine.Screen.currentResolution.height / 2) { pos.y = pickerPosition.y - UnityEngine.Screen.currentResolution.height / 2; } //We show a drop down window which is automatically destroyed when focus is lost s_componentPicker.ShowAsDropDown(pos, new UnityEngine.Vector2(pickerPosition.width >= 250 ? pickerPosition.width : 250, UnityEngine.Screen.currentResolution.height / 2)); s_componentPicker.m_selectedItemGuid = guidProperty; s_componentPicker.m_selectedItemID = idProperty; s_componentPicker.m_serializedObject = serializedObject; s_componentPicker.m_type = objectType; //Make a backup of the tree's expansion status and replace it with an empty list to make sure nothing will get expanded //when we populate the tree var expandedItemsBackUp = AkWwiseProjectInfo.GetData().ExpandedItems; AkWwiseProjectInfo.GetData().ExpandedItems = new System.Collections.Generic.List <string>(); s_componentPicker.m_treeView.AssignDefaults(); s_componentPicker.m_treeView.SetRootItem( System.IO.Path.GetFileNameWithoutExtension(WwiseSetupWizard.Settings.WwiseProjectPath), AkWwiseProjectData.WwiseObjectType.PROJECT); //Populate the tree with the correct type if (objectType == AkWwiseProjectData.WwiseObjectType.EVENT) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Events", AkWwiseProjectInfo.GetData().EventWwu); } else if (objectType == AkWwiseProjectData.WwiseObjectType.SWITCH) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Switches", AkWwiseProjectInfo.GetData().SwitchWwu); } else if (objectType == AkWwiseProjectData.WwiseObjectType.STATE) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "States", AkWwiseProjectInfo.GetData().StateWwu); } else if (objectType == AkWwiseProjectData.WwiseObjectType.SOUNDBANK) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Banks", AkWwiseProjectInfo.GetData().BankWwu); } else if (objectType == AkWwiseProjectData.WwiseObjectType.AUXBUS) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Auxiliary Busses", AkWwiseProjectInfo.GetData().AuxBusWwu); } else if (objectType == AkWwiseProjectData.WwiseObjectType.GAMEPARAMETER) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Game Parameters", AkWwiseProjectInfo.GetData().RtpcWwu); } else if (objectType == AkWwiseProjectData.WwiseObjectType.TRIGGER) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Triggers", AkWwiseProjectInfo.GetData().TriggerWwu); } else if (objectType == AkWwiseProjectData.WwiseObjectType.ACOUSTICTEXTURE) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Virtual Acoustics", AkWwiseProjectInfo.GetData().AcousticTextureWwu); } AK.Wwise.TreeView.TreeViewItem item = null; var byteArray = AkUtilities.GetByteArrayProperty(guidProperty[0]); if (byteArray != null) { item = s_componentPicker.m_treeView.GetItemByGuid(new System.Guid(byteArray)); } if (item != null) { item.ParentControl.SelectedItem = item; var itemIndexFromRoot = 0; //Expand all the parents of the selected item. //Count the number of items that are displayed before the selected item while (true) { item.IsExpanded = true; if (item.Parent != null) { itemIndexFromRoot += item.Parent.Items.IndexOf(item) + 1; item = item.Parent; } else { break; } } //Scroll down the window to make sure that the selected item is always visible when the window opens //there seems to be 1 pixel between each item so we add 2 pixels(top and bottom) var itemHeight = item.ParentControl.m_skinSelected.button.CalcSize(new UnityEngine.GUIContent(item.Header)).y + 2.0f; s_componentPicker.m_treeView.SetScrollViewPosition(new UnityEngine.Vector2(0.0f, itemHeight * itemIndexFromRoot - UnityEngine.Screen.currentResolution.height / 4)); } //Restore the tree's expansion status AkWwiseProjectInfo.GetData().ExpandedItems = expandedItemsBackUp; }
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); } }
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); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { // Using BeginProperty / EndProperty on the parent property means that // prefab override logic works on the entire property. EditorGUI.BeginProperty(position, label, property); SetupSerializedProperties(property); ID = property.FindPropertyRelative("ID"); // Draw label position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); /************************************************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***************************************************************/ var style = new GUIStyle(GUI.skin.button); style.alignment = TextAnchor.MiddleLeft; style.fontStyle = FontStyle.Normal; if (componentName.Equals(String.Empty)) { componentName = "No " + m_typeName + " is currently selected"; style.normal.textColor = Color.red; } if (GUI.Button(position, componentName, style)) { s_pressedPosition = position; s_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; } var currentEvent = UnityEngine.Event.current; if (currentEvent.type == EventType.Repaint) { if (s_buttonWasPressed && s_pressedPosition.Equals(position)) { s_serializedObject = property.serializedObject; s_pickerPos = GetLastRectAbsolute(); s_guidProperty = m_guidProperty; s_objectType = m_objectType; EditorApplication.delayCall += DelayCreateCall; s_buttonWasPressed = false; } } HandleDragAndDrop(currentEvent, position); EditorGUI.EndProperty(); }
static public void Create(AkWwiseProjectData.WwiseObjectType in_type, SerializedProperty[] in_guid, SerializedObject in_serializedObject, Rect in_pos) { if (s_componentPicker == null) { s_componentPicker = ScriptableObject.CreateInstance <AkWwiseComponentPicker> (); //position the window below the button Rect pos = new Rect(in_pos.x, in_pos.yMax, 0, 0); //If the window gets out of the screen, we place it on top of the button instead if (in_pos.yMax > (Screen.currentResolution.height / 2)) { pos.y = in_pos.y - (Screen.currentResolution.height / 2); } //We show a drop down window which is automatically destoyed when focus is lost s_componentPicker.ShowAsDropDown(pos, new Vector2(in_pos.width >= 250 ? in_pos.width : 250, Screen.currentResolution.height / 2)); s_componentPicker.m_selectedItemGuid = in_guid; s_componentPicker.m_serializedObject = in_serializedObject; s_componentPicker.m_type = in_type; //Make a backup of the tree's expansion status and replace it with an empty list to make sure nothing will get expanded //when we populate the tree List <string> expandedItemsBackUp = AkWwiseProjectInfo.GetData().ExpandedItems; AkWwiseProjectInfo.GetData().ExpandedItems = new List <string> (); s_componentPicker.m_treeView.AssignDefaults(); s_componentPicker.m_treeView.SetRootItem(System.IO.Path.GetFileNameWithoutExtension(WwiseSetupWizard.Settings.WwiseProjectPath), AkWwiseProjectData.WwiseObjectType.PROJECT); //Populate the tree with the correct type if (in_type == AkWwiseProjectData.WwiseObjectType.EVENT) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Events", AkWwiseProjectInfo.GetData().EventWwu); } else if (in_type == AkWwiseProjectData.WwiseObjectType.SWITCH) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Switches", AkWwiseProjectInfo.GetData().SwitchWwu); } else if (in_type == AkWwiseProjectData.WwiseObjectType.STATE) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "States", AkWwiseProjectInfo.GetData().StateWwu); } else if (in_type == AkWwiseProjectData.WwiseObjectType.SOUNDBANK) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Banks", AkWwiseProjectInfo.GetData().BankWwu); } else if (in_type == AkWwiseProjectData.WwiseObjectType.AUXBUS) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Auxiliary Busses", AkWwiseProjectInfo.GetData().AuxBusWwu); } TreeViewItem item = s_componentPicker.m_treeView.GetItemByGuid(new Guid(AkUtilities.GetByteArrayProperty(in_guid[0]))); if (item != null) { item.ParentControl.SelectedItem = item; int itemIndexFromRoot = 0; //Expand all the parents of the selected item. //Count the number of items that are displayed before the selected item while (true) { item.IsExpanded = true; if (item.Parent != null) { itemIndexFromRoot += item.Parent.Items.IndexOf(item) + 1; item = item.Parent; } else { break; } } //Scroll down the window to make sure that the selected item is always visible when the window opens float itemHeight = item.ParentControl.m_skinSelected.button.CalcSize(new GUIContent(item.Header)).y + 2.0f; //there seems to be 1 pixel between each item so we add 2 pixels(top and bottom) s_componentPicker.m_treeView.SetScrollViewPosition(new Vector2(0.0f, (itemHeight * itemIndexFromRoot) - (Screen.currentResolution.height / 4))); } //Restore the tree's expansion status AkWwiseProjectInfo.GetData().ExpandedItems = expandedItemsBackUp; } }
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); } }