private TreeFunctionAsset ToTrunkFunction(TreeFunctionAsset parent)
        {
            TrunkFunction function = ScriptableObject.CreateInstance <TrunkFunction>();

            function.Init(parent);
            function.number               = Tnumber;
            function.displacementSize     = TdisplacementSize;
            function.displacementStrength = TdisplacementStrength;
            function.seed             = seed;
            function.flareNumber      = TflareNumber;
            function.heightOffset     = TheightOffset;
            function.length           = Tlength;
            function.originAttraction = ToriginAttraction;
            function.radius           = Tradius;
            function.radiusMultiplier = TradiusMultiplier;
            function.randomness       = Trandomness;
            function.resolution       = Tresolution;
            function.rootHeight       = TrootHeight;
            function.rootInnerRadius  = TrootInnerRadius;
            function.rootRadius       = TrootRadius;
            function.rootResolution   = TrootResolution;
            function.rootShape        = TrootShape;
            function.spinAmount       = TspinAmount;

            return(function);
        }
        void UpdateBranch(bool normalShader = false)
        {
            switch (texSize)
            {
            case EnumTextureSize._512:
                textureSize = 512;
                break;

            case EnumTextureSize._1024:
                textureSize = 1024;
                break;

            case EnumTextureSize._2048:
                textureSize = 2048;
                break;

            case EnumTextureSize._4096:
                textureSize = 4096;
                break;
            }

            if (branchObject == null)
            {
                CreateBranchObject(normalShader);
            }
            if (!deadLeafsRendering)
            {
                CreateLeafMesh();
            }
            MTree         branch        = new MTree(branchObject.transform);
            TrunkFunction trunkFunction = ScriptableObject.CreateInstance <TrunkFunction>();

            trunkFunction.Init(null);

            float resolution = 20;

            Random.InitState(seed);


            branch.AddTrunk(Vector3.up, Vector3.forward, stemLength, AnimationCurve.Linear(0, 1, 1, .3f), radius, resolution, randomness / 3, 0, AnimationCurve.Linear(0, 1, 0, 0), 0, .01f, 1, 0);
            branch.TwigSplit(branchNumber, angle * 90f, .9f, 0f);
            branch.Grow(length, AnimationCurve.Linear(0, 1, 1, 1), resolution, splitProba, AnimationCurve.Linear(0, 1, 1, 1), angle, 2, 1, 1, randomness, AnimationCurve.Linear(0, 1, 1, .4f), .9f, 0f, 0f, 1f, 0.00001f);
            if (!deadLeafsRendering)
            {
                branch.AddLeafs(leafCovering, leafNumber, new Mesh[] { leafMesh }, leafSize, false, 0, 0, 1, leafAngle, false, 0, 0, 0, 0);
            }
            Mesh mesh = CreateBranchMesh(branch, trunkFunction);

            branchObject.GetComponent <MeshFilter>().mesh = mesh;

            if (cameraObject == null)
            {
                CreateCameraObject();
            }
            RenderCamera();

            DestoyObjects();
        }