//---------------------------------------------------------------------------- private EShaderApiEditor ShaderApiToShaderApiEditor(PkFxCustomShader.EShaderApi api, bool isGL3) { EShaderApiEditor apiType = (EShaderApiEditor)api; if (apiType == EShaderApiEditor.GL2 && isGL3) { apiType = EShaderApiEditor.GL3; } else if (apiType == EShaderApiEditor.GL3) { apiType = EShaderApiEditor.GLES; } return(apiType); }
//---------------------------------------------------------------------------- private void SetShaderApiFromShaderApiEditor(EShaderApiEditor editorApi, SerializedProperty api, SerializedProperty isGL3) { api.intValue = (int)editorApi; isGL3.boolValue = false; if (editorApi == EShaderApiEditor.GL3) { api.intValue = (int)PkFxCustomShader.EShaderApi.GL; isGL3.boolValue = true; } else if (editorApi == EShaderApiEditor.GLES) { api.intValue = (int)PkFxCustomShader.EShaderApi.GLES; } }
//---------------------------------------------------------------------------- public override void OnInspectorGUI() { if (m_InShaderConstantsLoading) { ReloadConstants(false); } m_ShaderName.stringValue = EditorGUILayout.TextField(m_ShaderName.stringValue); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(m_ShaderGroup); EShaderApiEditor apiType = ShaderApiToShaderApiEditor((PkFxCustomShader.EShaderApi)m_Api.intValue, m_IsGL3.boolValue); apiType = (EShaderApiEditor)EditorGUILayout.EnumPopup("Api", apiType); SetShaderApiFromShaderApiEditor(apiType, m_Api, m_IsGL3); EditorGUILayout.PropertyField(m_IsMesh); if (m_IsMesh.boolValue == false) { if ((PkFxCustomShader.EShaderApi)m_Api.intValue != PkFxCustomShader.EShaderApi.GLES) { EditorGUILayout.PropertyField(m_HasSoftAnimBlend); EditorGUILayout.PropertyField(m_IsDistortion); } EditorGUILayout.PropertyField(m_IsSoft); } else { EditorGUILayout.PropertyField(m_HasMeshTexture); } if (m_IsDistortion.boolValue || m_IsMesh.boolValue) { m_IsSoft.boolValue = false; m_HasSoftAnimBlend.boolValue = false; } if ((PkFxCustomShader.EShaderApi)m_Api.intValue == PkFxCustomShader.EShaderApi.GLES) { m_HasSoftAnimBlend.boolValue = false; } SetVertexAndPixelType(); DrawVertexAndPixelType(); m_ShowShaderConstants = EditorGUILayout.ToggleLeft("Show Shader Constants", m_ShowShaderConstants); if (m_ShowShaderConstants) { EditorGUI.indentLevel++; if (GUILayout.Button("Reload")) { ReloadConstants(false); } for (int i = 0; i < this.m_ShaderConstantList.arraySize; i++) { SerializedProperty attr = this.m_ShaderConstantList.GetArrayElementAtIndex(i); attr = PKFxEditor.AttributeField(attr); } EditorGUI.indentLevel--; } EditorGUI.indentLevel--; serializedObject.ApplyModifiedProperties(); }