// Moves the selected block down private void MoveBlockDown() { int movedInt = 0; int tempVar = selectedVar; CustomInspectorWindowBlock temp = new CustomInspectorWindowBlock(); CustomInspectorWindowBlock thisBlock = varList[selectedVar]; // Moves the object down so it passes any childed objects for (int i = selectedVar; i < varList.Count - 1; ++i) { bool end = true; movedInt++; temp = varList[i + 1]; varList[i + 1] = varList[i]; varList[i] = temp; if (i < varList.Count - 2 && varList[i + 2].parent != null && varList[i + 2].parent != varList[i + 1]) { end = false; } if (i < varList.Count - 1 && varList[selectedVar].parent != null && varList[i + 1].parent == varList[selectedVar].parent) { end = true; } if (varList[i].childIncrements <= varList[i + 1].childIncrements && end) { break; } } // Adjusts the moved amount to account for the number of childed objects if (thisBlock.children.Count > 1) { movedInt -= (thisBlock.children.Count - 1); } // Moves any of the object's children down with it for (int i = 0; i < movedInt; ++i) { int val = tempVar + i; for (int j = (thisBlock.children.Count + val - 1); j >= val; --j) { if (j + 1 < varList.Count) { temp = varList[j + 1]; varList[j + 1] = varList[j]; varList[j] = temp; } } } }
private void DrawEnd() { GUILayout.FlexibleSpace(); EditorGUI.DrawRect(new Rect(0, 657.5f, 360, 50f), new Color(0.65f, 0.65f, 0.65f)); EditorGUI.DrawRect(new Rect(0, 657.5f, 360, 1), Color.black); if (GUILayout.Button("Create Variable")) { CustomInspectorWindowBlock block = new CustomInspectorWindowBlock(); varList.Add(block); } if (GUILayout.Button("Export Data")) { if (CheckCanExportData()) { ExportEditorData(); ExportNormalData(); } } }
// Moves the selected block up private void MoveBlockUp() { int movedInt = 0; int tempVar = selectedVar; CustomInspectorWindowBlock temp = new CustomInspectorWindowBlock(); CustomInspectorWindowBlock thisBlock = varList[selectedVar]; // Moves the object up so it passes any childed objects for (int i = selectedVar; i > 0; --i) { movedInt++; temp = varList[i - 1]; varList[i - 1] = varList[i]; varList[i] = temp; if (varList[i].childIncrements <= varList[i - 1].childIncrements) { break; } } // Moves any of the object's children up with it for (int i = 0; i < movedInt; ++i) { int val = tempVar - i; for (int j = val; j < thisBlock.children.Count + val; ++j) { if (j - 1 >= 0) { temp = varList[j + 1]; varList[j + 1] = varList[j]; varList[j] = temp; } } } }
private void UnchildBlock(CustomInspectorWindowBlock block) { block.parent.children.Remove(block); block.childIncrements = 0; block.parent = null; }