protected virtual void OnEnable() { // Load the mixture graph: graph = MixtureEditorUtils.GetGraphAtPath(AssetDatabase.GetAssetPath(target)); variant = MixtureEditorUtils.GetVariantAtPath(AssetDatabase.GetAssetPath(target)); if (graph != null) { exposedParameterFactory = new ExposedParameterFieldFactory(graph); graph.onExposedParameterListChanged += UpdateExposedParameters; graph.onExposedParameterModified += UpdateExposedParameters; Undo.undoRedoPerformed += UpdateExposedParameters; } if (variant != null) { graph = variant.parentGraph; if (graph != null) { exposedParameterFactory = new ExposedParameterFieldFactory(variant.parentGraph); Editor.CreateCachedEditor(variant, typeof(MixtureVariantInspector), ref variantEditor); } else { Debug.LogError("Can't find parent graph for Mixture Variant " + variant); } } }
protected void OnEnable() { variant = target as MixtureVariant; graph = variant.parentGraph; if (graph != null) { graph.onExposedParameterListChanged += UpdateParameters; graph.onExposedParameterModified += UpdateParameters; graph.onExposedParameterValueChanged += UpdateParameters; Undo.undoRedoPerformed += UpdateParameters; } variant.variantTexturesUpdated += UpdateIsDirtyAndPreview; MixtureVariant parent = variant.parentVariant; while (parent != null) { parent.parameterValueChanged += UpdateParameters; parent = parent.parentVariant; } // TODO: create a temp render texture to copy the result of the graph we process // it will be used to display in real time how the parameter changes affects the texture // Update serialized parameters (for the inspector) SyncParameters(); exposedParameterFactory = new ExposedParameterFieldFactory(graph, visibleParameters); overrideParameterView = Resources.Load <VisualTreeAsset>("UI Blocks/MixtureVariantParameter"); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { renderTextureEditorType = assembly.GetType("UnityEditor.RenderTextureEditor"); if (renderTextureEditorType != null) { break; } } variantPreview = new RenderTexture(1, 1, 0); }
protected virtual void OnDisable() { if (graph != null) { graph.onExposedParameterListChanged -= UpdateExposedParameters; graph.onExposedParameterModified -= UpdateExposedParameters; Undo.undoRedoPerformed -= UpdateExposedParameters; exposedParameterFactory.Dispose(); exposedParameterFactory = null; } if (defaultTextureEditor != null) { DestroyImmediate(defaultTextureEditor); } if (variantEditor != null) { DestroyImmediate(variantEditor); } }