bool drawEffectChooserPopup()
        {
            var createdEffect = false;

            if (ImGui.BeginPopup("effect-chooser"))
            {
                foreach (var subclassType in InspectorCache.getAllEffectSubclassTypes())
                {
                    if (ImGui.Selectable(subclassType.Name))
                    {
                        // create the Effect, remove the existing EffectInspector and create a new one
                        var effect   = Activator.CreateInstance(subclassType) as Effect;
                        var material = getValue <Material>();
                        material.effect = effect;

                        for (var i = _inspectors.Count - 1; i >= 0; i--)
                        {
                            if (_inspectors[i].GetType() == typeof(EffectInspector))
                            {
                                _inspectors.RemoveAt(i);
                            }
                        }

                        var inspector = new EffectInspector();
                        inspector.setTarget(material, ReflectionUtils.getFieldInfo(material, "effect"));
                        inspector.initialize();
                        _inspectors.Add(inspector);

                        createdEffect = true;
                    }
                }
                ImGui.EndPopup();
            }
            return(createdEffect);
        }
Esempio n. 2
0
    private void Refresh()
    {
        if (!_cache.TryGetValue(state, out cache))
        {
            cache = new InspectorCache();
            _cache.Add(state, cache);
        }

        CleanupCache();

        cache.UpdateFrom(state);
        EditorUtility.SetDirty(target);
    }
Esempio n. 3
0
 void drawPostProcessorSelectorPopup()
 {
     if (ImGui.BeginPopup("postprocessor-selector"))
     {
         foreach (var subclassType in InspectorCache.getAllPostProcessorSubclassTypes())
         {
             if (ImGui.Selectable(subclassType.Name))
             {
                 var postprocessor = (PostProcessor)Activator.CreateInstance(subclassType, new object[] { _postProcessorInspectors.Count });
                 Core.scene.addPostProcessor(postprocessor);
                 _isPostProcessorListInitialized = false;
             }
         }
         ImGui.EndPopup();
     }
 }
Esempio n. 4
0
 private void Refresh()
 {
     cache = _cache.GetValue(state, _ => new InspectorCache());
     cache.UpdateFrom(state);
     EditorUtility.SetDirty(target);
 }