void OnEnable() { if (textureBaker != null) { serializedObject = new SerializedObject(textureBaker); tbe.OnEnable(serializedObject); } else if (meshBaker != null) { serializedObject = new SerializedObject(meshBaker); mbe.OnEnable(serializedObject); } }
void drawTabAddObjectsToBakers() { if (helpBoxString == null) { helpBoxString = ""; } EditorGUILayout.HelpBox("To add, select one or more objects in the hierarchy view. Child Game Objects with MeshRender or SkinnedMeshRenderer will be added. Use the fields below to filter what is added." + "To remove, use the fields below to filter what is removed.\n" + helpBoxString, UnityEditor.MessageType.None); target = (MB3_MeshBakerRoot)EditorGUILayout.ObjectField("Target to add objects to", target, typeof(MB3_MeshBakerRoot), true); if (target != null) { targetGO = target.gameObject; } else { targetGO = null; } if (targetGO != oldTargetGO && targetGO != null) { textureBaker = targetGO.GetComponent <MB3_TextureBaker>(); meshBaker = targetGO.GetComponent <MB3_MeshBaker>(); tbe = new MB3_TextureBakerEditorInternal(); mbe = new MB3_MeshBakerEditorInternal(); oldTargetGO = targetGO; if (textureBaker != null) { serializedObject = new SerializedObject(textureBaker); tbe.OnEnable(serializedObject); } else if (meshBaker != null) { serializedObject = new SerializedObject(meshBaker); mbe.OnEnable(serializedObject); } } EditorGUIUtility.labelWidth = 300; onlyStaticObjects = EditorGUILayout.Toggle("Only Static Objects", onlyStaticObjects); onlyEnabledObjects = EditorGUILayout.Toggle("Only Enabled Objects", onlyEnabledObjects); excludeMeshesWithOBuvs = EditorGUILayout.Toggle("Exclude meshes with out-of-bounds UVs", excludeMeshesWithOBuvs); excludeMeshesAlreadyAddedToBakers = EditorGUILayout.Toggle("Exclude GameObjects already added to bakers", excludeMeshesAlreadyAddedToBakers); mat = (Material)EditorGUILayout.ObjectField("Using Material", mat, typeof(Material), true); shaderMat = (Material)EditorGUILayout.ObjectField("Using Shader", shaderMat, typeof(Material), true); string[] lightmapDisplayValues = new string[257]; int[] lightmapValues = new int[257]; lightmapValues[0] = -2; lightmapValues[1] = -1; lightmapDisplayValues[0] = "don't filter on lightmapping"; lightmapDisplayValues[1] = "not lightmapped"; for (int i = 2; i < lightmapDisplayValues.Length; i++) { lightmapDisplayValues[i] = "" + i; lightmapValues[i] = i; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Using Lightmap Index "); lightmapIndex = EditorGUILayout.IntPopup(lightmapIndex, lightmapDisplayValues, lightmapValues); EditorGUILayout.EndHorizontal(); if (regExParseError != null && regExParseError.Length > 0) { EditorGUILayout.HelpBox("Error In Regular Expression:\n" + regExParseError, MessageType.Error); } searchRegEx = EditorGUILayout.TextField(GUIContentRegExpression, searchRegEx); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add Selected Meshes To Target")) { addSelectedObjects(); } if (GUILayout.Button("Remove Matching Meshes From Target")) { removeSelectedObjects(); } EditorGUILayout.EndHorizontal(); if (textureBaker != null) { MB_EditorUtil.DrawSeparator(); tbFoldout = EditorGUILayout.Foldout(tbFoldout, "Texture Baker"); if (tbFoldout) { tbe.DrawGUI(serializedObject, (MB3_TextureBaker)textureBaker, typeof(MB3_MeshBakerEditorWindow)); } } if (meshBaker != null) { MB_EditorUtil.DrawSeparator(); mbFoldout = EditorGUILayout.Foldout(mbFoldout, "Mesh Baker"); if (mbFoldout) { mbe.DrawGUI(serializedObject, (MB3_MeshBaker)meshBaker, typeof(MB3_MeshBakerEditorWindow)); } } }
void OnEnable() { mbe.OnEnable(serializedObject); }