Here are the examples of the csharp api UnityEngine.Transform.Find(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
159 Examples
19
Source : AHSSShotGunCollider.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private bool checkIfBehind(GameObject replacedan)
{
Transform transform = replacedan.transform.Find("Amarture/Core/Controller_Body/hip/spine/chest/neck/head");
Vector3 to = baseT.position - transform.transform.position;
return Vector3.Angle(-transform.transform.Forward(), to) < 100f; //Note: was 70f before, Edited to 100 to fit RC mod
}
19
Source : TriggerColliderWeapon.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private bool checkIfBehind(GameObject replacedan)
{
Transform transform = replacedan.transform.Find("Amarture/Core/Controller_Body/hip/spine/chest/neck/head");
Vector3 to = baseT.position - transform.transform.position;
return Vector3.Angle(-transform.transform.Forward(), to) < 70f;
}
19
Source : HERO_SETUP.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private void Awake()
{
baseT = transform;
this.part_head.transform.parent = baseT.Find("Amarture/Controller_Body/hip/spine/chest/neck/head").transform;
this.mount_3dmg = new GameObject();
this.mount_3dmg_gas_l = new GameObject();
this.mount_3dmg_gas_r = new GameObject();
this.mount_3dmg_gun_mag_l = new GameObject();
this.mount_3dmg_gun_mag_r = new GameObject();
this.mount_weapon_l = new GameObject();
this.mount_weapon_r = new GameObject();
this.mount_3dmg.transform.position = baseT.position;
this.mount_3dmg.transform.rotation = Quaternion.Euler(270f, baseT.rotation.eulerAngles.y, 0f);
this.mount_3dmg.transform.parent = baseT.Find("Amarture/Controller_Body/hip/spine/chest").transform;
this.mount_3dmg_gas_l.transform.position = baseT.position;
this.mount_3dmg_gas_l.transform.rotation = Quaternion.Euler(270f, baseT.rotation.eulerAngles.y, 0f);
this.mount_3dmg_gas_l.transform.parent = baseT.Find("Amarture/Controller_Body/hip/spine").transform;
this.mount_3dmg_gas_r.transform.position = baseT.position;
this.mount_3dmg_gas_r.transform.rotation = Quaternion.Euler(270f, baseT.rotation.eulerAngles.y, 0f);
this.mount_3dmg_gas_r.transform.parent = baseT.Find("Amarture/Controller_Body/hip/spine").transform;
this.mount_3dmg_gun_mag_l.transform.position = baseT.position;
this.mount_3dmg_gun_mag_l.transform.rotation = Quaternion.Euler(270f, baseT.rotation.eulerAngles.y, 0f);
this.mount_3dmg_gun_mag_l.transform.parent = baseT.Find("Amarture/Controller_Body/hip/thigh_L").transform;
this.mount_3dmg_gun_mag_r.transform.position = baseT.position;
this.mount_3dmg_gun_mag_r.transform.rotation = Quaternion.Euler(270f, baseT.rotation.eulerAngles.y, 0f);
this.mount_3dmg_gun_mag_r.transform.parent = baseT.Find("Amarture/Controller_Body/hip/thigh_R").transform;
this.mount_weapon_l.transform.position = baseT.position;
this.mount_weapon_l.transform.rotation = Quaternion.Euler(270f, baseT.rotation.eulerAngles.y, 0f);
this.mount_weapon_l.transform.parent = baseT.Find("Amarture/Controller_Body/hip/spine/chest/shoulder_L/upper_arm_L/forearm_L/hand_L").transform;
this.mount_weapon_r.transform.position = baseT.position;
this.mount_weapon_r.transform.rotation = Quaternion.Euler(270f, baseT.rotation.eulerAngles.y, 0f);
this.mount_weapon_r.transform.parent = baseT.Find("Amarture/Controller_Body/hip/spine/chest/shoulder_R/upper_arm_R/forearm_R/hand_R").transform;
}
19
Source : HERO_SETUP.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void Create3DMG()
{
UnityEngine.Object.Destroy(this.part_3dmg);
UnityEngine.Object.Destroy(this.part_3dmg_belt);
UnityEngine.Object.Destroy(this.part_3dmg_gas_l);
UnityEngine.Object.Destroy(this.part_3dmg_gas_r);
UnityEngine.Object.Destroy(this.part_blade_l);
UnityEngine.Object.Destroy(this.part_blade_r);
if (this.myCostume.mesh_3dmg.Length > 0)
{
this.part_3dmg = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/" + this.myCostume.mesh_3dmg));
this.part_3dmg.transform.position = this.mount_3dmg.transform.position;
this.part_3dmg.transform.rotation = this.mount_3dmg.transform.rotation;
this.part_3dmg.transform.parent = this.mount_3dmg.transform.parent;
this.part_3dmg.renderer.material = CharacterMaterials.Materials[this.myCostume._3dmg_texture];
}
if (this.myCostume.mesh_3dmg_belt.Length > 0)
{
this.part_3dmg_belt = this.GenerateCloth(this.reference, "Character/" + this.myCostume.mesh_3dmg_belt);
this.part_3dmg_belt.renderer.material = CharacterMaterials.Materials[this.myCostume._3dmg_texture];
}
if (this.myCostume.mesh_3dmg_gas_l.Length > 0)
{
this.part_3dmg_gas_l = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/" + this.myCostume.mesh_3dmg_gas_l));
if (this.myCostume.uniform_type != UNIFORM_TYPE.CasualAHSS)
{
this.part_3dmg_gas_l.transform.position = this.mount_3dmg_gas_l.transform.position;
this.part_3dmg_gas_l.transform.rotation = this.mount_3dmg_gas_l.transform.rotation;
this.part_3dmg_gas_l.transform.parent = this.mount_3dmg_gas_l.transform.parent;
}
else
{
this.part_3dmg_gas_l.transform.position = this.mount_3dmg_gun_mag_l.transform.position;
this.part_3dmg_gas_l.transform.rotation = this.mount_3dmg_gun_mag_l.transform.rotation;
this.part_3dmg_gas_l.transform.parent = this.mount_3dmg_gun_mag_l.transform.parent;
}
this.part_3dmg_gas_l.renderer.material = CharacterMaterials.Materials[this.myCostume._3dmg_texture];
}
if (this.myCostume.mesh_3dmg_gas_r.Length > 0)
{
this.part_3dmg_gas_r = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/" + this.myCostume.mesh_3dmg_gas_r));
if (this.myCostume.uniform_type != UNIFORM_TYPE.CasualAHSS)
{
this.part_3dmg_gas_r.transform.position = this.mount_3dmg_gas_r.transform.position;
this.part_3dmg_gas_r.transform.rotation = this.mount_3dmg_gas_r.transform.rotation;
this.part_3dmg_gas_r.transform.parent = this.mount_3dmg_gas_r.transform.parent;
}
else
{
this.part_3dmg_gas_r.transform.position = this.mount_3dmg_gun_mag_r.transform.position;
this.part_3dmg_gas_r.transform.rotation = this.mount_3dmg_gun_mag_r.transform.rotation;
this.part_3dmg_gas_r.transform.parent = this.mount_3dmg_gun_mag_r.transform.parent;
}
this.part_3dmg_gas_r.renderer.material = CharacterMaterials.Materials[this.myCostume._3dmg_texture];
}
if (this.myCostume.weapon_l_mesh.Length > 0)
{
this.part_blade_l = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/" + this.myCostume.weapon_l_mesh));
this.part_blade_l.transform.position = this.mount_weapon_l.transform.position;
this.part_blade_l.transform.rotation = this.mount_weapon_l.transform.rotation;
this.part_blade_l.transform.parent = this.mount_weapon_l.transform.parent;
this.part_blade_l.renderer.material = CharacterMaterials.Materials[this.myCostume._3dmg_texture];
if (this.part_blade_l.transform.Find("X-WeaponTrailA"))
{
this.part_blade_l.transform.Find("X-WeaponTrailA").GetComponent<XWeaponTrail>().Deactivate();
this.part_blade_l.transform.Find("X-WeaponTrailB").GetComponent<XWeaponTrail>().Deactivate();
if (base.gameObject.GetComponent<HERO>())
{
base.gameObject.GetComponent<HERO>().leftbladetrail = this.part_blade_l.transform.Find("X-WeaponTrailA").GetComponent<XWeaponTrail>();
base.gameObject.GetComponent<HERO>().leftbladetrail2 = this.part_blade_l.transform.Find("X-WeaponTrailB").GetComponent<XWeaponTrail>();
}
}
}
if (this.myCostume.weapon_r_mesh.Length > 0)
{
this.part_blade_r = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/" + this.myCostume.weapon_r_mesh));
this.part_blade_r.transform.position = this.mount_weapon_r.transform.position;
this.part_blade_r.transform.rotation = this.mount_weapon_r.transform.rotation;
this.part_blade_r.transform.parent = this.mount_weapon_r.transform.parent;
this.part_blade_r.renderer.material = CharacterMaterials.Materials[this.myCostume._3dmg_texture];
if (this.part_blade_r.transform.Find("X-WeaponTrailA"))
{
this.part_blade_r.transform.Find("X-WeaponTrailA").GetComponent<XWeaponTrail>().Deactivate();
this.part_blade_r.transform.Find("X-WeaponTrailB").GetComponent<XWeaponTrail>().Deactivate();
if (base.gameObject.GetComponent<HERO>())
{
base.gameObject.GetComponent<HERO>().rightbladetrail = this.part_blade_r.transform.Find("X-WeaponTrailA").GetComponent<XWeaponTrail>();
base.gameObject.GetComponent<HERO>().rightbladetrail2 = this.part_blade_r.transform.Find("X-WeaponTrailB").GetComponent<XWeaponTrail>();
}
}
}
}
19
Source : HERO_SETUP.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void CreateFace()
{
this.part_face = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/character_face"));
this.part_face.transform.position = this.part_head.transform.position;
this.part_face.transform.rotation = this.part_head.transform.rotation;
this.part_face.transform.parent = baseT.Find("Amarture/Controller_Body/hip/spine/chest/neck/head").transform;
}
19
Source : HERO_SETUP.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void CreateGlreplaced()
{
this.part_glreplaced = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/glreplaced"));
this.part_glreplaced.transform.position = this.part_head.transform.position;
this.part_glreplaced.transform.rotation = this.part_head.transform.rotation;
this.part_glreplaced.transform.parent = baseT.Find("Amarture/Controller_Body/hip/spine/chest/neck/head").transform;
}
19
Source : HERO_SETUP.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void CreateHair()
{
UnityEngine.Object.Destroy(this.part_hair);
if (!this.IsDeadBody)
{
ClothFactory.DisposeObject(this.part_hair_1);
}
if (this.myCostume.hair_mesh != string.Empty)
{
this.part_hair = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/" + this.myCostume.hair_mesh));
this.part_hair.transform.position = this.part_head.transform.position;
this.part_hair.transform.rotation = this.part_head.transform.rotation;
this.part_hair.transform.parent = base.transform.Find("Amarture/Controller_Body/hip/spine/chest/neck/head").transform;
this.part_hair.renderer.material = CharacterMaterials.Materials[this.myCostume.hairInfo.texture];
this.part_hair.renderer.material.color = this.myCostume.hair_color;
}
if (this.myCostume.hair_1_mesh.Length > 0 && !this.IsDeadBody)
{
string name = "Character/" + this.myCostume.hair_1_mesh;
Material material = CharacterMaterials.Materials[this.myCostume.hairInfo.texture];
this.part_hair_1 = ClothFactory.GetHair(this.reference, name, material, this.myCostume.hair_color);
}
}
19
Source : HERO_SETUP.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void CreateHead()
{
UnityEngine.Object.Destroy(this.part_eye);
UnityEngine.Object.Destroy(this.part_face);
UnityEngine.Object.Destroy(this.part_glreplaced);
UnityEngine.Object.Destroy(this.part_hair);
if (!this.IsDeadBody)
{
ClothFactory.DisposeObject(this.part_hair_1);
}
this.CreateHair();
if (this.myCostume.eye_mesh.Length > 0)
{
this.part_eye = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/" + this.myCostume.eye_mesh));
this.part_eye.transform.position = this.part_head.transform.position;
this.part_eye.transform.rotation = this.part_head.transform.rotation;
this.part_eye.transform.parent = base.transform.Find("Amarture/Controller_Body/hip/spine/chest/neck/head").transform;
this.SetFacialTexture(this.part_eye, this.myCostume.eye_texture_id);
}
if (this.myCostume.beard_texture_id >= 0)
{
this.CreateFace();
this.SetFacialTexture(this.part_face, this.myCostume.beard_texture_id);
}
if (this.myCostume.glreplaced_texture_id >= 0)
{
this.CreateGlreplaced();
this.SetFacialTexture(this.part_glreplaced, this.myCostume.glreplaced_texture_id);
}
string indexHead = myCostume.skin_texture;
string indexChest = myCostume.skin_texture;
if (!CharacterMaterials.Materials.ContainsKey(indexHead))
{
indexHead = "hair_annie";
}
if (!CharacterMaterials.Materials.ContainsKey(indexChest))
{
indexChest = "aottg_hero_skin_1";
}
this.part_head.renderer.material = CharacterMaterials.Materials[indexHead];
this.part_chest.renderer.material = CharacterMaterials.Materials[indexChest];
}
19
Source : RockThrow.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
[RPC]
private void initRPC(int viewID, Vector3 scale, Vector3 pos, float level)
{
GameObject gameObject = PhotonView.Find(viewID).gameObject;
Transform parent = gameObject.transform.Find("Amarture/Core/Controller_Body/hip/spine/chest/shoulder_R/upper_arm_R/forearm_R/hand_R/hand_R_001");
baseT.localScale = gameObject.transform.localScale;
baseT.parent = parent;
baseT.localPosition = pos;
}
19
Source : HERO_SETUP.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void CreateHead()
{
UnityEngine.Object.Destroy(this.part_eye);
UnityEngine.Object.Destroy(this.part_face);
UnityEngine.Object.Destroy(this.part_glreplaced);
UnityEngine.Object.Destroy(this.part_hair);
if (!this.IsDeadBody)
{
ClothFactory.DisposeObject(this.part_hair_1);
}
this.CreateHair();
if (this.myCostume.eye_mesh.Length > 0)
{
this.part_eye = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/" + this.myCostume.eye_mesh));
this.part_eye.transform.position = this.part_head.transform.position;
this.part_eye.transform.rotation = this.part_head.transform.rotation;
this.part_eye.transform.parent = base.transform.Find("Amarture/Controller_Body/hip/spine/chest/neck/head").transform;
this.SetFacialTexture(this.part_eye, this.myCostume.eye_texture_id);
}
if (this.myCostume.beard_texture_id >= 0)
{
this.CreateFace();
this.SetFacialTexture(this.part_face, this.myCostume.beard_texture_id);
}
if (this.myCostume.glreplaced_texture_id >= 0)
{
this.CreateGlreplaced();
this.SetFacialTexture(this.part_glreplaced, this.myCostume.glreplaced_texture_id);
}
string indexHead = myCostume.skin_texture;
string indexChest = myCostume.skin_texture;
if(!CharacterMaterials.Materials.ContainsKey(indexHead))
{
indexHead = "hair_annie";
}
if (!CharacterMaterials.Materials.ContainsKey(indexChest))
{
indexChest = "aottg_hero_skin_1";
}
this.part_head.renderer.material = CharacterMaterials.Materials[indexHead];
this.part_chest.renderer.material = CharacterMaterials.Materials[indexChest];
}
19
Source : IN_GAME_MAIN_CAMERA.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public GameObject SetMainObject(object obj, bool resetRotation = true, bool lockAngle = false)
{
if (obj == null)
{
Head = null;
this.distanceMulti = this.heightMulti = 1f;
}
else if (obj is HERO)
{
usingreplacedan = false;
MainHERO = (HERO)obj;
MainreplacedAN = null;
MainObject = (obj as HERO).baseG;
Head = ((HERO)obj).baseT.Find("Amarture/Controller_Body/hip/spine/chest/neck/head");
if (Interpolation.Value)
{
MainHERO.rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
}
this.distanceMulti = this.heightMulti = 0.64f;
if (resetRotation)
{
BaseT.rotation = Quaternion.Euler(0f, 0f, 0f);
}
}
else if (obj is replacedAN)
{
usingreplacedan = true;
MainreplacedAN = obj as replacedAN;
MainHERO = null;
MainEREN = null;
MainObject = MainreplacedAN.baseG;
Head = MainT.transform.Find("Amarture/Core/Controller_Body/hip/spine/chest/neck/head");
this.distanceMulti = (Head != null) ? (Vector3.Distance(Head.position, MainT.position) * 0.4f) : 1f;
this.heightMulti = (Head != null) ? (Vector3.Distance(Head.position, MainT.position) * 0.45f) : 1f;
if (resetRotation)
{
BaseT.rotation = Quaternion.Euler(0f, 0f, 0f);
}
}
else if (obj is replacedAN_EREN)
{
MainEREN = obj as replacedAN_EREN;
MainreplacedAN = null;
MainObject = MainEREN.gameObject;
Head = MainT.transform.Find("Amarture/Core/Controller_Body/hip/spine/chest/neck/head");
this.distanceMulti = (Head != null) ? (Vector3.Distance(Head.position, MainT.position) * 0.2f) : 1f;
this.heightMulti = (Head != null) ? (Vector3.Distance(Head.position, MainT.position) * 0.33f) : 1f;
if (resetRotation)
{
BaseT.rotation = Quaternion.Euler(0f, 0f, 0f);
}
}
else
{
Head = null;
this.distanceMulti = this.heightMulti = 1f;
if (resetRotation)
{
BaseT.rotation = Quaternion.Euler(0f, 0f, 0f);
}
if (obj is GameObject obje)
{
MainObject = obje;
}
}
this.lockAngle = lockAngle;
VideoSettings.Apply();
return MainObject;
}
19
Source : SettingReciveInput.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private void OnClick()
{
FengCustomInputs.Main.startListening(this.id);
base.transform.Find("Label").gameObject.GetComponent<UILabel>().text = "*wait for input";
}
19
Source : TriggerColliderWeapon.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private void napeMeat(Vector3 vkill, Transform replacedan)
{
Transform transform = replacedan.transform.Find("Amarture/Core/Controller_Body/hip/spine/chest/neck");
GameObject gameObject = Pool.Enable("replacedanNapeMeat", transform.position, transform.rotation);//(GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("replacedanNapeMeat"), transform.position, transform.rotation);
gameObject.transform.localScale = replacedan.localScale;
gameObject.rigidbody.AddForce(vkill.normalized * 15f, ForceMode.Impulse);
gameObject.rigidbody.AddForce(-replacedan.forward * 10f, ForceMode.Impulse);
gameObject.rigidbody.AddTorque(new Vector3((float)UnityEngine.Random.Range(-100, 100), (float)UnityEngine.Random.Range(-100, 100), (float)UnityEngine.Random.Range(-100, 100)), ForceMode.Impulse);
}
19
Source : HERO_ON_MENU.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private void Start()
{
HeroCostume.Init();
HERO_SETUP component = gameObject.GetComponent<HERO_SETUP>();
component.Init();
component.myCostume = HeroCostume.costume[this.costumeId];
component.SetCharacterComponent();
this.head = base.transform.Find("Amarture/Controller_Body/hip/spine/chest/neck/head");
this.cameraPref = base.transform.Find("Amarture/Controller_Body/hip/spine/chest/shoulder_R/upper_arm_R");
if (this.costumeId == 9)
{
this.cameraOffset = monoT.position - this.cameraPref.position;
}
if (component.myCostume.sex == Sex.Female)
{
baseA.Play("stand");
baseA["stand"].normalizedTime = UnityEngine.Random.Range(0f, 1f);
}
else
{
baseA.Play("stand_levi");
baseA["stand_levi"].normalizedTime = UnityEngine.Random.Range(0f, 1f);
}
AnimationState animationState = baseA["stand_levi"];
float speed = 0.5f;
baseA["stand"].speed = speed;
animationState.speed = speed;
}
19
Source : HERO_SETUP.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void CreateUpperBody()
{
UnityEngine.Object.Destroy(this.part_upper_body);
UnityEngine.Object.Destroy(this.part_brand_1);
UnityEngine.Object.Destroy(this.part_brand_2);
UnityEngine.Object.Destroy(this.part_brand_3);
UnityEngine.Object.Destroy(this.part_brand_4);
UnityEngine.Object.Destroy(this.part_chest_1);
UnityEngine.Object.Destroy(this.part_chest_2);
if (!this.IsDeadBody)
{
ClothFactory.DisposeObject(this.part_chest_3);
}
this.CreateCape();
if (this.myCostume.part_chest_object_mesh.Length > 0)
{
this.part_chest_1 = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/" + this.myCostume.part_chest_object_mesh));
this.part_chest_1.transform.position = this.chest_info.transform.position;
this.part_chest_1.transform.rotation = this.chest_info.transform.rotation;
this.part_chest_1.transform.parent = base.transform.Find("Amarture/Controller_Body/hip/spine/chest").transform;
this.part_chest_1.renderer.material = CharacterMaterials.Materials[this.myCostume.part_chest_object_texture];
}
if (this.myCostume.part_chest_1_object_mesh.Length > 0)
{
this.part_chest_2 = (GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("Character/" + this.myCostume.part_chest_1_object_mesh));
this.part_chest_2.transform.position = this.chest_info.transform.position;
this.part_chest_2.transform.rotation = this.chest_info.transform.rotation;
this.part_chest_2.transform.parent = base.transform.Find("Amarture/Controller_Body/hip/spine/chest").transform;
this.part_chest_2.transform.parent = base.transform.Find("Amarture/Controller_Body/hip/spine/chest").transform;
this.part_chest_2.renderer.material = CharacterMaterials.Materials[this.myCostume.part_chest_1_object_texture];
}
if (this.myCostume.part_chest_skinned_cloth_mesh.Length > 0 && !this.IsDeadBody)
{
this.part_chest_3 = ClothFactory.GetCape(this.reference, "Character/" + this.myCostume.part_chest_skinned_cloth_mesh, CharacterMaterials.Materials[this.myCostume.part_chest_skinned_cloth_texture]);
}
if (this.myCostume.body_mesh.Length > 0)
{
this.part_upper_body = this.GenerateCloth(this.reference, "Character/" + this.myCostume.body_mesh);
this.part_upper_body.renderer.material = CharacterMaterials.Materials[this.myCostume.body_texture];
}
if (this.myCostume.brand1_mesh.Length > 0)
{
this.part_brand_1 = this.GenerateCloth(this.reference, "Character/" + this.myCostume.brand1_mesh);
this.part_brand_1.renderer.material = CharacterMaterials.Materials[this.myCostume.brand_texture];
}
if (this.myCostume.brand2_mesh.Length > 0)
{
this.part_brand_2 = this.GenerateCloth(this.reference, "Character/" + this.myCostume.brand2_mesh);
this.part_brand_2.renderer.material = CharacterMaterials.Materials[this.myCostume.brand_texture];
}
if (this.myCostume.brand3_mesh.Length > 0)
{
this.part_brand_3 = this.GenerateCloth(this.reference, "Character/" + this.myCostume.brand3_mesh);
this.part_brand_3.renderer.material = CharacterMaterials.Materials[this.myCostume.brand_texture];
}
if (this.myCostume.brand4_mesh.Length > 0)
{
this.part_brand_4 = this.GenerateCloth(this.reference, "Character/" + this.myCostume.brand4_mesh);
this.part_brand_4.renderer.material = CharacterMaterials.Materials[this.myCostume.brand_texture];
}
this.part_head.renderer.material = CharacterMaterials.Materials[this.myCostume.skin_texture];
this.part_chest.renderer.material = CharacterMaterials.Materials[this.myCostume.skin_texture];
}
19
Source : FengCustomInputs.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void showKeyMap()
{
for (int i = 0; i < this.DescriptionString.Length; i++)
{
if (GameObject.Find("CInput" + i))
{
GameObject.Find("CInput" + i).transform.Find("Label").gameObject.GetComponent<UILabel>().text = this.inputString[i];
}
}
if (GameObject.Find("ChangeQuality"))
{
GameObject.Find("ChangeQuality").GetComponent<UISlider>().sliderValue = PlayerPrefs.GetFloat("GameQuality");
}
if (GameObject.Find("MouseSensitivity"))
{
GameObject.Find("MouseSensitivity").GetComponent<UISlider>().sliderValue = PlayerPrefs.GetFloat("MouseSensitivity");
}
if (GameObject.Find("CheckboxSettings"))
{
GameObject.Find("CheckboxSettings").GetComponent<UICheckbox>().isChecked = (PlayerPrefs.GetInt("invertMouseY") != 1);
}
if (GameObject.Find("CheckboxCameraTilt"))
{
GameObject.Find("CheckboxCameraTilt").GetComponent<UICheckbox>().isChecked = (PlayerPrefs.GetInt("cameraTilt") == 1);
}
}
19
Source : IN_GAME_MAIN_CAMERA.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void update()
{
if (GameType == GameType.Stop)
{
Screen.showCursor = true;
Screen.lockCursor = false;
return;
}
if (this.flashDuration > 0f)
{
this.flashDuration -= Time.deltaTime;
if (this.flashDuration <= 0f)
{
this.flashDuration = 0f;
}
GameObject gameObject = CacheGameObject.Find("flash");
gameObject.GetComponent<UISprite>().alpha = this.flashDuration * 0.5f;
}
if (this.gameOver && GameType != GameType.Single)
{
if (InputManager.IsInputDown[InputCode.Attack1])
{
if (this.spectatorMode)
{
this.setSpectorMode(false);
}
else
{
this.setSpectorMode(true);
}
}
if (InputManager.IsInputDown[InputCode.Flare1])
{
this.currentPeekPlayerIndex++;
int num = FengGameManagerMKII.Heroes.Count;
if (this.currentPeekPlayerIndex >= num)
{
this.currentPeekPlayerIndex = 0;
}
if (num > 0)
{
this.SetMainObject(FengGameManagerMKII.Heroes[this.currentPeekPlayerIndex], true, false);
this.setSpectorMode(false);
this.lockAngle = false;
}
}
if (InputManager.IsInputDown[InputCode.Flare2])
{
this.currentPeekPlayerIndex--;
int num2 = FengGameManagerMKII.Heroes.Count;
if (this.currentPeekPlayerIndex >= num2)
{
this.currentPeekPlayerIndex = 0;
}
if (this.currentPeekPlayerIndex < 0)
{
this.currentPeekPlayerIndex = num2 - 1;
}
if (num2 > 0)
{
this.SetMainObject(FengGameManagerMKII.Heroes[this.currentPeekPlayerIndex], true, false);
this.setSpectorMode(false);
this.lockAngle = false;
}
}
if (InputManager.IsInputRebind((int)Anarchy.Inputs.InputRebinds.LiveSpectate))
{
if (mainObject != null)
{
liveSpecMode = !liveSpecMode;
}
}
if (this.spectatorMode)
{
return;
}
}
if (InputManager.IsInputDown[InputCode.Pause])
{
if (isPausing)
{
if (mainObject != null)
{
Vector3 a = BaseT.position;
a = ((!(Head != null)) ? MainT.position : Head.position);
a += Vectors.up * this.heightMulti;
BaseT.position = Vector3.Lerp(BaseT.position, a - BaseT.forward * 5f, 0.2f);
}
return;
}
isPausing = !isPausing;
if (isPausing)
{
if (GameType == GameType.Single)
{
Time.timeScale = 0f;
}
AnarchyManager.Pause.Enable();
InputManager.MenuOn = true;
Screen.showCursor = true;
Screen.lockCursor = false;
}
}
if (this.needSetHUD)
{
this.needSetHUD = false;
this.setHUDposition();
}
if (InputManager.IsInputDown[InputCode.FullScreen])
{
bool full = Screen.fullScreen;
if (full)
{
Screen.SetResolution(960, 600, false);
Anarchy.UI.Style.ScreenWidth = 960;
Anarchy.UI.Style.ScreenHeight = 600;
}
else
{
Screen.SetResolution((int)Anarchy.UI.Style.ScreenWidthDefault, (int)Anarchy.UI.Style.ScreenHeightDefault, true);
Anarchy.UI.Style.ResetScreenParameters();
}
Screen.fullScreen = !full;
this.needSetHUD = true;
Anarchy.UI.UIManager.UpdateGUIScaling();
Minimap.OnScreenResolutionChanged();
}
if (InputManager.IsInputDown[InputCode.Restart])
{
this.reset();
}
if (mainObject == null)
{
return;
}
if (InputManager.IsInputDown[InputCode.CameraChange])
{
if (CameraMode == CameraType.ORIGINAL)
{
CameraMode = CameraType.WOW;
Screen.lockCursor = false;
}
else if (CameraMode == CameraType.WOW)
{
CameraMode = CameraType.TPS;
Screen.lockCursor = true;
}
else if (CameraMode == CameraType.TPS)
{
CameraMode = CameraType.NewTPS;
Screen.lockCursor = CameraMode >= CameraType.TPS;
}
else if (CameraMode == CameraType.NewTPS)
{
CameraMode = CameraType.ORIGINAL;
Screen.lockCursor = false;
}
Settings.CameraMode.Value = (int)CameraMode;
PhotonNetwork.SetModProperties();
}
if (InputManager.IsInputDown[InputCode.HideCursor])
{
Screen.showCursor = !Screen.showCursor;
}
if (InputManager.IsInputDown[InputCode.Focus])
{
triggerAutoLock = !triggerAutoLock;
if (triggerAutoLock)
{
this.lockTarget = this.findNearestreplacedan();
if (this.closestDistance >= 150f)
{
this.lockTarget = null;
triggerAutoLock = false;
}
}
}
if (mainObject != null)
{
if (this.gameOver)
{
if (liveSpecMode && MainHERO.GetComponent<SmoothSyncMovement>().enabled && MainHERO.IsPhotonCamera)
{
CameraMovementLive(MainHERO);
}
else if (this.lockAngle)
{
BaseT.rotation = Quaternion.Lerp(BaseT.rotation, MainT.rotation, 0.2f);
BaseT.position = Vector3.Lerp(BaseT.position, MainT.position - MainT.forward * 5f, 0.2f);
}
else
{
this.CameraMovement();
}
}
else
{
this.CameraMovement();
}
if (triggerAutoLock && this.lockTarget != null)
{
float z = BaseT.eulerAngles.z;
Transform transform = this.lockTarget.transform.Find("Amarture/Core/Controller_Body/hip/spine/chest/neck");
Vector3 a2 = transform.position - ((!(Head != null)) ? MainT.position : Head.position);
a2.Normalize();
this.lockCameraPosition = ((!(Head != null)) ? MainT.position : Head.position);
this.lockCameraPosition -= a2 * this.distance * this.distanceMulti * this.distanceOffsetMulti;
this.lockCameraPosition += Vectors.up * 3f * this.heightMulti * this.distanceOffsetMulti;
BaseT.position = Vector3.Lerp(BaseT.position, this.lockCameraPosition, Time.deltaTime * 4f);
if (Head != null)
{
BaseT.LookAt(Head.position * 0.8f + transform.position * 0.2f);
}
else
{
BaseT.LookAt(MainT.position * 0.8f + transform.position * 0.2f);
}
BaseT.localEulerAngles = new Vector3(BaseT.eulerAngles.x, BaseT.eulerAngles.y, z);
Vector2 vector = BaseCamera.WorldToScreenPoint(transform.position - transform.Forward() * this.lockTarget.transform.localScale.x);
this.locker.transform.localPosition = new Vector3(vector.x - (float)Screen.width * 0.5f, vector.y - (float)Screen.height * 0.5f, 0f);
if (this.lockTarget.GetComponent<replacedAN>() && this.lockTarget.GetComponent<replacedAN>().hasDie)
{
this.lockTarget = null;
}
}
else
{
this.locker.transform.localPosition = new Vector3(0f, (float)(-(float)Screen.height) * 0.5f - 50f, 0f);
}
this.shakeUpdate();
}
Vector3 vector2 = (Head ?? MainT).position;
Vector3 normalized = ((Head ?? MainT).position - BaseT.position).normalized;
vector2 -= this.distance * normalized * this.distanceMulti;
RaycastHit raycastHit;
if (Head != null)
{
if (Physics.Linecast(Head.position, vector2, out raycastHit, Layers.Ground))
{
BaseT.position = raycastHit.point;
}
else if (Physics.Linecast(Head.position - normalized * this.distanceMulti * 3f, vector2, out raycastHit, Layers.EnemyBox))
{
BaseT.position = raycastHit.point;
}
}
else if (Physics.Linecast(MainT.position + Vectors.up, vector2, out raycastHit, Layers.EnemyGround))
{
BaseT.position = raycastHit.point;
}
}
19
Source : Xffect.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void Initialize()
{
if (this.EflList.Count > 0)
{
return;
}
foreach (object obj in base.transform)
{
Transform transform = (Transform)obj;
EffectLayer effectLayer = (EffectLayer)transform.GetComponent(typeof(EffectLayer));
if (!(effectLayer == null) && !(effectLayer.Material == null))
{
Material material = effectLayer.Material;
this.EflList.Add(effectLayer);
Transform transform2 = base.transform.Find("mesh " + material.name);
if (transform2 != null)
{
MeshFilter meshFilter = (MeshFilter)transform2.GetComponent(typeof(MeshFilter));
MeshRenderer meshRenderer = (MeshRenderer)transform2.GetComponent(typeof(MeshRenderer));
meshFilter.mesh.Clear();
this.MatDic[material.name] = new VertexPool(meshFilter.mesh, material);
}
if (!this.MatDic.ContainsKey(material.name))
{
GameObject gameObject = new GameObject("mesh " + material.name);
gameObject.transform.parent = base.transform;
gameObject.AddComponent("MeshFilter");
gameObject.AddComponent("MeshRenderer");
MeshFilter meshFilter = (MeshFilter)gameObject.GetComponent(typeof(MeshFilter));
MeshRenderer meshRenderer = (MeshRenderer)gameObject.GetComponent(typeof(MeshRenderer));
meshRenderer.castShadows = false;
meshRenderer.receiveShadows = false;
meshRenderer.renderer.material = material;
this.MatDic[material.name] = new VertexPool(meshFilter.mesh, material);
}
}
}
foreach (EffectLayer effectLayer2 in this.EflList)
{
effectLayer2.Vertexpool = this.MatDic[effectLayer2.Material.name];
}
}
19
Source : XffectCache.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
protected Transform AddObject(string name)
{
Transform transform = base.transform.Find(name);
if (transform == null)
{
Debug.Log("object:" + name + "doesn't exist!");
return null;
}
Transform transform2 = UnityEngine.Object.Instantiate(transform, Vectors.zero, Quaternion.idenreplacedy) as Transform;
this.ObjectDic[name].Add(transform2);
transform2.gameObject.SetActive(false);
Xffect component = transform2.GetComponent<Xffect>();
if (component != null)
{
component.Initialize();
}
return transform2;
}
19
Source : Cannon.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void Awake()
{
bool flag = BasePV != null;
if (flag)
{
BasePV.observed = this;
this.barrel = base.transform.Find("Barrel");
this.correctPlayerPos = base.transform.position;
this.correctPlayerRot = base.transform.rotation;
this.correctBarrelRot = this.barrel.rotation;
bool isMine = BasePV.IsMine;
if (isMine)
{
this.firingPoint = this.barrel.Find("FiringPoint");
this.ballPoint = this.barrel.Find("BallPoint");
this.myCannonLine = this.ballPoint.GetComponent<LineRenderer>();
bool flag2 = base.gameObject.name.Contains("CannonGround");
if (flag2)
{
this.isCannonGround = true;
}
}
bool isMasterClient = PhotonNetwork.IsMasterClient;
if (isMasterClient)
{
PhotonPlayer owner = BasePV.owner;
bool flag3 = RCManager.allowedToCannon.ContainsKey(owner.ID);
if (flag3)
{
this.settings = RCManager.allowedToCannon[owner.ID].settings;
BasePV.RPC("SetSize", PhotonTargets.All, new object[]
{
this.settings
});
int viewID = RCManager.allowedToCannon[owner.ID].viewID;
RCManager.allowedToCannon.Remove(owner.ID);
CannonPropRegion component = PhotonView.Find(viewID).gameObject.GetComponent<CannonPropRegion>();
bool flag4 = component != null;
if (flag4)
{
component.disabled = true;
component.destroyed = true;
PhotonNetwork.Destroy(component.gameObject);
}
}
else
{
bool flag5 = !owner.IsLocal;// && !FengGameManagerMKII.instance.restartingMC;
if (flag5)
{
//TO DO
//FengGameManagerMKII.instance.kickPlayerRC(owner, false, "spawning cannon without request.");
}
}
}
}
}
19
Source : UI.cs
with GNU General Public License v3.0
from AndrasMumm
with GNU General Public License v3.0
from AndrasMumm
public static void Postfix(ref UIMain __instance)
{
RectTransform dynamicCanvas = (RectTransform)__instance.transform.Find("DynamicCanvas");
RectTransform menu = (RectTransform)dynamicCanvas.transform.Find("Menu");
//Updating the Credits Button Text
RectTransform btnMember = (RectTransform)menu.Find("BtnMember");
RectTransform btn = (RectTransform)btnMember.Find("Btn");
RectTransform btn_text = (RectTransform)btn.Find("Text");
UnityEngine.UI.Text btn_text_text = (UnityEngine.UI.Text)btn_text.gameObject.GetComponentInChildren(typeof(UnityEngine.UI.Text));
btn_text_text.text = "Credits";
/*
Reducing Menu Button Font Size
menu.Find("BtnContinue").Find("Btn").Find("Text").GetComponent<Text>().fontSize = 20;
menu.Find("BtnNewGame").Find("Btn").Find("Text").GetComponent<Text>().fontSize = 23;
menu.Find("BtnLoadGame").Find("Btn").Find("Text").GetComponent<Text>().fontSize = 23;
menu.Find("BtnSystem").Find("Btn").Find("Text").GetComponent<Text>().fontSize = 16;
menu.Find("BtnQuitGame").Find("Btn").Find("Text").GetComponent<Text>().fontSize = 23;
*/
//Focing the UI to update itself after all the changes we made. We just force every RectTransform to update itself
for (int i = 0; i < __instance.transform.childCount; ++i)
{
Transform t = __instance.transform.GetChild(i);
if (t != null && t.GetType() == typeof(RectTransform))
{
RectTransform rt = t as RectTransform;
rt.ForceUpdateRectTransforms();
}
}
}
19
Source : FsmManager.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
public static bool IsGTGrilleInstalled()
{
if (gtGrilleInstalled == null)
gtGrilleInstalled = GameObject.Find("Database").transform.Find("DatabaseOrders/GrilleGT").gameObject.GetComponent<PlayMakerFSM>().FsmVariables.GetFsmBool("Installed");
return gtGrilleInstalled.Value == true;
}
19
Source : ItemBehaviour.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
void ToggleActive(bool enabled)
{
try
{
// If the item has fallen under the detection range of the game's built in garbage collector,
// teleport that item manually to the landfill.
if (!firstLoad)
{
if (transform.position.y < -100 && transform.position.x != 0 && transform.position.z != 0)
transform.position = ItemsManager.Instance.LostSpawner.position;
firstLoad = true;
}
if (!Hypervisor.Instance.IsItemInitializationDone())
{
if (transform.root != Satsuma.Instance.transform || IsPartMagnetAttached())
transform.position = position;
}
if (DontDisable)
{
TogglePhysicsOnly(enabled);
return;
}
// Disable empty items function.
// Items that are marked as empty are disabled by the game.
if (MOP.DisableEmptyItems.Value && this.gameObject.name == "empty(itemx)" && this.gameObject.transform.parent == null)
{
enabled = !MopSettings.IsModActive;
}
// Don't execute rest of the code, if the enabled is the same as activeSelf.
if (gameObject.activeSelf == enabled)
{
return;
}
// Don't toggle, if the item is attached to Satsuma.
if (transform.root.gameObject.name == "SATSUMA(557kg, 248)" || IsPartMagnetAttached())
{
return;
}
switch (gameObject.name)
{
// Don't disable wheels that are attached to the car.
case "wheel_regula":
Transform root = this.gameObject.transform.parent;
if (root != null && root.gameObject.name == "pivot_wheel_standard")
return;
break;
// Fix for batteries popping out of the car.
case "battery(Clone)":
if (gameObject.transform.parent.gameObject.name == "pivot_battery")
return;
// Don't toggle if battery is left on charger.
if (!enabled && batteryOnCharged.Value)
return;
break;
// Don't disable the helmet, if player has put it on.
case "helmet(itemx)":
if (Vector3.Distance(gameObject.transform.position, Hypervisor.Instance.GetPlayer().position) < 5)
return;
break;
// Don't despawn floor or car jack if it's not in it's default position.
case "floor jack(itemx)":
if (floorJackTriggerY.Value >= 0.15f)
return;
break;
case "car jack(itemx)":
if (floorJackTriggerY.Value >= 0.15f)
return;
break;
// Fixes infinitely burnign garbage barrel fire.
case "garbage barrel(itemx)":
if (!enabled)
transform.Find("Fire").gameObject.SetActive(false);
break;
// Fixes unpickable empty plastic cans
case "emptyca":
if (Vector3.Distance(transform.position, ItemsManager.Instance.LandfillSpawn.position) < 5)
{
gameObject.name = "empty plastic can(itemx)";
gameObject.MakePickable(true);
}
break;
}
// CDs resetting fix.
if (this.gameObject.name.StartsWith("cd(item") && this.transform.parent != null && this.transform.parent.name == "cd_sled_pivot")
{
return;
}
// Check if item is in CarryMore inventory.
// If so, ignore that item.
if (CompatibilityManager.IsInBackpack(this))
{
return;
}
gameObject.SetActive(enabled);
}
catch { }
}
19
Source : ItemBehaviour.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
void FsmFixes()
{
try
{
PlayMakerFSM useFsm = gameObject.GetPlayMakerFSM("Use");
if (useFsm != null)
{
useFsm.Fsm.RestartOnEnable = false;
if (gameObject.name.StartsWith("door ")) return;
if (gameObject.name == ("amis-auto ky package(xxxxx)")) return;
if (gameObject.name == "lottery ticket(xxxxx)") return;
FsmState state1 = useFsm.GetState("State 1");
if (state1 != null)
{
List<FsmStateAction> emptyState1 = state1.Actions.ToList();
emptyState1.Insert(0, new CustomStop());
state1.Actions = emptyState1.ToArray();
state1.SaveActions();
}
FsmState loadState = useFsm.GetState("Load");
if (loadState != null)
{
List<FsmStateAction> emptyActions = loadState.Actions.ToList();
emptyActions.Insert(0, new CustomStop());
loadState.Actions = emptyActions.ToArray();
loadState.SaveActions();
}
if (this.gameObject.name == "battery(Clone)")
{
batteryOnCharged = useFsm.FsmVariables.GetFsmBool("OnCharged");
}
if (useFsm.FsmVariables.GetFsmFloat("SpoilingRate") != null)
{
spoilRate = useFsm.FsmVariables.GetFsmFloat("SpoilingRate");
condition = useFsm.FsmVariables.GetFsmFloat("Condition");
}
if (useFsm.FsmVariables.GetFsmFloat("SpoilingRateFridge") != null)
{
spoilRateFridge = useFsm.FsmVariables.GetFsmFloat("SpoilingRateFridge");
}
}
// Fixes for particular items.
switch (gameObject.name)
{
case "diesel(itemx)":
transform.Find("FluidTrigger").gameObject.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
break;
case "gasoline(itemx)":
transform.Find("FluidTrigger").gameObject.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
break;
case "motor oil(itemx)":
transform.Find("MotorOilTrigger").gameObject.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
break;
case "coolant(itemx)":
transform.Find("CoolantTrigger").gameObject.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
break;
case "brake fluid(itemx)":
transform.Find("BrakeFluidTrigger").gameObject.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
break;
case "wood carrier(itemx)":
transform.Find("WoodTrigger").gameObject.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
break;
case "suitcase(itemx)":
transform.Find("Money").gameObject.AddComponent<SuitcaseMoneyBehaviour>();
break;
case "radio(Clone)":
if (transform.Find("Channel") != null)
transform.Find("Channel").gameObject.AddComponent<RadioDisable>();
break;
case "fuel tank(Clone)":
transform.Find("Bolts").GetChild(7).GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
break;
case "spark plug(Clone)":
gameObject.GetPlayMakerFSM("Screw").Fsm.RestartOnEnable = false;
break;
case "spark plug box(Clone)":
break;
}
PlayMakerFSM dataFsm = gameObject.GetPlayMakerFSM("Data");
if (dataFsm != null)
{
dataFsm.Fsm.RestartOnEnable = false;
}
PlayMakerFSM paintFSM = gameObject.GetPlayMakerFSM("Paint");
if (paintFSM != null)
{
paintFSM.Fsm.RestartOnEnable = false;
}
}
catch (System.Exception ex)
{
ExceptionManager.New(ex, false, $"FSM_FIXES | {gameObject.Path()}");
}
}
19
Source : ItemsManager.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
internal void Initialize()
{
cashRegisterHook = GameObject.Find("STORE/StoreCashRegister/Register").AddComponent<CashRegisterBehaviour>();
Transform spawner = GameObject.Find("Spawner").transform;
InjectSpawnScripts(spawner.Find("CreateItems").gameObject);
InjectSpawnScripts(spawner.Find("CreateSpraycans").gameObject);
InjectSpawnScripts(spawner.Find("CreateShoppingbag").gameObject);
InjectSpawnScripts(spawner.Find("CreateMooseMeat").gameObject);
InjectSpawnScripts(GameObject.Find("fish trap(itemx)").transform.Find("Spawn").gameObject);
GetCanTrigger();
// Car parts order bill hook.
try
{
GameObject storeLOD = GameObject.Find("STORE").transform.Find("LOD").gameObject;
GameObject activateStore = storeLOD.transform.Find("ActivateStore").gameObject;
bool lodLastState = storeLOD.activeSelf;
bool activeStore = activateStore.activeSelf;
if (!lodLastState)
storeLOD.SetActive(true);
if (!activeStore)
activateStore.SetActive(true);
GameObject postOrder = GameObject.Find("STORE").transform.Find("LOD/ActivateStore/PostOffice/PostOrderBuy").gameObject;
bool isPostOrderActive = postOrder.activeSelf;
postOrder.SetActive(true);
FsmHook.FsmInject(postOrder, "State 3", cashRegisterHook.Packages);
if (!isPostOrderActive)
postOrder.SetActive(false);
storeLOD.SetActive(lodLastState);
activateStore.SetActive(activateStore);
}
catch
{
throw new System.Exception("Couldn't inject PostOrderBuy object.");
}
InitializeList();
// Hooks all bottles and adds adds BeerBottle script to them, which deletes the object and adds the ItemHook to them.
Dictionary<string, string> names = new Dictionary<string, string>()
{
{
"BottleBeerFly",
"empty bottle(Clone)"
},
{
"BottleBoozeFly",
"empty bottle(Clone)"
},
{
"BottleSpiritFly",
"empty bottle(Clone)"
},
{
"CoffeeFly",
"empty cup(Clone)"
},
{
"MilkFly",
"empty pack(Clone)"
},
{
"VodkaShotFly",
"empty glreplaced(Clone)"
}
};
foreach (GameObject gameObject in Resources.FindObjectsOfTypeAll<GameObject>().Where(obj => names.ContainsKey(obj.name) && obj.GetComponent<PlayMakerFSM>() != null))
{
gameObject.AddComponent<ThrowableJunkBehaviour>();
}
// Hook the prefab of firewood.
GameObject firewoodPrefab = Resources.FindObjectsOfTypeAll<GameObject>().FirstOrDefault(f => f.name.EqualsAny("firewood") && f.GetComponent<PlayMakerFSM>() == null).gameObject;
if (firewoodPrefab)
{
firewoodPrefab.AddComponent<ItemBehaviour>();
}
// Hook the prefab of log.
GameObject logPrefab = Resources.FindObjectsOfTypeAll<GameObject>().FirstOrDefault(f => f.name.EqualsAny("log") && f.GetComponent<PlayMakerFSM>() == null).gameObject;
if (logPrefab)
{
logPrefab.AddComponent<ItemBehaviour>();
logPrefab.transform.Find("log(Clone)").gameObject.AddComponent<ItemBehaviour>();
}
foreach (var f in Resources.FindObjectsOfTypeAll<GameObject>().Where(g => g.name == "log(Clone)"))
{
f.AddComponent<ItemBehaviour>();
}
radiatorHose3Database = GameObject.Find("Database/DatabaseMechanics/RadiatorHose3").GetPlayMakerFSM("Data");
GameObject attachedHose = Resources.FindObjectsOfTypeAll<GameObject>().First(g => g.name == "radiator hose3(xxxxx)");
realRadiatorHose = Resources.FindObjectsOfTypeAll<GameObject>().First(g => g.name == "radiator hose3(Clone)");
GameObject dummy = GameObject.Instantiate(realRadiatorHose); // used for spawning the radiator hose3 after it gets detached.
UnityEngine.Object.Destroy(dummy.GetComponent<ItemBehaviour>());
dummy.SetActive(false);
dummy.name = dummy.name.Replace("(Clone)(Clone)", "(Clone)");
Transform t = SaveManager.GetRadiatorHose3Transform();
if (!attachedHose.activeSelf)
{
realRadiatorHose.transform.position = t.position;
realRadiatorHose.transform.rotation = t.rotation;
realRadiatorHose.SetActive(true);
}
radiatorHose3Database.FsmVariables.GameObjectVariables.First(g => g.Name == "SpawnThis").Value = realRadiatorHose;
}
19
Source : GameFixes.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
public void MainFixes()
{
// GT Grille resetting fix.
try
{
PlayMakerFSM[] gtGrille = GameObject.Find("grille gt(Clone)").GetComponents<PlayMakerFSM>();
foreach (var fsm in gtGrille)
fsm.Fsm.RestartOnEnable = false;
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "GT_GRILLE_ERROR");
}
// Random fixes.
try
{
Transform buildings = GameObject.Find("Buildings").transform;
// Find house of Teimo and detach it from Perajarvi, so it can be loaded and unloaded separately
GameObject perajarvi = GameObject.Find("PERAJARVI");
perajarvi.transform.Find("HouseRintama4").parent = buildings;
// Same for chicken house.
perajarvi.transform.Find("ChickenHouse").parent = buildings;
// Chicken house (barn) close to player's house
buildings.Find("ChickenHouse").parent = null;
// Fix for church wall. Changing it's parent to NULL, so it will not be loaded or unloaded.
// It used to be attached to CHURCH gameobject,
// but the Amis cars (yellow and grey cars) used to end up in the graveyard area.
GameObject.Find("CHURCHWALL").transform.parent = null;
// Fix for old house on the way from Perajarvi to Ventti's house (HouseOld5)
perajarvi.transform.Find("HouseOld5").parent = buildings;
// Fix for houses behind Teimo's
perajarvi.transform.Find("HouseRintama3").parent = buildings;
perajarvi.transform.Find("HouseSmall3").parent = buildings;
// Perajarvi fixes for multiple objects with the same name.
// Instead of being the part of Perajarvi, we're changing it to be the part of Buildings.
Transform[] perajarviChilds = perajarvi.GetComponentsInChildren<Transform>();
for (int i = 0; i < perajarviChilds.Length; i++)
{
// Fix for disappearing grain processing plant
// https://my-summer-car.fandom.com/wiki/Grain_processing_plant
if (perajarviChilds[i].gameObject.name.Contains("silo"))
{
perajarviChilds[i].parent = buildings;
continue;
}
// Fix for Ventti's and Teimo's mailboxes (and pretty much all mailboxes that are inside of Perajarvi)
if (perajarviChilds[i].gameObject.name == "MailBox")
{
perajarviChilds[i].parent = buildings;
continue;
}
// Fix for greenhouses on the road from Perajarvi to Ventti's house
if (perajarviChilds[i].name == "Greenhouse")
{
perajarviChilds[i].parent = buildings;
continue;
}
}
// Fix for floppies at Jokke's new house
while (perajarvi.transform.Find("TerraceHouse/diskette(itemx)") != null)
{
Transform diskette = perajarvi.transform.Find("TerraceHouse/diskette(itemx)");
if (diskette != null && diskette.parent != null)
diskette.parent = null;
}
// Fix for Jokke's house furnitures clipping through floor
perajarvi.transform.Find("TerraceHouse/Colliders").parent = null;
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "PERAJARVI_FIXES_ERROR");
}
// Fix for cottage items disappearing when moved
try
{
GameObject.Find("coffee pan(itemx)").transform.parent = null;
GameObject.Find("lantern(itemx)").transform.parent = null;
GameObject.Find("coffee cup(itemx)").transform.parent = null;
GameObject.Find("camera(itemx)").transform.parent = null;
GameObject.Find("COTTAGE/ax(itemx)").transform.parent = null;
GameObject.Find("fireworks bag(itemx)").transform.parent = null;
// Fix for fishing areas
GameObject.Find("FishAreaAVERAGE").transform.parent = null;
GameObject.Find("FishAreaBAD").transform.parent = null;
GameObject.Find("FishAreaGOOD").transform.parent = null;
GameObject.Find("FishAreaGOOD2").transform.parent = null;
// Fix for strawberry field mailboxes
GameObject.Find("StrawberryField").transform.Find("LOD/MailBox").parent = null;
GameObject.Find("StrawberryField").transform.Find("LOD/MailBox").parent = null;
// Fix for items left on cottage chimney clipping through it on first load of cottage
GameObject.Find("COTTAGE").transform.Find("MESH/Cottage_chimney").parent = null;
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "ITEMS_FIXES_ERROR");
}
// Applying a script to vehicles that can pick up and drive the player as a preplacedanger to his house.
// This script makes it so when the player enters the car, the parent of the vehicle is set to null.
try
{
GameObject fittan = GameObject.Find("TRAFFIC").transform.Find("VehiclesDirtRoad/Rally/FITTAN").gameObject;
GameObject kuski = GameObject.Find("NPC_CARS").transform.Find("KUSKI").gameObject;
FsmHook.FsmInject(fittan.transform.Find("PlayerTrigger/DriveTrigger").gameObject, "Player in car", () => fittan.transform.parent = null);
FsmHook.FsmInject(kuski.transform.Find("PlayerTrigger/DriveTrigger").gameObject, "Player in car", () => kuski.transform.parent = null);
}
catch (Exception ex)
{
ExceptionManager.New(ex, true, "TAXI_MANAGERS_ERROR");
}
// Fixed Ventii bet resetting to default on cabin load.
try
{
GameObject.Find("CABIN").transform.Find("Cabin/Ventti/Table/GameManager").GetPlayMakerFSM("Use").Fsm.RestartOnEnable = false;
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "VENTII_FIX_ERROR");
}
// Junk cars - setting Load game to null.
int junkCarCounter = 1;
try
{
for (junkCarCounter = 1; GameObject.Find($"JunkCar{junkCarCounter}") != null; junkCarCounter++)
{
GameObject junk = GameObject.Find($"JunkCar{junkCarCounter}");
junk.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
WorldObjectManager.Instance.Add(junk, DisableOn.Distance);
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, $"JUNK_CARS_{junkCarCounter}_ERROR");;
}
// Toggle Humans (apart from Farmer and Fighter2).
try
{
GameObject humans = GameObject.Find("HUMANS");
foreach (Transform t in GameObject.Find("HUMANS").GetComponentsInChildren<Transform>().Where(t => t.parent == humans.transform))
{
if (t.gameObject.name.EqualsAny("HUMANS", "Fighter2", "Farmer", "FighterPub"))
continue;
WorldObjectManager.Instance.Add(t.gameObject, DisableOn.Distance);
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "HUMANS_ERROR");
}
// Fixes wasp hives resetting to on load values.
try
{
GameObject[] wasphives = Resources.FindObjectsOfTypeAll<GameObject>().Where(g => g.name == "WaspHive").ToArray();
foreach (GameObject wasphive in wasphives)
{
wasphive.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "WASPHIVES_ERROR");
}
// Disabling the script that sets the kinematic state of Satsuma to False.
try
{
GameObject hand = GameObject.Find("PLAYER/Pivot/AnimPivot/Camera/FPSCamera/1Hand_replacedemble/Hand");
PlayMakerFSM pickUp = hand.GetPlayMakerFSM("PickUp");
pickUp.GetState("Drop part").RemoveAction(0);
pickUp.GetState("Drop part 2").RemoveAction(0);
pickUp.GetState("Tool picked").RemoveAction(2);
pickUp.GetState("Drop tool").RemoveAction(0);
}
catch (Exception ex)
{
ExceptionManager.New(ex, true, "SATSUMA_HAND_BS_FIX");
}
// Preventing mattres from being disabled.
try
{
Transform mattres = GameObject.Find("DINGONBIISI").transform.Find("mattres");
if (mattres != null)
mattres.parent = null;
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "MANSION_MATTRES_ERROR");
}
// Item anti clip for cottage.
try
{
GameObject area = new GameObject("MOP_ItemAntiClip");
area.transform.position = new Vector3(-848.3f, -5.4f, 505.5f);
area.transform.eulerAngles = new Vector3(0, 343.0013f, 0);
area.AddComponent<ItemAntiClip>();
}
catch (Exception ex)
{
ExceptionManager.New(ex, true, "ITEM_ANTICLIP_ERROR");
}
// Z-fighting fix for wrisreplacedch.
try
{
GameObject player = GameObject.Find("PLAYER");
if (player)
{
Transform hour = player.transform.Find("Pivot/AnimPivot/Camera/FPSCamera/FPSCamera/Watch/Animate/BreathAnim/WrisreplacedchHand/Clock/Pivot/Hour/hour");
if (hour)
{
hour.GetComponent<Renderer>().material.renderQueue = 3001;
}
Transform minute = player.transform.Find("Pivot/AnimPivot/Camera/FPSCamera/FPSCamera/Watch/Animate/BreathAnim/WrisreplacedchHand/Clock/Pivot/Minute/minute");
if (minute)
{
minute.GetComponent<Renderer>().material.renderQueue = 3002;
}
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "HANDWATCH_RENDERER_QUEUE_ERROR");
}
// Adds roll fix to the bus.
try
{
GameObject bus = GameObject.Find("BUS");
if (bus)
{
bus.AddComponent<BusRollFix>();
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "BUS_ROLL_FIX_ERROR");
}
// Fixes bedroom window wrap resetting to default value.
try
{
Transform triggerWindowWrap = GameObject.Find("YARD").transform.Find("Building/BEDROOM1/trigger_window_wrap");
if (triggerWindowWrap != null)
triggerWindowWrap.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "TRIGGER_WINDOW_WRAP_ERROR");
}
// Fixes diskette ejecting not wokring.
try
{
Resources.FindObjectsOfTypeAll<GameObject>().First(g => g.name == "TriggerDiskette")
.GetPlayMakerFSM("replacedembly").Fsm.RestartOnEnable = false;
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "TRIGGER_DISKETTE_ERROR");
}
// Fixed computer memory resetting.
try
{
Resources.FindObjectsOfTypeAll<GameObject>().First(g => g.name == "TriggerPlayMode").GetPlayMakerFSM("PlayerTrigger").Fsm.RestartOnEnable = false;
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "TRIGGER_DISKETTE_ERROR");
}
// Fixes berry picking skill resetting to default.
try
{
GameObject.Find("JOBS").transform.Find("StrawberryField").gameObject.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "STRAWBERRY_FIELD_FSM");
}
// GrandmaHiker fixes.
try
{
GameObject grandmaHiker = GameObject.Find("GrannyHiker");
if (grandmaHiker)
{
GameObject skeleton = grandmaHiker.transform.Find("Char/skeleton").gameObject;
PlayMakerFSM logicFSM = grandmaHiker.GetPlayMakerFSM("Logic");
FsmState openDoorFsmState = logicFSM.GetState("Open door");
List<FsmStateAction> openDoorActions = openDoorFsmState.Actions.ToList();
openDoorActions.Add(new GrandmaHiker(skeleton, false));
openDoorFsmState.Actions = openDoorActions.ToArray();
FsmState setMreplaced2State = logicFSM.GetState("Set mreplaced 2");
List<FsmStateAction> setMreplaced2Actions = setMreplaced2State.Actions.ToList();
setMreplaced2Actions.Add(new GrandmaHiker(skeleton, true));
setMreplaced2State.Actions = setMreplaced2Actions.ToArray();
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "GRANDMA_HIKER_FIXES");
}
// Cabin door resetting fix.
try
{
GameObject.Find("CABIN").transform.Find("Cabin/Door/Pivot/Handle").gameObject.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "CABIN_DOOR_RESET_FIX_ERROR");
}
// Construction site
try
{
Transform construction = GameObject.Find("PERAJARVI").transform.Find("ConstructionSite");
if (construction)
{
construction.parent = null;
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "PERAJARVI_CONSTRUCTION_ERROR");
}
// Satsuma parts trigger fix.
try
{
gameObject.AddComponent<SatsumaTriggerFixer>();
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "SATSUMA_TRIGGER_FIXER_ERROR");
}
// MailBox fix
try
{
foreach (var g in Resources.FindObjectsOfTypeAll<GameObject>().Where(g => g.name == "MailBox"))
{
Transform hatch = g.transform.Find("BoxHatch");
if (hatch)
{
hatch.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
}
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "MAILBOX_ERROR");
}
ModConsole.Log("[MOP] Finished applying fixes");
}
19
Source : Hypervisor.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
void Initialize()
{
instance = this;
ModConsole.Log("[MOP] Loading MOP...");
// Initialize the worldObjectManager list
worldObjectManager = new WorldObjectManager();
// Looking for player and yard
player = GameObject.Find("PLAYER").transform;
// Add GameFixes MonoBehaviour.
try
{
gameObject.AddComponent<GameFixes>();
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, $"GAME_FIXES_INITIALIZAITON | {ex}");
}
// Loading vehicles
vehicleManager = new VehicleManager();
// World Objects
try
{
worldObjectManager.Add("CABIN", DisableOn.Distance | DisableOn.IgnoreInQualityMode);
worldObjectManager.Add("COTTAGE", DisableOn.Distance, 400);
worldObjectManager.Add("DANCEHALL", DisableOn.Distance, 500);
worldObjectManager.Add("PERAJARVI", DisableOn.Distance | DisableOn.IgnoreInQualityMode, 400);
worldObjectManager.Add("SOCCER", DisableOn.Distance);
worldObjectManager.Add("WATERFACILITY", DisableOn.Distance, 300);
worldObjectManager.Add("DRAGRACE", DisableOn.Distance, 1100);
worldObjectManager.Add("StrawberryField", DisableOn.Distance, 400);
worldObjectManager.Add("MAP/Buildings/DINGONBIISI", DisableOn.Distance, 400);
worldObjectManager.Add("RALLY/PartsSalesman", DisableOn.Distance, 400);
worldObjectManager.Add("LakeSmallBottom1", DisableOn.Distance, 500);
worldObjectManager.Add("machine", DisableOn.Distance, 200, silent: true);
ModConsole.Log("[MOP] World objects (1) loaded");
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "WORLD_OBJECTS_1_INITIALIZAITON_FAIL");
}
// Initialize places.
placeManager = new PlaceManager();
// Fixes
GameFixes.Instance.MainFixes();
//Things that should be enabled when out of proximity of the house
try
{
worldObjectManager.Add("NPC_CARS", DisableOn.PlayerInHome);
worldObjectManager.Add("TRAFFIC", DisableOn.PlayerInHome);
worldObjectManager.Add("TRAIN", DisableOn.PlayerInHome | DisableOn.IgnoreInQualityMode);
worldObjectManager.Add("Buildings", DisableOn.PlayerInHome);
worldObjectManager.Add("TrafficSigns", DisableOn.PlayerInHome);
worldObjectManager.Add("StreetLights", DisableOn.PlayerInHome);
worldObjectManager.Add("HUMANS", DisableOn.PlayerInHome);
worldObjectManager.Add("TRACKFIELD", DisableOn.PlayerInHome);
worldObjectManager.Add("SkijumpHill", DisableOn.PlayerInHome | DisableOn.IgnoreInQualityMode);
worldObjectManager.Add("Factory", DisableOn.PlayerInHome);
worldObjectManager.Add("WHEAT", DisableOn.PlayerInHome);
worldObjectManager.Add("RAILROAD", DisableOn.PlayerInHome);
worldObjectManager.Add("AIRPORT", DisableOn.PlayerInHome);
worldObjectManager.Add("RAILROAD_TUNNEL", DisableOn.PlayerInHome);
worldObjectManager.Add("PierDancehall", DisableOn.PlayerInHome);
worldObjectManager.Add("PierRiver", DisableOn.PlayerInHome);
worldObjectManager.Add("PierStore", DisableOn.PlayerInHome);
worldObjectManager.Add("BRIDGE_dirt", DisableOn.PlayerInHome);
worldObjectManager.Add("BRIDGE_highway", DisableOn.PlayerInHome);
worldObjectManager.Add("BirdTower", DisableOn.Distance, 400);
worldObjectManager.Add("RYKIPOHJA", DisableOn.PlayerInHome);
worldObjectManager.Add("COMPUTER", DisableOn.PlayerAwayFromHome);
ModConsole.Log("[MOP] World objects (2) loaded");
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "WORLD_OBJECTS_2_INITIALIZAITON_FAIL");
}
// Adding area check if Satsuma is in the inspection's area
try
{
SatsumaInArea inspectionArea = GameObject.Find("INSPECTION").AddComponent<SatsumaInArea>();
inspectionArea.Initialize(new Vector3(20, 20, 20));
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "SATSUMA_AREA_CHECK_INSPECTION_FAIL");
}
// Check for when Satsuma is on the lifter
try
{
SatsumaInArea lifterArea = GameObject.Find("REPAIRSHOP/Lifter/Platform").AddComponent<SatsumaInArea>();
lifterArea.Initialize(new Vector3(5, 5, 5));
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "SATSUMA_AREA_CHECK_REPAIRSHOP_FAIL");
}
// Area for the parc ferme.
try
{
GameObject parcFermeTrigger = new GameObject("MOP_ParcFermeTrigger");
parcFermeTrigger.transform.parent = GameObject.Find("RALLY").transform.Find("Scenery");
parcFermeTrigger.transform.position = new Vector3(-1383f, 3f, 1260f);
SatsumaInArea parcFerme = parcFermeTrigger.AddComponent<SatsumaInArea>();
parcFerme.Initialize(new Vector3(41, 12, 35));
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "PARC_FERME_TRIGGER_FAIL");
}
ModConsole.Log("[MOP] Satsuma triggers loaded");
// Jokke's furnitures.
// Only renderers are going to be toggled.
try
{
if (GameObject.Find("tv(Clo01)"))
{
string[] furnitures = { "tv(Clo01)", "chair(Clo02)", "chair(Clo05)", "bench(Clo01)",
"bench(Clo02)", "table(Clo02)", "table(Clo03)", "table(Clo04)",
"table(Clo05)", "desk(Clo01)", "arm chair(Clo01)" };
foreach (string furniture in furnitures)
{
GameObject g = GameObject.Find(furniture);
if (g)
{
g.transform.parent = null;
worldObjectManager.Add(g, DisableOn.Distance, 100, ToggleModes.Renderer);
}
}
ModConsole.Log("[MOP] Jokke's furnitures found and loaded");
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "JOKKE_FURNITURE_ERROR");
}
// Haybales.
// First we null out the prevent it from reloading the position of haybales.
try
{
GameObject haybalesParent = GameObject.Find("JOBS/HayBales");
if (haybalesParent != null)
{
haybalesParent.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
// And now we add all child haybale to world objects.
foreach (Transform haybale in haybalesParent.transform.GetComponentInChildren<Transform>())
{
worldObjectManager.Add(haybale.gameObject.name, DisableOn.Distance | DisableOn.IgnoreInQualityMode, 120);
}
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "HAYBALES_FIX_ERROR");
}
// Logwalls
try
{
foreach (GameObject wall in Resources.FindObjectsOfTypeAll<GameObject>().Where(g => g.name == "LogwallLarge"))
worldObjectManager.Add(wall, DisableOn.Distance, 300);
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "LOGWALL_LOAD_ERROR");
}
// Perajarvi Church.
try
{
if (MopSettings.Mode != PerformanceMode.Performance)
{
GameObject church = GameObject.Find("PERAJARVI").transform.Find("CHURCH").gameObject;
church.transform.parent = null;
GameObject churchLOD = church.transform.Find("LOD").gameObject;
church.GetComponent<PlayMakerFSM>().enabled = false;
worldObjectManager.Add(churchLOD, DisableOn.Distance, 300);
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "CHURCH_LOD_ERROR");
}
// Lake houses.
try
{
if (MopSettings.Mode == PerformanceMode.Quality)
{
GameObject.Find("PERAJARVI").transform.Find("TerraceHouse").transform.parent = null;
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "LAKE_HOUSE_ERROR");
}
// VehiclesHighway renderers.
try
{
Transform vehiclesHighway = GameObject.Find("TRAFFIC").transform.Find("VehiclesHighway");
foreach (var f in vehiclesHighway.GetComponentsInChildren<Transform>(true).Where(f => f.parent == vehiclesHighway))
{
worldObjectManager.Add(f.gameObject, DisableOn.Distance, 600, ToggleModes.MultipleRenderers);
}
// Also we gonna fix the lag on initial traffic load.
vehiclesHighway.gameObject.SetActive(true);
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "TRAFFIC_VEHICLES_ERROR");
}
// FITTAN renderers.
try
{
worldObjectManager.Add(GameObject.Find("TRAFFIC").transform.Find("VehiclesDirtRoad/Rally/FITTAN").gameObject, DisableOn.Distance, 600, ToggleModes.MultipleRenderers);
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "FITTAN_RENDERERS_ERROR");
}
// Initialize Items clreplaced
try
{
new ItemsManager();
ItemsManager.Instance.Initialize();
ModConsole.Log("[MOP] Items clreplaced initialized");
}
catch (Exception ex)
{
ExceptionManager.New(ex, true, "ITEMS_CLreplaced_ERROR");
}
try
{
DateTime now = DateTime.Now;
if (now.Day == 1 && now.Month == 4)
{
GameObject fpsObject = GameObject.Find("GUI").transform.Find("HUD/FPS/HUDValue").gameObject;
PlayMakerFSM[] fsms = fpsObject.GetComponents<PlayMakerFSM>();
foreach (var fsm in fsms)
fsm.enabled = false;
fpsObject.GetComponent<TextMesh>().text = "99999999 :)";
fpsObject.transform.Find("HUDValueShadow").GetComponent<TextMesh>().text = "99999999 :)";
}
}
catch { }
HookPreSaveGame();
ModConsole.Log("[MOP] Loading rules...");
foreach (ToggleRule v in RulesManager.Instance.ToggleRules)
{
try
{
switch (v.ToggleMode)
{
default:
ModConsole.LogError($"[MOP] Unrecognized toggle mode for {v.ObjectName}: {v.ToggleMode}.");
break;
case ToggleModes.Simple:
if (GameObject.Find(v.ObjectName) == null)
{
ModConsole.LogError($"[MOP] Couldn't find world object {v.ObjectName}");
continue;
}
worldObjectManager.Add(v.ObjectName, DisableOn.Distance);
break;
case ToggleModes.Renderer:
if (GameObject.Find(v.ObjectName) == null)
{
ModConsole.LogError($"[MOP] Couldn't find world object {v.ObjectName}");
continue;
}
worldObjectManager.Add(v.ObjectName, DisableOn.Distance, 200, ToggleModes.Renderer);
break;
case ToggleModes.Item:
GameObject g = GameObject.Find(v.ObjectName);
if (g == null)
{
ModConsole.LogError($"[MOP] Couldn't find item {v.ObjectName}");
continue;
}
if (g.GetComponent<ItemBehaviour>() == null)
g.AddComponent<ItemBehaviour>();
break;
case ToggleModes.Vehicle:
if (RulesManager.Instance.SpecialRules.IgnoreModVehicles) continue;
if (GameObject.Find(v.ObjectName) == null)
{
ModConsole.LogError($"[MOP] Couldn't find vehicle {v.ObjectName}");
continue;
}
vehicleManager.Add(new Vehicle(v.ObjectName));
break;
case ToggleModes.VehiclePhysics:
if (RulesManager.Instance.SpecialRules.IgnoreModVehicles) continue;
if (GameObject.Find(v.ObjectName) == null)
{
ModConsole.LogError($"[MOP] Couldn't find vehicle {v.ObjectName}");
continue;
}
vehicleManager.Add(new Vehicle(v.ObjectName));
Vehicle veh = vehicleManager[vehicleManager.Count - 1];
veh.Toggle = veh.ToggleUnityCar;
break;
}
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "TOGGLE_RULES_LOAD_ERROR");
}
}
ModConsole.Log("[MOP] Rules loading complete!");
// Initialzie sector manager
try
{
gameObject.AddComponent<SectorManager>();
}
catch (Exception ex)
{
ExceptionManager.New(ex, true, "SECTOR_MANAGER_ERROR");
}
// Add DynamicDrawDistance component.
try
{
gameObject.AddComponent<DynamicDrawDistance>();
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, "DYNAMIC_DRAW_DISTANCE_ERROR");
}
if (MopSettings.Mode != PerformanceMode.Safe)
ToggleAll(false, ToggleAllMode.OnLoad);
// Initialize the coroutines.
currentLoop = LoopRoutine();
StartCoroutine(currentLoop);
currentControlCoroutine = ControlCoroutine();
StartCoroutine(currentControlCoroutine);
ModConsole.Log("<color=green>[MOP] MOD LOADED SUCCESFULLY!</color>");
Resources.UnloadUnusedreplacedets();
GC.Collect();
// If generate-list command is set to true, generate the list of items that are disabled by MOP.
if (MopSettings.GenerateToggledItemsListDebug)
{
if (System.IO.File.Exists("world.txt"))
System.IO.File.Delete("world.txt");
string world = "";
foreach (var w in worldObjectManager.GetList())
{
if (world.Contains(w.GetName())) continue;
world += w.GetName() + ", ";
}
System.IO.File.WriteAllText("world.txt", world);
System.Diagnostics.Process.Start("world.txt");
if (System.IO.File.Exists("vehicle.txt"))
System.IO.File.Delete("vehicle.txt");
string vehiclez = "";
foreach (var w in vehicleManager.List())
vehiclez += w.gameObject.name + ", ";
System.IO.File.WriteAllText("vehicle.txt", vehiclez);
System.Diagnostics.Process.Start("vehicle.txt");
if (System.IO.File.Exists("items.txt"))
System.IO.File.Delete("items.txt");
string items = "";
foreach (var w in ItemsManager.Instance.All())
{
if (items.Contains(w.gameObject.name)) continue;
items += w.gameObject.name + ", ";
}
System.IO.File.WriteAllText("items.txt", items);
System.Diagnostics.Process.Start("items.txt");
if (System.IO.File.Exists("place.txt"))
System.IO.File.Delete("place.txt");
string place = "";
foreach (var w in placeManager.GetList())
{
place += w.GetName() + ": ";
foreach (var f in w.GetDisableableChilds())
{
if (place.Contains(f.gameObject.name)) continue;
place += f.gameObject.name + ", ";
}
place += "\n\n";
}
System.IO.File.WriteAllText("place.txt", place);
System.Diagnostics.Process.Start("place.txt");
}
}
19
Source : BugReporter.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
IEnumerator CheckSaveSlots()
{
yield return null;
if (GameObject.Find("SaveSlotsCanvas(Clone)") != null)
{
GameObject.Find("SaveSlotsCanvas(Clone)").transform.Find("SaveSlotsUI/Saves/SavesList").gameObject.AddComponent<SaveSlotsSupport>();
}
}
19
Source : FramerateRecorder.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
internal void Initialize()
{
try
{
instance = this;
fpsMesh = GameObject.Find("GUI").transform.Find("HUD/FPS/HUDValue").GetComponent<TextMesh>();
if (samples == null) samples = new List<float>();
currentFrameRateWait = FrameWait();
StartCoroutine(currentFrameRateWait);
}
catch (Exception ex)
{
ModConsole.LogError(ex.ToString());
}
}
19
Source : LoadScreen.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
void Start()
{
loadScreen = ModLoader.UICanvas.transform.Find("ModLoaderUI/ModLoadScreen").gameObject;
loadScreen.transform.Find("TextHolder/Text").gameObject.GetComponent<Text>().text = LoadText;
Cursor.visible = false;
cursorFSM = GameObject.Find("PLAYER").GetPlayMakerFSM("Update Cursor");
cursorFSM.enabled = false;
}
19
Source : SaveManager.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
public static bool IsSatsumaLoadedCompletely()
{
// Check if cylinder head is supposed to be installed, but for some reason its disabled, or not a part of Satsuma at all.
GameObject satsuma = GameObject.Find("SATSUMA(557kg, 248)");
GameObject cylinderHead = Resources.FindObjectsOfTypeAll<GameObject>().First( g => g.name == "cylinder head(Clone)");
GameObject block = Resources.FindObjectsOfTypeAll<GameObject>().First(g => g.name == "block(Clone)");
MopSaveData save = new MopSaveData();
bool isCylinderHeadInstalled = ES2.Load<bool>(SavePath + "?tag=cylinder head(Clone)Installed", setting);
bool isEngineBlockInstalled = ES2.Load<bool>(SavePath + "?tag=block(Clone)Installed", setting);
if (!isEngineBlockInstalled)
{
if (isCylinderHeadInstalled && !cylinderHead.transform.Path().Contains("block(Clone)"))
{
return false;
}
}
else
{
if ((cylinderHead.gameObject.activeSelf == false || cylinderHead.transform.root != satsuma.transform) && isCylinderHeadInstalled)
{
return false;
}
}
Transform sparkPlug1Pivot = cylinderHead.transform.Find("pivot_sparkplug1");
for (int i = 1; i < 1000; ++i)
{
if (ES2.Load<int?>(ItemsPath + $"?tag=spark plug{i}TriggerID") == null)
{
break;
}
if (ES2.Load<int>(ItemsPath + $"?tag=spark plug{i}TriggerID") == 1 && ES2.Load<bool>(ItemsPath + $"?tag=spark plug{i}Installed"))
{
if (sparkPlug1Pivot.childCount == 0)
{
return false;
}
}
}
return true;
}
19
Source : BugReporter.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
IEnumerator DelayedRestart()
{
yield return null;
GameObject buttonContinue = GameObject.Find("Interface").transform.Find("Buttons/ButtonContinue").gameObject;
if (!buttonContinue.activeSelf)
{
yield break;
}
buttonContinue.SetActive(true);
PlayMakerFSM fsm = buttonContinue.GetPlayMakerFSM("SetSize");
var state = fsm.GetState("Action");
while (!state.ActionsLoaded)
yield return null;
var actions = state.Actions;
actions[2].Active = false;
actions[2].Enabled = false;
state.Actions = actions;
fsm.SendEvent("OVER");
fsm.SendEvent("DOWN");
}
19
Source : HingeManager.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
IEnumerator InitializationRoutine(bool noDelay = false)
{
if (noDelay)
yield return null;
else
yield return new WaitForSeconds(2);
this.initialLocalRotation = this.transform.localRotation;
this.initialLocalPosition = this.transform.localPosition;
if (!initialHookDone)
{
FsmHook.FsmInject(GameObject.Find("SATSUMA(557kg, 248)").transform.Find("Body/trigger_hood").gameObject, "replacedemble 2", UpdateInitialRotation);
initialHookDone = true;
}
}
19
Source : DynamicDrawDistance.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
void Start()
{
mainCamera = Camera.main;
player = GameObject.Find("PLAYER").transform;
typer = GameObject.Find("COMPUTER").transform.Find("SYSTEM/POS/Command").GetPlayMakerFSM("Typer").FsmVariables.GetFsmString("Old");
}
19
Source : ItemsManager.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
void InitializeList()
{
// Find shopping bags in the list
GameObject[] items = UnityEngine.Object.FindObjectsOfType<GameObject>()
.Where(gm => gm.name.ContainsAny(NameList) && gm.name.ContainsAny("(itemx)", "(Clone)") & gm.GetComponent<ItemBehaviour>() == null)
.ToArray();
if (items.Length > 0)
{
for (int i = 0; i < items.Length; i++)
{
if (items[i] == null) continue;
try
{
items[i].AddComponent<ItemBehaviour>();
}
catch { }
}
}
// CD Player Enhanced compatibility
if (ModLoader.GetMod("CDPlayer") != null)
{
GameObject[] cdEnchancedObjects = Resources.FindObjectsOfTypeAll<GameObject>()
.Where(gm => gm.name.ContainsAny("cd case(itemy)", "CD Rack(itemy)", "cd(itemy)") && gm.activeSelf).ToArray();
for (int i = 0; i < cdEnchancedObjects.Length; i++)
{
cdEnchancedObjects[i].AddComponent<ItemBehaviour>();
}
// Create shop table check, for when the CDs are bought
GameObject itemCheck = new GameObject("MOP_ItemAreaCheck");
itemCheck.transform.localPosition = new Vector3(-1551.303f, 4.883998f, 1182.904f);
itemCheck.transform.localEulerAngles = new Vector3(0f, 58.00043f, 0f);
itemCheck.transform.localScale = new Vector3(1f, 1f, 1f);
itemCheck.AddComponent<ShopModItemSpawnCheck>();
}
else
{
foreach (GameObject cd in Resources.FindObjectsOfTypeAll<GameObject>().Where(g => g.name.ContainsAny("cd case(item", "cd(item")).ToArray())
cd.AddComponent<ItemBehaviour>();
}
// Get items from ITEMS object.
GameObject itemsObject = GameObject.Find("ITEMS");
for (int i = 0; i < itemsObject.transform.childCount; i++)
{
GameObject item = itemsObject.transform.GetChild(i).gameObject;
if (item.name == "CDs") continue;
try
{
if (item.GetComponent<ItemBehaviour>() != null)
continue;
item.AddComponent<ItemBehaviour>();
}
catch (System.Exception ex)
{
ExceptionManager.New(ex, false, "ITEM_LIST_AT_ITEMS_LOAD_ERROR");
}
}
// Also disable the restart for that sunnuva replaced.
itemsObject.GetComponent<PlayMakerFSM>().Fsm.RestartOnEnable = false;
// replaced wheels.
foreach (GameObject wheel in UnityEngine.Object.FindObjectsOfType<GameObject>().Where(gm => gm.name.EqualsAny("wheel_regula", "wheel_offset") && gm.activeSelf).ToArray())
wheel.AddComponent<ItemBehaviour>();
// Tires trigger at Fleetari's.
GameObject wheelTrigger = new GameObject("MOP_WheelTrigger");
wheelTrigger.transform.localPosition = new Vector3(1555.49f, 4.8f, 737);
wheelTrigger.transform.localEulerAngles = new Vector3(1.16f, 335, 1.16f);
wheelTrigger.AddComponent<WheelRepairJobTrigger>();
// Hook up the envelope.
foreach (var g in Resources.FindObjectsOfTypeAll<GameObject>().Where(g => g.name.EqualsAny("envelope(xxxxx)", "lottery ticket(xxxxx)")).ToArray())
g.AddComponent<ItemBehaviour>();
// Unparent all childs of CDs object.
Transform cds = GameObject.Find("ITEMS").transform.Find("CDs");
if (cds)
{
for (int i = 0; i < cds.childCount; i++)
cds.GetChild(i).parent = null;
}
}
19
Source : Hypervisor.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
void HookPreSaveGame()
{
try
{
GameObject[] saveGames = Resources.FindObjectsOfTypeAll<GameObject>()
.Where(obj => obj.name.Contains("SAVEGAME")).ToArray();
int i = 0;
for (; i < saveGames.Length; i++)
{
bool useInnactiveFix = false;
bool isJail = false;
if (!saveGames[i].activeSelf)
{
useInnactiveFix = true;
saveGames[i].SetActive(true);
}
if (saveGames[i].transform.parent != null && saveGames[i].transform.parent.name == "JAIL" && saveGames[i].transform.parent.gameObject.activeSelf == false)
{
useInnactiveFix = true;
isJail = true;
saveGames[i].transform.parent.gameObject.SetActive(true);
}
FsmHook.FsmInject(saveGames[i], "Mute audio", PreSaveGame);
if (useInnactiveFix)
{
if (isJail)
{
saveGames[i].transform.parent.gameObject.SetActive(false);
continue;
}
saveGames[i].SetActive(false);
}
}
// Hooking up on death save.
GameObject onDeathSaveObject = new GameObject("MOP_OnDeathSave");
onDeathSaveObject.transform.parent = GameObject.Find("Systems").transform.Find("Death/GameOverScreen");
OnDeathBehaviour behaviour = onDeathSaveObject.AddComponent<OnDeathBehaviour>();
behaviour.Initialize(PreSaveGame);
i++;
// Adding custom action to state that will trigger PreSaveGame, if the player picks up the phone with large Suski.
PlayMakerFSM useHandleFSM = GameObject.Find("Telephone").transform.Find("Logic/UseHandle").GetComponent<PlayMakerFSM>();
FsmState phoneFlip = useHandleFSM.GetState("Pick phone");
List<FsmStateAction> phoneFlipActions = phoneFlip.Actions.ToList();
phoneFlipActions.Insert(0, new CustomSuskiLargeFlip());
phoneFlip.Actions = phoneFlipActions.ToArray();
i++;
ModConsole.Log($"[MOP] Hooked {i} save points!");
}
catch (Exception ex)
{
ExceptionManager.New(ex, true, "SAVE_HOOK_ERROR");
}
}
19
Source : Transform.cs
with MIT License
from bbepis
with MIT License
from bbepis
[Obsolete( "FindChild has been deprecated. Use Find instead (UnityUpgradable) -> Find([mscorlib] System.String)", false )]
public Transform FindChild( string name )
{
return Find( name );
}
19
Source : AutoCompleteComboBox.cs
with MIT License
from cmaher
with MIT License
from cmaher
private bool Initialize()
{
bool success = true;
try
{
_rectTransform = GetComponent<RectTransform>();
_inputRT = _rectTransform.Find("InputField").GetComponent<RectTransform>();
_mainInput = _inputRT.GetComponent<InputField>();
//_arrow_Button = _rectTransform.FindChild ("ArrowBtn").GetComponent<Button> ();
_overlayRT = _rectTransform.Find("Overlay").GetComponent<RectTransform>();
_overlayRT.gameObject.SetActive(false);
_scrollPanelRT = _overlayRT.Find("ScrollPanel").GetComponent<RectTransform>();
_scrollBarRT = _scrollPanelRT.Find("Scrollbar").GetComponent<RectTransform>();
_slidingAreaRT = _scrollBarRT.Find("SlidingArea").GetComponent<RectTransform>();
// scrollHandleRT = slidingAreaRT.FindChild("Handle").GetComponent<RectTransform>();
_itemsPanelRT = _scrollPanelRT.Find("Items").GetComponent<RectTransform>();
//itemPanelLayout = itemsPanelRT.gameObject.GetComponent<LayoutGroup>();
_canvas = GetComponentInParent<Canvas>();
_canvasRT = _canvas.GetComponent<RectTransform>();
_scrollRect = _scrollPanelRT.GetComponent<ScrollRect>();
_scrollRect.scrollSensitivity = _rectTransform.sizeDelta.y / 2;
_scrollRect.movementType = ScrollRect.MovementType.Clamped;
_scrollRect.content = _itemsPanelRT;
itemTemplate = _rectTransform.Find("ItemTemplate").gameObject;
itemTemplate.SetActive(false);
}
catch (System.NullReferenceException ex)
{
Debug.LogException(ex);
Debug.LogError("Something is setup incorrectly with the dropdownlist component causing a Null Refernece Exception");
success = false;
}
panelObjects = new Dictionary<string, GameObject>();
_prunedPanelItems = new List<string>();
_panelItems = new List<string>();
RebuildPanel();
//RedrawPanel(); - causes an initialisation failure in U5
return success;
}
19
Source : ComboBox.cs
with MIT License
from cmaher
with MIT License
from cmaher
private bool Initialize()
{
bool success = true;
try
{
_rectTransform = GetComponent<RectTransform>();
_inputRT = _rectTransform.Find("InputField").GetComponent<RectTransform>();
_mainInput = _inputRT.GetComponent<InputField>();
_overlayRT = _rectTransform.Find("Overlay").GetComponent<RectTransform>();
_overlayRT.gameObject.SetActive(false);
_scrollPanelRT = _overlayRT.Find("ScrollPanel").GetComponent<RectTransform>();
_scrollBarRT = _scrollPanelRT.Find("Scrollbar").GetComponent<RectTransform>();
_slidingAreaRT = _scrollBarRT.Find("SlidingArea").GetComponent<RectTransform>();
// scrollHandleRT = slidingAreaRT.FindChild("Handle").GetComponent<RectTransform>();
_itemsPanelRT = _scrollPanelRT.Find("Items").GetComponent<RectTransform>();
//itemPanelLayout = itemsPanelRT.gameObject.GetComponent<LayoutGroup>();
_canvas = GetComponentInParent<Canvas>();
_canvasRT = _canvas.GetComponent<RectTransform>();
_scrollRect = _scrollPanelRT.GetComponent<ScrollRect>();
_scrollRect.scrollSensitivity = _rectTransform.sizeDelta.y / 2;
_scrollRect.movementType = ScrollRect.MovementType.Clamped;
_scrollRect.content = _itemsPanelRT;
itemTemplate = _rectTransform.Find("ItemTemplate").gameObject;
itemTemplate.SetActive(false);
}
catch (System.NullReferenceException ex)
{
Debug.LogException(ex);
Debug.LogError("Something is setup incorrectly with the dropdownlist component causing a Null Refernece Exception");
success = false;
}
panelObjects = new Dictionary<string, GameObject>();
_panelItems = AvailableOptions.ToList();
RebuildPanel();
//RedrawPanel(); - causes an initialisation failure in U5
return success;
}
19
Source : DropDownList.cs
with MIT License
from cmaher
with MIT License
from cmaher
private bool Initialize()
{
bool success = true;
try
{
_rectTransform = GetComponent<RectTransform>();
_mainButton = new DropDownListButton(_rectTransform.Find("MainButton").gameObject);
_overlayRT = _rectTransform.Find("Overlay").GetComponent<RectTransform>();
_overlayRT.gameObject.SetActive(false);
_scrollPanelRT = _overlayRT.Find("ScrollPanel").GetComponent<RectTransform>();
_scrollBarRT = _scrollPanelRT.Find("Scrollbar").GetComponent<RectTransform>();
_slidingAreaRT = _scrollBarRT.Find("SlidingArea").GetComponent<RectTransform>();
// scrollHandleRT = slidingAreaRT.FindChild("Handle").GetComponent<RectTransform>();
_itemsPanelRT = _scrollPanelRT.Find("Items").GetComponent<RectTransform>();
//itemPanelLayout = itemsPanelRT.gameObject.GetComponent<LayoutGroup>();
_canvas = GetComponentInParent<Canvas>();
_canvasRT = _canvas.GetComponent<RectTransform>();
_scrollRect = _scrollPanelRT.GetComponent<ScrollRect>();
_scrollRect.scrollSensitivity = _rectTransform.sizeDelta.y / 2;
_scrollRect.movementType = ScrollRect.MovementType.Clamped;
_scrollRect.content = _itemsPanelRT;
_itemTemplate = _rectTransform.Find("ItemTemplate").gameObject;
_itemTemplate.SetActive(false);
}
catch (System.NullReferenceException ex)
{
Debug.LogException(ex);
Debug.LogError("Something is setup incorrectly with the dropdownlist component causing a Null Reference Exception");
success = false;
}
_panelItems = new List<DropDownListButton>();
RebuildPanel();
RedrawPanel();
return success;
}
19
Source : SegmentedControl.cs
with MIT License
from cmaher
with MIT License
from cmaher
public void LayoutSegments()
{
RecreateSprites();
RectTransform transform = this.transform as RectTransform;
float width = (transform.rect.width / segments.Length) - (SeparatorWidth * (segments.Length - 1));
for (int i = 0; i < segments.Length; i++)
{
float insetX = ((width + SeparatorWidth) * i);
var rectTransform = segments[i].GetComponent<RectTransform>();
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = Vector2.zero;
rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, insetX, width);
rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, transform.rect.height);
if (separator && i > 0)
{
var sepTransform = gameObject.transform.Find("Separator " + i);
Graphic sep = (sepTransform != null) ? sepTransform.GetComponent<Graphic>() : (GameObject.Instantiate(separator.gameObject) as GameObject).GetComponent<Graphic>();
sep.gameObject.name = "Separator " + i;
sep.gameObject.SetActive(true);
sep.rectTransform.SetParent(this.transform, false);
sep.rectTransform.anchorMin = Vector2.zero;
sep.rectTransform.anchorMax = Vector2.zero;
sep.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, insetX - SeparatorWidth, SeparatorWidth);
sep.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, transform.rect.height);
}
// TODO: maybe adjust text position
}
}
19
Source : Stepper.cs
with MIT License
from cmaher
with MIT License
from cmaher
public void LayoutSides(Selectable[] sides = null)
{
sides = sides ?? this.sides;
RecreateSprites(sides);
RectTransform transform = this.transform as RectTransform;
float width = (transform.rect.width / 2) - separatorWidth;
for (int i = 0; i < 2; i++)
{
float insetX = i == 0 ? 0 : width + separatorWidth;
var rectTransform = sides[i].GetComponent<RectTransform>();
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = Vector2.zero;
rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, insetX, width);
rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, transform.rect.height);
// TODO: maybe adjust text position
}
if (separator)
{
var sepTransform = gameObject.transform.Find("Separator");
Graphic sep = (sepTransform != null) ? sepTransform.GetComponent<Graphic>() : (GameObject.Instantiate(separator.gameObject) as GameObject).GetComponent<Graphic>();
sep.gameObject.name = "Separator";
sep.gameObject.SetActive(true);
sep.rectTransform.SetParent(this.transform, false);
sep.rectTransform.anchorMin = Vector2.zero;
sep.rectTransform.anchorMax = Vector2.zero;
sep.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, width, separatorWidth);
sep.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, transform.rect.height);
}
}
19
Source : G_CUIColorPicker.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
private GameObject GO( string name )
{
return transform.Find( name ).gameObject;
}
19
Source : ActionTabs.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
private void Awake()
{
// Make sure game objects are active
icons.ForEach(it => it.gameObject.SetActive(true));
tabs.ForEach(it =>
{
it.gameObject.SetActive(true);
it.canvasGroup.blocksRaycasts = false;
});
tabBackground.gameObject.SetActive(true);
tabBackground.canvasGroup.blocksRaycasts = false;
// Get profile rect transform
if (ProfileWidget.Instance != null)
{
profileRectTransform = ProfileWidget.Instance.GetComponent<RectTransform>();
}
// Setup close button
var closeIcon = gameObject.transform.Find(closeGameObjectName);
closeAction = closeIcon.gameObject.AddComponent<Action>();
closeAction.owner = this;
closeAction.index = -1;
closeAction.icon = closeIcon.Find(iconPath);
DOFade(closeAction.icon, 0, 0);
// Setup actions and tabs
for (var index = 0; index < icons.Count; index++)
{
var actionGameObject = icons[index];
var icon = actionGameObject.transform.Find(iconPath);
var tabIndicator = actionGameObject.transform.Find(tabIndicatorPath);
if (icon == null || tabIndicator == null) continue;
var action = actionGameObject.AddComponent<Action>();
action.owner = this;
action.index = index;
action.icon = icon;
action.tabIndicator = tabIndicator.GetComponent<TransitionElement>();
action.tabIndicator.hiddenOnStart = true;
action.tabIndicator.enterOnScreenBecomeActive = false;
Actions.Add(action);
tabs[index].hiddenOnStart = true;
tabs[index].enterOnScreenBecomeActive = false;
}
tabBackground.hiddenOnStart = true;
tabBackground.enterOnScreenBecomeActive = false;
// Set up close detection area
closeDetectionArea.onClick = Close;
closeDetectionArea.DetectionEnabled = false;
}
19
Source : ControllerHoverHighlight.cs
with MIT License
from dag10
with MIT License
from dag10
private void OnRenderModelLoaded( SteamVR_RenderModel renderModel, bool success )
{
if ( renderModel != this.renderModel )
{
return;
}
Transform bodyTransform = transform.Find( "body" );
if ( bodyTransform != null )
{
bodyMeshRenderer = bodyTransform.GetComponent<MeshRenderer>();
bodyMeshRenderer.material = highLightMaterial;
bodyMeshRenderer.enabled = false;
}
Transform trackingHatTransform = transform.Find( "trackhat" );
if ( trackingHatTransform != null )
{
trackingHatMeshRenderer = trackingHatTransform.GetComponent<MeshRenderer>();
trackingHatMeshRenderer.material = highLightMaterial;
trackingHatMeshRenderer.enabled = false;
}
foreach ( Transform child in transform )
{
if ( ( child.name != "body" ) && ( child.name != "trackhat" ) )
{
Destroy( child.gameObject );
}
}
renderModelLoaded = true;
}
19
Source : Hand.cs
with MIT License
from dag10
with MIT License
from dag10
public Transform GetAttachmentTransform( string attachmentPoint = "" )
{
Transform attachmentTransform = null;
if ( !string.IsNullOrEmpty( attachmentPoint ) )
{
attachmentTransform = transform.Find( attachmentPoint );
}
if ( !attachmentTransform )
{
attachmentTransform = this.transform;
}
return attachmentTransform;
}
19
Source : ControllerButtonHints.cs
with MIT License
from dag10
with MIT License
from dag10
private void CreateAndAddButtonInfo( EVRButtonId buttonID )
{
Transform buttonTransform = null;
List<MeshRenderer> buttonRenderers = new List<MeshRenderer>();
string buttonDebug = "Looking for button: " + buttonID;
EVRButtonId searchButtonID = buttonID;
if ( buttonID == EVRButtonId.k_EButton_Grip && SteamVR.instance.hmd_TrackingSystemName.ToLowerInvariant().Contains( "oculus" ) )
{
searchButtonID = EVRButtonId.k_EButton_Axis2;
}
ulong buttonMaskForID = ( 1ul << (int)searchButtonID );
foreach ( KeyValuePair<string, ulong> componentButtonMask in componentButtonMasks )
{
if ( ( componentButtonMask.Value & buttonMaskForID ) == buttonMaskForID )
{
buttonDebug += "\nFound component: " + componentButtonMask.Key + " " + componentButtonMask.Value;
Transform componentTransform = renderModel.FindComponent( componentButtonMask.Key );
buttonTransform = componentTransform;
buttonDebug += "\nFound componentTransform: " + componentTransform + " buttonTransform: " + buttonTransform;
buttonRenderers.AddRange( componentTransform.GetComponentsInChildren<MeshRenderer>() );
}
}
buttonDebug += "\nFound " + buttonRenderers.Count + " renderers for " + buttonID;
foreach ( MeshRenderer renderer in buttonRenderers )
{
buttonDebug += "\n\t" + renderer.name;
}
HintDebugLog( buttonDebug );
if ( buttonTransform == null )
{
HintDebugLog( "Couldn't find buttonTransform for " + buttonID );
return;
}
ButtonHintInfo hintInfo = new ButtonHintInfo();
buttonHintInfos.Add( buttonID, hintInfo );
hintInfo.componentName = buttonTransform.name;
hintInfo.renderers = buttonRenderers;
//Get the local transform for the button
hintInfo.localTransform = buttonTransform.Find( SteamVR_RenderModel.k_localTransformName );
OffsetType offsetType = OffsetType.Right;
switch ( buttonID )
{
case EVRButtonId.k_EButton_SteamVR_Trigger:
{
offsetType = OffsetType.Right;
}
break;
case EVRButtonId.k_EButton_ApplicationMenu:
{
offsetType = OffsetType.Right;
}
break;
case EVRButtonId.k_EButton_System:
{
offsetType = OffsetType.Right;
}
break;
case Valve.VR.EVRButtonId.k_EButton_Grip:
{
offsetType = OffsetType.Forward;
}
break;
case Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad:
{
offsetType = OffsetType.Up;
}
break;
}
//Offset for the text end transform
switch ( offsetType )
{
case OffsetType.Forward:
hintInfo.textEndOffsetDir = hintInfo.localTransform.forward;
break;
case OffsetType.Back:
hintInfo.textEndOffsetDir = -hintInfo.localTransform.forward;
break;
case OffsetType.Right:
hintInfo.textEndOffsetDir = hintInfo.localTransform.right;
break;
case OffsetType.Up:
hintInfo.textEndOffsetDir = hintInfo.localTransform.up;
break;
}
//Create the text hint object
Vector3 hintStartPos = hintInfo.localTransform.position + ( hintInfo.localTransform.forward * 0.01f );
hintInfo.textHintObject = GameObject.Instantiate( textHintPrefab, hintStartPos, Quaternion.idenreplacedy ) as GameObject;
hintInfo.textHintObject.name = "Hint_" + hintInfo.componentName + "_Start";
hintInfo.textHintObject.transform.SetParent( textHintParent );
//Get all the relevant child objects
hintInfo.textStartAnchor = hintInfo.textHintObject.transform.Find( "Start" );
hintInfo.textEndAnchor = hintInfo.textHintObject.transform.Find( "End" );
hintInfo.canvasOffset = hintInfo.textHintObject.transform.Find( "CanvasOffset" );
hintInfo.line = hintInfo.textHintObject.transform.Find( "Line" ).GetComponent<LineRenderer>();
hintInfo.textCanvas = hintInfo.textHintObject.GetComponentInChildren<Canvas>();
hintInfo.text = hintInfo.textCanvas.GetComponentInChildren<Text>();
hintInfo.textMesh = hintInfo.textCanvas.GetComponentInChildren<TextMesh>();
hintInfo.textHintObject.SetActive( false );
hintInfo.textStartAnchor.position = hintStartPos;
if ( hintInfo.text != null )
{
hintInfo.text.text = hintInfo.componentName;
}
if ( hintInfo.textMesh != null )
{
hintInfo.textMesh.text = hintInfo.componentName;
}
centerPosition += hintInfo.textStartAnchor.position;
// Scale hint components to match player size
hintInfo.textCanvas.transform.localScale = Vector3.Scale( hintInfo.textCanvas.transform.localScale, player.transform.localScale );
hintInfo.textStartAnchor.transform.localScale = Vector3.Scale( hintInfo.textStartAnchor.transform.localScale, player.transform.localScale );
hintInfo.textEndAnchor.transform.localScale = Vector3.Scale( hintInfo.textEndAnchor.transform.localScale, player.transform.localScale );
hintInfo.line.transform.localScale = Vector3.Scale( hintInfo.line.transform.localScale, player.transform.localScale );
}
19
Source : ControllerButtonHints.cs
with MIT License
from dag10
with MIT License
from dag10
private void CreateAndAddButtonInfo( EVRButtonId buttonID )
{
Transform buttonTransform = null;
List<MeshRenderer> buttonRenderers = new List<MeshRenderer>();
string buttonDebug = "Looking for button: " + buttonID;
EVRButtonId searchButtonID = buttonID;
if ( buttonID == EVRButtonId.k_EButton_Grip && SteamVR.instance.hmd_TrackingSystemName.ToLowerInvariant().Contains( "oculus" ) )
{
searchButtonID = EVRButtonId.k_EButton_Axis2;
}
ulong buttonMaskForID = ( 1ul << (int)searchButtonID );
foreach ( KeyValuePair<string, ulong> componentButtonMask in componentButtonMasks )
{
if ( ( componentButtonMask.Value & buttonMaskForID ) == buttonMaskForID )
{
buttonDebug += "\nFound component: " + componentButtonMask.Key + " " + componentButtonMask.Value;
Transform componentTransform = renderModel.FindComponent( componentButtonMask.Key );
buttonTransform = componentTransform;
buttonDebug += "\nFound componentTransform: " + componentTransform + " buttonTransform: " + buttonTransform;
buttonRenderers.AddRange( componentTransform.GetComponentsInChildren<MeshRenderer>() );
}
}
buttonDebug += "\nFound " + buttonRenderers.Count + " renderers for " + buttonID;
foreach ( MeshRenderer renderer in buttonRenderers )
{
buttonDebug += "\n\t" + renderer.name;
}
HintDebugLog( buttonDebug );
if ( buttonTransform == null )
{
HintDebugLog( "Couldn't find buttonTransform for " + buttonID );
return;
}
ButtonHintInfo hintInfo = new ButtonHintInfo();
buttonHintInfos.Add( buttonID, hintInfo );
hintInfo.componentName = buttonTransform.name;
hintInfo.renderers = buttonRenderers;
//Get the local transform for the button
hintInfo.localTransform = buttonTransform.Find( SteamVR_RenderModel.k_localTransformName );
OffsetType offsetType = OffsetType.Right;
switch ( buttonID )
{
case EVRButtonId.k_EButton_SteamVR_Trigger:
{
offsetType = OffsetType.Right;
}
break;
case EVRButtonId.k_EButton_ApplicationMenu:
{
offsetType = OffsetType.Right;
}
break;
case EVRButtonId.k_EButton_System:
{
offsetType = OffsetType.Right;
}
break;
case Valve.VR.EVRButtonId.k_EButton_Grip:
{
offsetType = OffsetType.Forward;
}
break;
case Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad:
{
offsetType = OffsetType.Up;
}
break;
}
//Offset for the text end transform
switch ( offsetType )
{
case OffsetType.Forward:
hintInfo.textEndOffsetDir = hintInfo.localTransform.forward;
break;
case OffsetType.Back:
hintInfo.textEndOffsetDir = -hintInfo.localTransform.forward;
break;
case OffsetType.Right:
hintInfo.textEndOffsetDir = hintInfo.localTransform.right;
break;
case OffsetType.Up:
hintInfo.textEndOffsetDir = hintInfo.localTransform.up;
break;
}
//Create the text hint object
Vector3 hintStartPos = hintInfo.localTransform.position + ( hintInfo.localTransform.forward * 0.01f );
hintInfo.textHintObject = GameObject.Instantiate( textHintPrefab, hintStartPos, Quaternion.idenreplacedy ) as GameObject;
hintInfo.textHintObject.name = "Hint_" + hintInfo.componentName + "_Start";
hintInfo.textHintObject.transform.SetParent( textHintParent );
//Get all the relevant child objects
hintInfo.textStartAnchor = hintInfo.textHintObject.transform.Find( "Start" );
hintInfo.textEndAnchor = hintInfo.textHintObject.transform.Find( "End" );
hintInfo.canvasOffset = hintInfo.textHintObject.transform.Find( "CanvasOffset" );
hintInfo.line = hintInfo.textHintObject.transform.Find( "Line" ).GetComponent<LineRenderer>();
hintInfo.textCanvas = hintInfo.textHintObject.GetComponentInChildren<Canvas>();
hintInfo.text = hintInfo.textCanvas.GetComponentInChildren<Text>();
hintInfo.textMesh = hintInfo.textCanvas.GetComponentInChildren<TextMesh>();
hintInfo.textHintObject.SetActive( false );
hintInfo.textStartAnchor.position = hintStartPos;
if ( hintInfo.text != null )
{
hintInfo.text.text = hintInfo.componentName;
}
if ( hintInfo.textMesh != null )
{
hintInfo.textMesh.text = hintInfo.componentName;
}
centerPosition += hintInfo.textStartAnchor.position;
// Scale hint components to match player size
hintInfo.textCanvas.transform.localScale = Vector3.Scale( hintInfo.textCanvas.transform.localScale, player.transform.localScale );
hintInfo.textStartAnchor.transform.localScale = Vector3.Scale( hintInfo.textStartAnchor.transform.localScale, player.transform.localScale );
hintInfo.textEndAnchor.transform.localScale = Vector3.Scale( hintInfo.textEndAnchor.transform.localScale, player.transform.localScale );
hintInfo.line.transform.localScale = Vector3.Scale( hintInfo.line.transform.localScale, player.transform.localScale );
}
19
Source : UIUtility.cs
with Apache License 2.0
from DarkLop
with Apache License 2.0
from DarkLop
public static T FindChildComponent<T>(this MonoBehaviour ui, string name) where T : Component
{
if (ui == null)
{
return null;
}
return ui.transform.Find(name).GetComponent<T>();
}
19
Source : UnityExtensions.cs
with MIT License
from DonnYep
with MIT License
from DonnYep
public static T GetOrAddComponentInPeer<T>(this Transform transform, string peerName)
where T : Component
{
Transform tran = transform.parent.Find(peerName);
if (tran != null)
{
var comp = tran.GetComponent<T>();
if (comp == null)
transform.gameObject.AddComponent<T>();
return comp;
}
return null;
}
See More Examples