代码拉取完成,页面将自动刷新
using System;
using spaar.ModLoader;
using UnityEngine;
using System.IO;
using System.Collections.Generic;
namespace Texture_Things_Mod
{
public class TextureingMod : Mod
{
public override string Name { get { return "Texture_Things_Mod"; } }
public override string DisplayName { get { return "Texture Things Mod"; } }
public override string BesiegeVersion { get { return "v0.27"; } }
public override string Author { get { return "覅是"; } }
public override Version Version { get { return new Version("0.5"); } }
public override bool CanBeUnloaded { get { return true; } }
private GameObject temp = new GameObject();
public override void OnLoad()
{
temp.name = "Texturing Mod";
temp.AddComponent<Painter>();
GameObject.DontDestroyOnLoad(temp);
}
public override void OnUnload()
{
GameObject.Destroy(temp.GetComponent<Painter>());
GameObject.Destroy(temp);
}
}
public class Painter : MonoBehaviour
{
public Texture TextureTempelate;
public bool UseTransparent = false;
public Key TextureActivationKey;
void Start()
{
Commands.RegisterCommand("TextureFileName", (args, notUses) =>
{
try
{
WWW tempwww = new WWW("File:///" + Application.dataPath + "/Mods/Blocks/Textures/" + args[0]);
TextureTempelate = tempwww.texture;
return "Done! Now texturing things will use " + args[0] + "!";
}
catch { return "Cannot Find the file! Please put it under " + Application.dataPath + "/Mods/Blocks/Textures/"+" !"; }
}, "Reset texture for texturing.");//Tf
Commands.RegisterCommand("UseTransparting", (args, notUses) =>
{
UseTransparent = !UseTransparent;
if(UseTransparent)
{
return "Done! Now the textures can be transparent!";
}
else
{
return "Done! Now the textures will not be transparent!";
}
}, "Reset if texturing is transparent.");//Tr
TextureActivationKey = Keybindings.AddKeybinding("Texturing", new Key(KeyCode.LeftControl, KeyCode.T));
}
void Update()
{
if (TextureActivationKey.IsDown() ^ Input.GetKeyDown(KeyCode.F10))
{
TextureTempelate.wrapMode = TextureWrapMode.Clamp;
RaycastHit hitt;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitt, float.PositiveInfinity))
{
try
{
try
{
hitt.transform.gameObject.GetComponent<Renderer>().material.mainTexture = null;
//hitt.transform.gameObject.GetComponent<Renderer>().material.color = new Color(0,0,0,0);
hitt.transform.gameObject.GetComponent<Renderer>().material.SetTexture("_MainTex", TextureTempelate);
if (UseTransparent)
{
hitt.transform.gameObject.GetComponent<Renderer>().material.shader = Shader.Find("Transparent/Diffuse");
}
}
catch
{
try
{
foreach (Renderer re in hitt.transform.GetComponentsInChildren<Renderer>())
{
re.material.mainTexture = null;
//re.material.color = new Color(0,0,0,0);
re.material.SetTexture("_MainTex", TextureTempelate);
if (UseTransparent)
{ re.material.shader = Shader.Find("Transparent/Diffuse"); }
}
}
catch { }
}
}
catch (Exception e) { Debug.Log(e); }
}
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。