public static SetByteArrayProperty ( UnityEditor.SerializedProperty property, byte byteArray ) : void | ||
property | UnityEditor.SerializedProperty | |
byteArray | byte | |
Résultat | void |
private void SetGuid(AK.Wwise.TreeView.TreeViewItem in_item) { m_serializedObject.Update(); var obj = in_item.DataContext as AkWwiseTreeView.AkTreeInfo; //we set the items guid AkUtilities.SetByteArrayProperty(m_selectedItemGuid[0], obj.Guid); if (m_selectedItemID != null) { m_selectedItemID[0].intValue = obj.ID; } //When its a State or a Switch, we set the group's guid if (m_selectedItemGuid.Length == 2) { obj = in_item.Parent.DataContext as AkWwiseTreeView.AkTreeInfo; AkUtilities.SetByteArrayProperty(m_selectedItemGuid[1], obj.Guid); if (m_selectedItemID != null) { m_selectedItemID[1].intValue = obj.ID; } } m_serializedObject.ApplyModifiedProperties(); }
private void ResetGuid() { m_serializedObject.Update(); var emptyArray = new byte[16]; //we set the items guid AkUtilities.SetByteArrayProperty(m_selectedItemGuid[0], emptyArray); if (m_selectedItemID != null) { m_selectedItemID[0].intValue = 0; } //When its a State or a Switch, we set the group's guid if (m_selectedItemGuid.Length == 2) { AkUtilities.SetByteArrayProperty(m_selectedItemGuid[1], emptyArray); if (m_selectedItemID != null) { m_selectedItemID[1].intValue = 0; } } m_serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (Event.current.type == EventType.DragExited && m_isInDropArea && DragAndDrop.paths.Length >= 4 && DragAndDrop.paths[3].Equals(m_typeName)) { AkUtilities.SetByteArrayProperty(m_guidProperty[1], new System.Guid(DragAndDrop.paths[4]).ToByteArray()); } base.OnInspectorGUI(); }
private void HandleDragAndDrop(UnityEngine.Rect dropArea) { var currentEvent = UnityEngine.Event.current; if (currentEvent.type == UnityEngine.EventType.DragExited) { UnityEditor.DragAndDrop.PrepareStartDrag(); } else if (currentEvent.type == UnityEngine.EventType.DragUpdated || currentEvent.type == UnityEngine.EventType.DragPerform) { if (dropArea.Contains(currentEvent.mousePosition)) { var DDData = GetAkDragDropData(); if (currentEvent.type == UnityEngine.EventType.DragUpdated) { UnityEditor.DragAndDrop.visualMode = DDData != null ? UnityEditor.DragAndDropVisualMode.Link : UnityEditor.DragAndDropVisualMode.Rejected; } else { UnityEditor.DragAndDrop.AcceptDrag(); if (DDData != null) { AkUtilities.SetByteArrayProperty(m_guidProperty[0], DDData.guid.ToByteArray()); m_IDProperty[0].intValue = DDData.ID; var DDGroupData = DDData as AkDragDropGroupData; if (DDGroupData != null) { if (m_guidProperty.Length > 1) { AkUtilities.SetByteArrayProperty(m_guidProperty[1], DDGroupData.groupGuid.ToByteArray()); } if (m_IDProperty.Length > 1) { m_IDProperty[1].intValue = DDGroupData.groupID; } } // needed for the undo operation to work UnityEngine.GUIUtility.hotControl = 0; } } currentEvent.Use(); } } }
public override void OnInspectorGUI() { object[] DDInfo = (object[])DragAndDrop.GetGenericData("AKWwiseDDInfo"); if (DDInfo != null && DDInfo.Length >= 4) { string DDTypeName = (string)DDInfo[3]; if (Event.current.type == EventType.DragExited && m_isInDropArea && DDTypeName.Equals(m_typeName)) { Guid DDGuid = (Guid)DDInfo[4]; AkUtilities.SetByteArrayProperty(m_guidProperty[1], DDGuid.ToByteArray()); } } base.OnInspectorGUI(); }
void SetGuid(TreeViewItem in_item) { m_serializedObject.Update(); //we set the items guid AkUtilities.SetByteArrayProperty(m_selectedItemGuid[0], (in_item.DataContext as AkWwiseTreeView.AkTreeInfo).Guid); //When its a State or a Switch, we set the group's guid if (m_selectedItemGuid.Length == 2) { AkUtilities.SetByteArrayProperty(m_selectedItemGuid[1], (in_item.Parent.DataContext as AkWwiseTreeView.AkTreeInfo).Guid); } m_serializedObject.ApplyModifiedProperties(); }
private void HandleDragAndDrop(UnityEngine.Event currentEvent, UnityEngine.Rect dropArea) { switch (currentEvent.type) { case UnityEngine.EventType.DragUpdated: if (dropArea.Contains(currentEvent.mousePosition)) { var DDData = GetAkDragDropData(); UnityEditor.DragAndDrop.visualMode = DDData != null ? UnityEditor.DragAndDropVisualMode.Link : UnityEditor.DragAndDropVisualMode.Rejected; currentEvent.Use(); } break; case UnityEngine.EventType.DragPerform: if (dropArea.Contains(currentEvent.mousePosition)) { var DDData = GetAkDragDropData(); UnityEditor.DragAndDrop.AcceptDrag(); if (DDData != null) { AkUtilities.SetByteArrayProperty(m_guidProperty[0], DDData.guid.ToByteArray()); var DDGroupData = DDData as AkDragDropGroupData; if (DDGroupData != null && m_guidProperty.Length > 1) { AkUtilities.SetByteArrayProperty(m_guidProperty[1], DDGroupData.groupGuid.ToByteArray()); } //needed for the undo operation to work UnityEngine.GUIUtility.hotControl = 0; } currentEvent.Use(); } break; case UnityEngine.EventType.DragExited: // clear dragged data UnityEditor.DragAndDrop.PrepareStartDrag(); break; } }
void ResetGuid() { m_serializedObject.Update(); byte[] emptyArray = new byte[16]; //we set the items guid AkUtilities.SetByteArrayProperty(m_selectedItemGuid[0], emptyArray); //When its a State or a Switch, we set the group's guid if (m_selectedItemGuid.Length == 2) { AkUtilities.SetByteArrayProperty(m_selectedItemGuid[1], emptyArray); } m_serializedObject.ApplyModifiedProperties(); }
private void HandleDragAndDrop(UnityEngine.Event currentEvent, Rect dropArea) { if (currentEvent.type == EventType.DragExited) { // clear dragged data DragAndDrop.PrepareStartDrag(); } else if (currentEvent.type == EventType.DragUpdated || currentEvent.type == EventType.DragPerform) { if (dropArea.Contains(currentEvent.mousePosition)) { var DDData = GetAkDragDropData(); if (currentEvent.type == EventType.DragUpdated) { DragAndDrop.visualMode = DDData != null ? DragAndDropVisualMode.Link : DragAndDropVisualMode.Rejected; } else { DragAndDrop.AcceptDrag(); if (DDData != null) { AkUtilities.SetByteArrayProperty(m_guidProperty[0], DDData.guid.ToByteArray()); AkDragDropGroupData DDGroupData = DDData as AkDragDropGroupData; if (DDGroupData != null && m_guidProperty.Length > 1) { AkUtilities.SetByteArrayProperty(m_guidProperty[1], DDGroupData.groupGuid.ToByteArray()); } //needed for the undo operation to work GUIUtility.hotControl = 0; } } currentEvent.Use(); } } }
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); } }