Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - wheee09

Pages: [1]
This seems to have been introduced in earlier versions of 2021.1.x and was fixed but when you have the Substance plugin installed, you still get the error.

Based on the other threads, I'm going to guess that we need to wait for the new version of Substance. 

See the original defect:

Verified the issue on:
Unity Editor - 2021.1.6 and 2021.1.7
Substance in Unity Plugin - 2.4.5 and 2.5.4
MacOS (based on the original defect, it seemed to be a defect that affected Macs only)

Steps to reproduce:
  • Install Unity 2021.1.7
  • Install Substance Plugin 2.4.5
  • Import any image
  • Select the image in the editor
See the following error:
InvalidCastException: Specified cast is not valid.
  at UnityEditor.TextureImporterInspector.get_textureInspector () [0x00000] in /Users/bokken/buildslave/unity/build/Editor/Mono/ImportSettings/TextureImporterInspector.cs:119
  at UnityEditor.TextureImporterInspector.DrawPreview (UnityEngine.Rect previewArea) [0x00009] in /Users/bokken/buildslave/unity/build/Editor/Mono/ImportSettings/TextureImporterInspector.cs:1597
  at UnityEditor.PropertyEditor.DrawPreviewAndLabels () [0x0050f] in /Users/bokken/buildslave/unity/build/Editor/Mono/Inspector/PropertyEditor.cs:1310
  at UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) [0x001df] in /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.u
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.UIElements.IMGUIContainer:DoOnGUI(Event, Matrix4x4, Rect, Boolean, Rect, Action, Boolean) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:360)
UnityEngine.UIElements.IMGUIContainer:DoMeasure(Single, MeasureMode, Single, MeasureMode) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:815)
UnityEngine.UIElements.VisualElement:Measure(YogaNode, Single, YogaMeasureMode, Single, YogaMeasureMode) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/VisualElement.cs:1539)
UnityEngine.UIElements.VisualElement:<AssignMeasureFunction>b__203_0(YogaNode, Single, YogaMeasureMode, Single, YogaMeasureMode) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/VisualElement.cs:1523)
UnityEngine.Yoga.YogaNode:MeasureInternal(YogaNode, Single, YogaMeasureMode, Single, YogaMeasureMode) (at /Users/bokken/buildslave/unity/build/External/Yoga/csharp/Facebook.Yoga/YogaNode.cs:689)
UnityEngine.Yoga.Native:YGNodeMeasureInvoke(YogaNode, Single, YogaMeasureMode, Single, YogaMeasureMode, IntPtr) (at /Users/bokken/buildslave/unity/build/External/Yoga/csharp/Facebook.Yoga/YogaNative.bindings.cs:146)
UnityEngine.Yoga.Native:YGNodeCalculateLayout(IntPtr, Single, Single, YogaDirection)
UnityEngine.Yoga.YogaNode:CalculateLayout(Single, Single) (at /Users/bokken/buildslave/unity/build/External/Yoga/csharp/Facebook.Yoga/YogaNode.cs:665)
UnityEngine.UIElements.UIRLayoutUpdater:Update() (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/Renderer/UIRLayoutUpdater.cs:51)
UnityEngine.UIElements.VisualTreeUpdater:UpdateVisualTreePhase(VisualTreeUpdatePhase) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/VisualTreeUpdater.cs:155)
UnityEngine.UIElements.Panel:UpdateForRepaint() (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/Panel.cs:940)
UnityEngine.UIElements.Panel:Repaint(Event) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/Panel.cs:985)
UnityEngine.UIElements.UIElementsUtility:DoDispatch(BaseVisualElementPanel) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/UIElementsUtility.cs:446)
UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/UIElementsUtility.cs:209)
UnityEngine.UIElements.UIEventRegistration:ProcessEvent(Int32, IntPtr) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/UIElementsUtility.cs:74)
UnityEngine.UIElements.<>c:<.cctor>b__1_2(Int32, IntPtr) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/UIElementsUtility.cs:28)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

(Filename: /Users/bokken/buildslave/unity/build/Editor/Mono/ImportSettings/TextureImporterInspector.cs Line: 119)


So I'm rewriting this asset that uses Substance for my own purposes.  I never heard of Substance before that so I'm a bit new to it so please bear with me.

What I'm trying to do is essentially generate planets for a level procedurally. 

Here some of the characteristics/requirements:
- There can be many planets on this level.
- Each planet has a type: eg. earth, lava, ice, gas, etc.
- There could be many planets of the same type. 
- These planets (of the same type) should look differently from each other.

This asset has a number of Substance Graph objects that represent each of the planet types (biomes) along with other characteristics like clouds and so on.

Using a "Dust/Barren biome" as an example, it can take a random seed and other properties and generate textures and I can do all of this via the script.

But where I'm stuck is with how I can generate X number of "Dust/Barren" planets with X number of generated textures with different seeds.

What I want to do is this:
* for each planet in the level do the following:
  - create a planet game object
  - access the "Dust/Barren" SGO, choose a random seed, generate the texture
  - assign texture to the planet's material/mesh render

The problem is that the SGO's generated texture is a shared texture and despite generating the texture with a different seed X times, it means that I'm only changing the same texture X times.  This means that every planet I create using the same SGO will look the same - effectively the last random seed that was used.

It appears the "proper" (?) way to do this is to call Duplicate on the Substance Graph object.  This means calling Duplicate, then generating the texture for each planet on the duplicate instance - X times.

The problem with that is that if I have a 100 planets, after generating the planets, if I view the SGO in Unity, it will have a 100 new Substance graph instances and removing them in the editor is a slow and tedious process.

I'm hoping that there's a better way to do this.  It doesn't make any sense that I would need to duplicate a Substance graph.  It smells of poor design.

I'm going to see if I can copy textures at runtime in Unity and perhaps then I can just use one SG to simply act as Texture Factory/Generator (which to me sounds like what it's supposed to be ...)


Hi all,

I've been trying to workaround this very annoying and frustrating error and I'm able to narrow it down to the Substance plugin for Unity.

Simply put, I have a simple script on a game object that only has a mesh renderer with no material set.  I have a button on the script that when clicked (be it in play mode or in editor) does the following:

Code: [Select]
public Material TestMaterial;

public void onClick()
    var material = new Material(TestMaterial);
    var meshRenderer = GetComponent<MeshRenderer>();
    meshRenderer.material = material;

When you inspect the game object and click the button which runs the simple script, you will see the material/shader in the inspector.

When you try to expand it, nothing shows up and you get the following error showing up in the console over and over (while the material/shader is expanded).

I did this on a brand new project without the Substance plugin and it works fine.  As soon as I import the Substance plugin, it happens.

Other notes:
* I'm using the latest Unity 2019.3.15 version.
* Running on MacOS
* Also working with URP.
* This only happens when you instantiate a new material.  If you just reference an existing material, then it's fine.  For example:
Code: [Select]
   meshRenderer.material = TestMaterial;

It's very frustrating.  Tracing through the Unity code, it appears that the LightMapSettings object is not initialized in the MaterialEditor - in fact, the real issue is that the onEnable of the MaterialEditor is never run when you expand the Material/Shader in the inspector which is causing the LightMapSettings to not be initialized thereby causing the NullReferenceException.  My guess is that the Substance plugin is overriding this behaviour and not running base.

Pages: [1]