Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating an InkCanvas on runtime. #74

Open
DKarampistis opened this issue Sep 1, 2022 · 2 comments
Open

Creating an InkCanvas on runtime. #74

DKarampistis opened this issue Sep 1, 2022 · 2 comments

Comments

@DKarampistis
Copy link

DKarampistis commented Sep 1, 2022

I am using CSG (Constructive Solid Geometry) to create a mesh on runtime. The mesh is given a MeshCollider component and collisions work fine. I tried to add an InkCanvas component but it was causing an exception.
NullReferenceException: Object reference not set to an instance of an object Es.InkPainter.InkCanvas.InitPropertyID () (at Assets/InkPainter/Script/Core/InkCanvas.cs:323) Es.InkPainter.InkCanvas.Awake () (at Assets/InkPainter/Script/Core/InkCanvas.cs:265) UnityEngine.GameObject:AddComponent() ObstacleGeneratorV2:Start() (at Assets/Scripts/ObstacleGeneratorV2.cs:26)

The InkCanvas is added after the MeshCollider. Here is a part of the code:

        Model result = CSG.Subtract(bigGameObject, smallGameObject);
        var composite = new GameObject();
        composite.tag = "Obstacle";
        composite.AddComponent<MeshFilter>().sharedMesh = result.mesh;
        composite.AddComponent<MeshCollider>().sharedMesh = result.mesh;
        composite.AddComponent<MeshRenderer>().sharedMaterials = result.materials.ToArray();
        composite.AddComponent<InkCanvas>();
        composite.transform.parent = this.transform; 

Am I adding the component wrong or it's not possible for it to be added on runtime.

@hassannibg
Copy link

Hey! did you find any solution for this problem

@DKarampistis
Copy link
Author

Unfortunately no

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants