//---------------------------------------------------------------------------- public override void OnInspectorGUI() { serializedObject.Update(); if (!string.IsNullOrEmpty(m_FxName.stringValue) && File.Exists("Assets/StreamingAssets/PackFx/" + m_FxName.stringValue)) { m_BoundFx.objectReferenceValue = AssetDatabase.LoadAssetAtPath("Assets/StreamingAssets/PackFx/" + m_FxName.stringValue, typeof(Object)); } m_BoundFx.objectReferenceValue = EditorGUILayout.ObjectField("FX", m_BoundFx.objectReferenceValue, typeof(Object), false); string tmpPath = ""; if (m_BoundFx.objectReferenceValue != null) { tmpPath = AssetDatabase.GetAssetPath(m_BoundFx.objectReferenceValue); } if (tmpPath.StartsWith("Assets/StreamingAssets/PackFx/") && tmpPath.EndsWith(".pkfx")) { if (tmpPath.Substring("Assets/StreamingAssets/PackFx/".Length) != m_FxName.stringValue) { m_FxName.stringValue = tmpPath.Substring("Assets/StreamingAssets/PackFx/".Length); serializedObject.ApplyModifiedProperties(); if (!string.IsNullOrEmpty(this.m_FxName.stringValue)) { PKFxManager.PreLoadFxIFN(this.m_FxName.stringValue); } Reload(true); if (Application.isPlaying) { (serializedObject.targetObject as PKFxFX).StartEffect(); } } } else { if (!string.IsNullOrEmpty(tmpPath)) { Debug.LogError("[PKFX] Invalid FX path.\n" + "Effects must be baked in Assets/StreamingAssets/PackFx/ (case sensitive) and have a .pkfx extension"); } else { m_FxName.stringValue = ""; } m_BoundFx.objectReferenceValue = null; serializedObject.ApplyModifiedProperties(); Reload(false); } EditorGUI.BeginDisabledGroup(true); EditorGUILayout.PropertyField(this.m_IsPlaying); EditorGUI.EndDisabledGroup(); EditorGUILayout.PropertyField(this.m_PlayOnStart); for (int i = 0; i < this.m_FxSamplers.arraySize; i++) { SerializedProperty smp = this.m_FxSamplers.GetArrayElementAtIndex(i); SamplerField(smp); } if (m_FxAttributes.hasMultipleDifferentValues == false) { for (int i = 0; i < this.m_FxAttributes.arraySize; i++) { SerializedProperty attr = this.m_FxAttributes.GetArrayElementAtIndex(i); attr = PKFxEditor.AttributeField(attr); } } serializedObject.ApplyModifiedProperties(); displayPlaybackBtns(); }
//---------------------------------------------------------------------------- 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(); }