
Risk of Rain 2
You are viewing a potentially older version of this package. View Latest Version

Created using https://thunderstore.io/package/Brynzananas/Body_Model_Additions_API/
All code as an example:
using R2API.Utils;
using System.Security.Permissions;
using System.Security;
using static BodyModelAdditionsAPI.Main;
using UnityEngine;
using RoR2;
using System;
using UnityEngine.AddressableAssets;
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: HG.Reflection.SearchableAttribute.OptIn]
[assembly: HG.Reflection.SearchableAttribute.OptInAttribute]
[module: UnverifiableCode]
#pragma warning disable CS0618
#pragma warning restore CS0618
namespace FreakyEyes
{
[BepInPlugin(ModGuid, ModName, ModVer)]
[BepInDependency(R2API.R2API.PluginGUID, R2API.R2API.PluginVersion)]
//[R2APISubmoduleDependency(nameof(CommandHelper))]
[System.Serializable]
public class Main : BaseUnityPlugin
{
public const string ModGuid = "com.brynzananas.freakyeyes";
public const string ModName = "Freaky Eyes";
public const string ModVer = "1.0.0";
public static AssetBundle assetBundle;
public static PluginInfo PInfo { get; private set; }
public void Awake()
{
PInfo = Info;
assetBundle = AssetBundle.LoadFromFile(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(PInfo.Location), "assetbundles", "freakyeye"));
foreach (Material material in assetBundle.LoadAllAssets<Material>())
{
if (!material.shader.name.StartsWith("StubbedRoR2"))
{
continue;
}
string shaderName = material.shader.name.Replace("StubbedRoR2", "RoR2") + ".shader";
Shader replacementShader = Addressables.LoadAssetAsync<Shader>(shaderName).WaitForCompletion();
if (replacementShader)
{
material.shader = replacementShader;
}
}
new ModelPart("FlyingVerminBody", assetBundle.LoadAsset<GameObject>("Assets/CosmeticsMod/googlyeye.prefab"), "Body", inputCodeAfterApplying: PlaceIt);
void PlaceIt(GameObject modelObject, ChildLocator childLocator, CharacterModel characterModel)
{
modelObject.transform.localPosition = new Vector3(-0.45f, 0.641f, .89f);
modelObject.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
}
new ModelPart("FlyingVerminBody", assetBundle.LoadAsset<GameObject>("Assets/CosmeticsMod/googlyeye.prefab"), "Body", inputCodeAfterApplying: PlaceIt2);
void PlaceIt2(GameObject modelObject, ChildLocator childLocator, CharacterModel characterModel)
{
modelObject.transform.localPosition = new Vector3(0.45f, 0.641f, .89f);
modelObject.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
}
}
}
}