/// <summary> /// LineFunctionIndexを変更したときに呼ぶ /// </summary> void ChangedLineFunctionsIndex() { int funcsIndex = reorderableFunctionsList.index; if (funcsIndex < 0 || funcsIndex >= propLineFunctionsList.arraySize) { return; } SerializedProperty propFuncs = propLineFunctionsList.GetArrayElementAtIndex(funcsIndex); GameObject currentLineFuncs = propFuncs.objectReferenceValue as GameObject; serializedLineFunctionsObject = currentLineFuncs != null ? new SerializedObject(currentLineFuncs.GetComponent <MaterialLineFunctionsNode>()) : null; if (serializedLineFunctionsObject == null || serializedLineFunctionsObject.targetObject == null) { return; } propTargetMaterials = serializedLineFunctionsObject.FindProperty("TargetMaterials"); reorderableTargetMaterialList = Common.CreateMaterialList( serializedLineFunctionsObject, propTargetMaterials, new List <Material>(), selectedMaterials => { serializedLineFunctionsObject.Update(); propTargetMaterials.AppendObjects(selectedMaterials); serializedLineFunctionsObject.ApplyModifiedProperties(); reorderableTargetMaterialList.index = reorderableTargetMaterialList.count - 1; }); }
void OnEnable() { var currentNode = target as LineListNode; // ---------- Line List ---------- propLineList = serializedObject.FindProperty("LineList"); reorderableLineList = Common.CreateReorderableNodeList(serializedObject, propLineList, currentNode, Prefabs.Line); // ---------- Material Line Functions List ---------- propLineFunctionsList = serializedObject.FindProperty("LineFunctionsList"); reorderableFunctionsList = Common.CreateReorderableNodeList(serializedObject, propLineFunctionsList, currentNode, Prefabs.LineFunctions); // Elementを追加するコールバック reorderableFunctionsList.onAddCallback += (list) => { ChangedLineFunctionsIndex(); }; // Elementを削除するコールバック reorderableFunctionsList.onRemoveCallback += (list) => { ChangedLineFunctionsIndex(); }; // Elementの入れ替えを行った際に呼ばれるコールバック reorderableFunctionsList.onReorderCallback += (list) => { ChangedLineFunctionsIndex(); }; // 選択状態変更 reorderableFunctionsList.onSelectCallback += (list) => { ChangedLineFunctionsIndex(); }; // ---------- Double Sided Materials ---------- propDoubleSidedMaterials = serializedObject.FindProperty("DoubleSidedMaterials"); reorderableDoubleSidedMaterials = Common.CreateMaterialList( serializedObject, propDoubleSidedMaterials, (target as LineListNode).DoubleSidedMaterials, selectedMaterials => { serializedObject.Update(); propDoubleSidedMaterials.AppendObjects(selectedMaterials); serializedObject.ApplyModifiedProperties(); reorderableDoubleSidedMaterials.index = reorderableDoubleSidedMaterials.count - 1; }); // ---------- Ignore Object List ---------- propIgnoreObjectList = serializedObject.FindProperty("IgnoreObjectList"); reorderableIgnoreObjectList = Common.CreateObjectList( serializedObject, propIgnoreObjectList, (target as LineListNode).IgnoreObjectList, selectedObjects => { serializedObject.Update(); propIgnoreObjectList.AppendObjects(selectedObjects); serializedObject.ApplyModifiedProperties(); reorderableIgnoreObjectList.index = reorderableIgnoreObjectList.count - 1; }); #if SORT_LIST // Sortコールバックが登録されていない場合は登録 if (EditorApplication.hierarchyWindowChanged == null) { EditorApplication.hierarchyWindowChanged += SortLineListNodeCallback; return; } Delegate[] del = EditorApplication.hierarchyWindowChanged.GetInvocationList(); if (!del.Any(x => x.Method.Name == "SortLineListNodeCallback")) { EditorApplication.hierarchyWindowChanged += SortLineListNodeCallback; } #endif }
void OnEnable() { if (indentStyle == null) { indentStyle = new GUIStyle(); indentStyle.border = new RectOffset(1, 1, 1, 1); indentStyle.padding = new RectOffset(0, 0, 0, 0); indentStyle.margin = new RectOffset(60, 0, 0, 0); } propTargetMaterials = serializedObject.FindProperty("TargetMaterials"); propOutlineOn = serializedObject.FindProperty("OutlineOn"); propOutlineColor = serializedObject.FindProperty("OutlineColor"); propOutlineAmount = serializedObject.FindProperty("OutlineAmount"); propObjectOn = serializedObject.FindProperty("ObjectOn"); propObjectColor = serializedObject.FindProperty("ObjectColor"); propObjectAmount = serializedObject.FindProperty("ObjectAmount"); propIntersectionOn = serializedObject.FindProperty("IntersectionOn"); propIntersectionColor = serializedObject.FindProperty("IntersectionColor"); propIntersectionAmount = serializedObject.FindProperty("IntersectionAmount"); propSmoothOn = serializedObject.FindProperty("SmoothOn"); propSmoothColor = serializedObject.FindProperty("SmoothColor"); propSmoothAmount = serializedObject.FindProperty("SmoothAmount"); propMaterialOn = serializedObject.FindProperty("MaterialOn"); propMaterialColor = serializedObject.FindProperty("MaterialColor"); propMaterialAmount = serializedObject.FindProperty("MaterialAmount"); propNormalAngleOn = serializedObject.FindProperty("NormalAngleOn"); propNormalAngleColor = serializedObject.FindProperty("NormalAngleColor"); propNormalAngleAmount = serializedObject.FindProperty("NormalAngleAmount"); propWireframeOn = serializedObject.FindProperty("WireframeOn"); propWireframeColor = serializedObject.FindProperty("WireframeColor"); propWireframeAmount = serializedObject.FindProperty("WireframeAmount"); propDisableIntersection = serializedObject.FindProperty("DisableIntersection"); propDrawHiddenLines = serializedObject.FindProperty("DrawHiddenLines"); propDrawHiddenLinesOfTarget = serializedObject.FindProperty("DrawHiddenLinesOfTarget"); propDrawObjects = serializedObject.FindProperty("DrawObjects"); propDrawMaterials = serializedObject.FindProperty("DrawMaterials"); propMaskHiddenLinesOfTarget = serializedObject.FindProperty("MaskHiddenLinesOfTarget"); propMaskObjects = serializedObject.FindProperty("MaskObjects"); propMaskMaterials = serializedObject.FindProperty("MaskMaterials"); reorderableTargetMaterialList = Common.CreateMaterialList( serializedObject, propTargetMaterials, Resources.FindObjectsOfTypeAll <MaterialLineFunctionsNode>().SelectMany(x => x.TargetMaterials), selectedMaterials => { serializedObject.Update(); propTargetMaterials.AppendObjects(selectedMaterials); serializedObject.ApplyModifiedProperties(); reorderableTargetMaterialList.index = reorderableTargetMaterialList.count - 1; }); reorderableDrawObjectList = Common.CreateObjectList( serializedObject, propDrawObjects, (target as MaterialLineFunctionsNode).DrawObjects, selectedObjects => { serializedObject.Update(); propDrawObjects.AppendObjects(selectedObjects); serializedObject.ApplyModifiedProperties(); reorderableDrawObjectList.index = reorderableDrawObjectList.count - 1; }); reorderableDrawMaterialList = Common.CreateMaterialList( serializedObject, propDrawMaterials, (target as MaterialLineFunctionsNode).DrawMaterials, selectedMaterials => { serializedObject.Update(); propDrawMaterials.AppendObjects(selectedMaterials); serializedObject.ApplyModifiedProperties(); reorderableDrawMaterialList.index = reorderableDrawMaterialList.count - 1; }); reorderableMaskObjectList = Common.CreateObjectList( serializedObject, propMaskObjects, (target as MaterialLineFunctionsNode).MaskObjects, selectedObjects => { serializedObject.Update(); propMaskObjects.AppendObjects(selectedObjects); serializedObject.ApplyModifiedProperties(); reorderableMaskObjectList.index = reorderableMaskObjectList.count - 1; }); reorderableMaskMaterialList = Common.CreateMaterialList( serializedObject, propMaskMaterials, (target as MaterialLineFunctionsNode).MaskMaterials, selectedMaterials => { serializedObject.Update(); propMaskMaterials.AppendObjects(selectedMaterials); serializedObject.ApplyModifiedProperties(); reorderableMaskMaterialList.index = reorderableMaskMaterialList.count - 1; }); }