Search Unity

Preview window does not show blendweights

Discussion in 'Immediate Mode GUI (IMGUI)' started by BinaryCats, Mar 20, 2018.

  1. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    Hi,

    I am working on an editor which has a preview window
    drawn as following (abridged)
    Code (csharp):
    1.  
    2.  Editor gameObjectEditor = Editor.CreateEditor(MyGameObject);//cached
    3. ...
    4.             gameObjectEditor.OnPreviewGUI(position, null);
    5.  
    everything shows as expected until I alter the blendweights (on the skinned mesh renderer) of MyGameObject with a slider

    I can see in scene that the blendweights are effecting the mesh, but not in the preview window.

    Code (csharp):
    1. [/LEFT]
    2.             m_Renderers[0].SetBlendShapeWeight(0, EditorGUILayout.Slider("Damage",m_Renderers[0].GetBlendShapeWeight(0), 0, 100));
    3.  
    Does not work, but the following code does

    Code (csharp):
    1. m_Renderers[0].SetBlendShapeWeight(0, 100)


    any thoughts what I am doing wrong here?

    Thanks
     
    Last edited: Mar 20, 2018
  2. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    I'm assuming what is happening here is that the first time the preview window draws, it creates a copy of the gameobject that its displaying. If that is the case, how do I go about getting that copy of the game object?
     
    Last edited: Mar 20, 2018
  3. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    I found out that if I do:

    Code (csharp):
    1. gameObjectEditor.ReloadPreviewInstances()
    It instantiates a new previewed object with the new blendweights. However, it does not remove the old one. Is it possible to remove the gameobject from the preview scene?