Esempio n. 1
0
        /// <summary>
        /// Saves the texture used for this node's mesh renderer
        /// <br/>
        /// By default, this saves to local files, aka "C:\Users\...\AppData\LocalLow\Ninja Kiwi\BloonsTD6"
        /// </summary>
        /// <param name="node">The UnityDisplayNode</param>
        /// <param name="index"></param>
        /// <param name="path">Optional path to save to instead</param>
        public static void SaveMeshTexture(this UnityDisplayNode node, int index = 0, string path = null)
        {
            if (path == null)
            {
                path = FileIOUtil.GetSandboxPath() + node.name + index + ".png";
            }

            var meshRenderers = node.GetMeshRenderers();

            if (meshRenderers.Count == 0)
            {
                MelonLogger.Error("Can't save mesh texture because the node doesn't have any MeshRenderers or SkinnedMeshRenderers, you might want to call node.PrintInfo()");
            }
            else if (meshRenderers.Count <= index)
            {
                MelonLogger.Error($"The node doesn't have {index} total mesh renderers, you might want to call node.PrintInfo()");
            }
            else
            {
                meshRenderers[index].material.mainTexture.TrySaveToPNG(path);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Gets the first (or an indexed) SkinnedMeshRenderer/MeshRenderer
 /// </summary>
 /// <param name="node"></param>
 /// <param name="index"></param>
 /// <param name="recalculate"></param>
 /// <returns></returns>
 public static Renderer GetMeshRenderer(this UnityDisplayNode node, int index = 0, bool recalculate = true)
 {
     return(node.GetMeshRenderers()[index]);
 }