public void AssignToNode(Texture tex, Painting.Channels channels, TC_Node node)
        {
            if (node == null)
            {
                return;
            }

            UpdateNodeTarget(node);

            node.stampTex = tex;
//			node.size.y = 1000;
            if (channels != Painting.Channels.RGBA)
            {
                if (node.imageSettings == null)
                {
                    node.imageSettings = new ImageSettings();
                }
                int active = (int)channels - 2;
                for (int i = 0; i < node.imageSettings.colChannels.Length; i++)
                {
                    node.imageSettings.colChannels[i].active = i == active;
                }
            }
            node.active = node.enabled = node.stampTex != null;
        }
        public void AssignCanvas(params RenderTexture[] textures)
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
            { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(gameObject.scene); }
#else
            { UnityEditor.EditorApplication.MarkSceneDirty(); }
#endif
#endif

            if (textures == null || textures.Length == 0 || textures.Any((RT) => RT == null))
            {
                if (TCNode != null)
                {
                    AssignToNode(Texture2D.blackTexture, TCNode);
                }
                for (int ch = 0; ch < channelTargets.Count; ch++)
                {
                    ChannelNodeTargets channelTarget = channelTargets[ch];
                    for (int i = 0; i < channelTarget.targets.Count; i++)
                    {
                        AssignToNode(Texture2D.blackTexture, channelTarget.targets[i]);
                    }
                }
            }
            else
            {
                if (TCNode != null)
                {
                    AssignToNode(textures[0], TCNode);
                }
                for (int ch = 0; ch < painter.canvasChannelCount && ch < channelTargets.Count; ch++)
                {
                    ChannelNodeTargets channelTarget = channelTargets[ch];
                    int texIndex = Mathf.Clamp(Mathf.FloorToInt((float)ch / 4), 0, textures.Length - 1);
                    Painting.Channels texChannels = painter.canvasFormat == Painting.Format.Multi ? (Painting.Channels)(ch % 4 + 2) : Painting.Channels.RGBA;
                    for (int i = 0; i < channelTarget.targets.Count; i++)
                    {
                        AssignToNode(textures[texIndex], texChannels, channelTarget.targets[i]);
                    }
                }
            }

            painter.canvasRotation = transform.localRotation.eulerAngles.y / 180;
            if (!painter.isDrawing || Settings.autoGenerate)
            {
                if (TC_Generate.instance != null)
                {
                    TC.AutoGenerate(FinalizeGenerateRect());
                }
            }
        }