private void CreateActionsListView() { ListView targetListView = ContainerElement.Query <ListView>("actions-list").First(); targetListView.Clear(); targetListView.makeItem = () => new Label(); targetListView.RegisterCallback <MouseDownEvent>(OnMouseDownEvent); targetListView.RegisterCallback <MouseMoveEvent>(OnMouseMoveEvent); targetListView.RegisterCallback <MouseUpEvent>(OnMouseUpEvent); targetListView.bindItem = (element, i) => (element as Label).text = m_viewData.AllActionsAvailable[i].name; targetListView.itemsSource = m_viewData.AllActionsAvailable; targetListView.itemHeight = 16; targetListView.selectionType = SelectionType.Single; targetListView.onSelectionChange += (enumerable) => { foreach (Object actionCandidate in enumerable) { if (Event.current.type == EventType.MouseDown) { m_selectedAction = actionCandidate as OTGCombatAction; m_actionsDragged[0] = m_selectedAction; } if (Event.current.type == EventType.MouseUp) { m_selectedAction = null; } } }; }
private static void FindAllActions(EditorConfig _editorConfig) { string[] actionGuids = AssetDatabase.FindAssets("t:OTGCombatAction"); ActionsInstantiated.Clear(); for (int i = 0; i < actionGuids.Length; i++) { string assetPath = AssetDatabase.GUIDToAssetPath(actionGuids[i]); ActionsInstantiated.Add(AssetDatabase.LoadAssetAtPath <OTGCombatAction>(assetPath)); } for (int i = 0; i < ActionsInstantiated.Count; i++) { for (int j = 0; j < ActionsAvailable.Count; j++) { OTGCombatAction actionInstance = ActionsInstantiated[i]; OTGCombatAction spawnAction = ActionsAvailable[j]; if (actionInstance.GetType() == spawnAction.GetType()) { ActionsAvailable.Remove(spawnAction); } } } for (int k = 0; k < ActionsAvailable.Count; k++) { OTGCombatAction act = ActionsAvailable[k]; string[] splitFileName = act.GetType().ToString().Split('.'); AssetDatabase.CreateAsset(act, _editorConfig.CombatActionsPath + "/" + splitFileName[splitFileName.Length - 1] + ".asset"); } }
private void GetPropertyValues(ref OTGCombatAction[] _target, SerializedObject _source, string _propName) { var props = _source.FindProperty(_propName); int size = props.arraySize; _target = new OTGCombatAction[size]; for (int i = 0; i < size; i++) { _target[i] = props.GetArrayElementAtIndex(i).objectReferenceValue as OTGCombatAction; } }
private void PopulateProprtyValuesDirectly(ref OTGCombatAction[] _target, List <OTGCombatAction> _source) { _target = new OTGCombatAction[_source.Count]; _target = _source.ToArray(); }