Here are the examples of the csharp api UnityEngine.Component.GetComponent() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1498 Examples
19
Source : RearBumperBehaviour.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
void Start()
{
coll = GetComponent<Collider>();
ignored = new List<Collider>();
fsm = gameObject.GetPlayMakerFSM("BoltCheck");
seekColliders = transform.root == Satsuma.Instance.transform;
if (seekColliders)
{
Collider[] colls = Physics.OverlapSphere(transform.position, 5);
foreach (Collider coll in colls)
{
if (coll.transform.root == Satsuma.Instance.transform)
{
Physics.IgnoreCollision(this.coll, coll);
ignored.Add(coll);
}
}
StartCoroutine(ReloadBolts());
}
}
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 : SatsumaTriggerFixer.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
void Awake()
{
try
{
GameObject gameObjectPivot = GetComponent<PlayMakerFSM>().FsmVariables.GetFsmGameObject("Parent").Value;
if (gameObjectPivot == null)
{
Destroy(this);
return;
}
pivot = gameObjectPivot.transform;
}
catch (Exception ex)
{
ExceptionManager.New(ex, false, gameObject.Path());
}
}
19
Source : SatsumaWindscreenFixer.cs
with GNU General Public License v3.0
from Athlon007
with GNU General Public License v3.0
from Athlon007
void Awake()
{
fsm = GetComponent<PlayMakerFSM>();
}
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 : 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 : PlayerPickUp.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
private void OnTriggerEnter2D(Collider2D collision)
{
GameObjectData god;
if (!(god = collision.GetComponent<GameObjectData>()))
return;
if (!god.isEquipped)
{
if (Q_InputManager.Instance.pickUpItem == KeyCode.None)
{
if (!Q_GameMaster.Instance.inventoryManager.playerInventory.CheckIsFull(god.item.ID))
{
god.AddItemSelf();
Q_GameMaster.Instance.inventoryManager.PlayAddItemClip();
}
else
{
Q_GameMaster.Instance.inventoryManager.SetInformation(Q_GameMaster.Instance.inventoryManager
.infoManager.inventoryFull);
Debug.Log("Player Inventory is Full!");
}
}
}
}
19
Source : PlayerPickUp.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
private void OnTriggerStay2D(Collider2D collision)
{
GameObjectData GOD = null;
if (!(GOD = collision.GetComponent<GameObjectData>()))
return;
if (!GOD.isEquipped && Q_InputManager.Instance.pickUpItem != KeyCode.None)
{
if (Input.GetKeyDown(Q_InputManager.Instance.pickUpItem))
{
if (!Q_GameMaster.Instance.inventoryManager.playerInventory.CheckIsFull(GOD.item.ID))
{
GOD.AddItemSelf();
Q_GameMaster.Instance.inventoryManager.PlayAddItemClip();
}
else
{
Q_GameMaster.Instance.inventoryManager.SetInformation(Q_GameMaster.Instance.inventoryManager
.infoManager.inventoryFull);
Debug.Log("Player Inventory is Full!");
}
}
}
}
19
Source : Interactable.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
protected void OnTriggerEnter2DFunc(Collider2D other)
{
if (other.CompareTag(InteractableTag) && Pickable)
{
var playercomponent = other.GetComponent<BasePlayer>();
if (playercomponent != null) OnPlayerEnter(playercomponent);
}
}
19
Source : Interactable.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
protected void OnTriggerExit2DFunc(Collider2D other)
{
if (other.CompareTag(InteractableTag) && Pickable)
{
var playercomponent = other.GetComponent<BasePlayer>();
if (playercomponent != null) OnPlayerExit(playercomponent);
}
}
19
Source : Interactable.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
protected void OnTriggerStay2DFunc(Collider2D other)
{
if (other.CompareTag(InteractableTag) && Pickable && _target != null)
{
_target = this;
var playercomponent = other.GetComponent<BasePlayer>();
if (playercomponent != null) OnPlayerEnter(playercomponent);
}
}
19
Source : HealthBottle.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
private void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag("Player") || !_pickable) return;
var playerComponent = other.GetComponent<CommonPlayer>();
if (playerComponent != null)
{
OnPlayerTrigger(playerComponent);
}
}
19
Source : HealthBottle.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
private void OnTriggerStay2D(Collider2D other)
{
if (!other.CompareTag("Player") || !_pickable) return;
var playerComponent = other.GetComponent<CommonPlayer>();
if (playerComponent != null)
{
OnPlayerTrigger(playerComponent);
}
}
19
Source : MPBottle.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
private void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag("CommonPlayer") || !_pickable) return;
var playerComponent = other.GetComponent<CommonPlayer>();
if (playerComponent != null)
{
OnPlayerTrigger(playerComponent);
}
}
19
Source : MPBottle.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
private void OnTriggerStay2D(Collider2D other)
{
if (!other.CompareTag("CommonPlayer") || !_pickable) return;
var playerComponent = other.GetComponent<CommonPlayer>();
if (playerComponent != null)
{
OnPlayerTrigger(playerComponent);
}
}
19
Source : Spikes.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
protected void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Enreplacedy") && DamageActive)
{
var healthcomponent = other.GetComponent<Health>();
if (healthcomponent != null) OnEnreplacedyEnter(healthcomponent);
}
}
19
Source : Spikes.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
protected void OnTriggerStay2D(Collider2D other)
{
if (other.CompareTag("Enreplacedy") && DamageActive)
{
var healthcomponent = other.GetComponent<Health>();
if (healthcomponent != null) OnEnreplacedyEnter(healthcomponent);
}
}
19
Source : Laser.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
public bool TriggerWeapon(Vector3 d)
{
lineRenderer.enabled = true;
var dir = d - gunBarrel.position;
var hit = Physics2D.Raycast(gunBarrel.position, dir.normalized, 5400f);
//光线投射,返回障碍物
if (hit && lineRenderer.enabled) //如果遇到障碍物且射线打开
{
var scaleX = Vector3.Distance(hit.point, gunBarrel.position);
Instantiate(fx, hit.point, Quaternion.Euler(Vector3.zero)); //在障碍物处产生爆炸效果
var enemy = hit.transform.GetComponent<Health>();
if (enemy != null)
{
enemy.TakeDamage(damage);
}
//射线的起始点
lineRenderer.SetPosition(0, new Vector3(gunBarrel.position.x, gunBarrel.position.y, 20));
//因为激光只有一个终点,所以障碍物位置为终点
lineRenderer.SetPosition(1, new Vector3(hit.point.x, hit.point.y, 20));
}
else
{
lineRenderer.SetPosition(0, gunBarrel.position);
lineRenderer.SetPosition(1, d);
}
return true;
}
19
Source : PixelArtCamera.cs
with GNU Affero General Public License v3.0
from AugustToko
with GNU Affero General Public License v3.0
from AugustToko
public void SetupRenderTexture () {
// Try to connect missing pieces
if (mainCamera == null) {
mainCamera = Camera.main;
}
if (mainCanvas == null) {
GameObject canvasObj = GameObject.Find("Canvas");
if (canvasObj != null) {
mainCanvas = canvasObj.GetComponent<Canvas>();
}
}
// prevent 0-size rendertextures, just in case
if (pixels.x == 0 || pixels.y == 0) {
return;
}
if (rt != null) {
rt.Release();
}
screenResolution.x = Screen.width;
screenResolution.y = Screen.height;
targetAspectRatio = (float)pixels.x / (float)pixels.y;
currentAspectRatio = (float)Screen.width / (float)Screen.height;
internalResolution.x = pixels.x;
internalResolution.y = pixels.y;
// Figure out best pixel resolution for aspect ratio we're on
if (currentAspectRatio != targetAspectRatio) {
if (currentAspectRatio > targetAspectRatio) {
// Wider screen
internalResolution.x = (int)Mathf.Round((float)pixels.y * currentAspectRatio);
} else {
// Taller screen
internalResolution.y = (int)Mathf.Round((float)pixels.x / currentAspectRatio);
}
}
// Determine scale to keep pixels square
finalBlitStretch = Vector2.one;
if (forceSquarePixels) {
float internalResAspect = (float)internalResolution.x / (float)internalResolution.y;
if (currentAspectRatio != targetAspectRatio) {
if (currentAspectRatio > targetAspectRatio) {
// Wider screen
finalBlitStretch.x = (currentAspectRatio / internalResAspect);
} else {
// Taller screen
finalBlitStretch.y = (internalResAspect / currentAspectRatio);
}
}
}
// Configure canvas properly to match camera
if (mainCanvas != null) {
mainCanvas.renderMode = RenderMode.ScreenSpaceCamera;
mainCanvas.worldCamera = mainCamera;
Canvreplacedcaler scaler = mainCanvas.GetComponent<Canvreplacedcaler>();
scaler.uiScaleMode = Canvreplacedcaler.ScaleMode.ScaleWithScreenSize;
//scaler.referenceResolution = new Vector2(pixels.x, pixels.y);
scaler.screenMatchMode = Canvreplacedcaler.ScreenMatchMode.Expand;
scaler.referencePixelsPerUnit = pixelsPerUnit;
// If we're stretching to a non-square pixel ratio, we need to make sure the canvas scaler keeps our pixel per unit ratio
Vector2 pixelSize;
pixelSize.x = (float)screenResolution.x / (float)internalResolution.x;
pixelSize.y = (float)screenResolution.y / (float)internalResolution.y;
scaler.referenceResolution = new Vector2((float)pixels.x * pixelSize.x/pixelSize.y, (float)pixels.y);
}
// Make sure our camera projection fits our resolution
mainCamera.orthographicSize = internalResolution.y / 2f / pixelsPerUnit;
Shader.SetGlobalFloat("PIXELS_PER_UNIT", pixelsPerUnit);
// rt = new RenderTexture(internalResolution.x, internalResolution.y, 16, RenderTextureFormat.ARGB32);
// if (smooth) {
// rt.filterMode = FilterMode.Bilinear;
// } else {
// rt.filterMode = FilterMode.Point;
// }
// rt.Create();
}
19
Source : NetworkProximityChecker.cs
with MIT License
from BattleDawnNZ
with MIT License
from BattleDawnNZ
public override bool OnRebuildObservers(HashSet<NetworkConnection> observers, bool initial)
{
if (forceHidden)
{
// ensure player can still see themself
var uv = GetComponent<NetworkIdenreplacedy>();
if (uv.connectionToClient != null)
{
observers.Add(uv.connectionToClient);
}
return true;
}
// find players within range
switch (checkMethod)
{
case CheckMethod.Physics3D:
{
var hits = Physics.OverlapSphere(transform.position, visRange);
for (int i = 0; i < hits.Length; i++)
{
var hit = hits[i];
// (if an object has a connectionToClient, it is a player)
var uv = hit.GetComponent<NetworkIdenreplacedy>();
if (uv != null && uv.connectionToClient != null)
{
observers.Add(uv.connectionToClient);
}
}
return true;
}
case CheckMethod.Physics2D:
{
var hits = Physics2D.OverlapCircleAll(transform.position, visRange);
for (int i = 0; i < hits.Length; i++)
{
var hit = hits[i];
// (if an object has a connectionToClient, it is a player)
var uv = hit.GetComponent<NetworkIdenreplacedy>();
if (uv != null && uv.connectionToClient != null)
{
observers.Add(uv.connectionToClient);
}
}
return true;
}
}
return false;
}
19
Source : TMP_Dropdown.cs
with MIT License
from BattleDawnNZ
with MIT License
from BattleDawnNZ
public void Show()
{
if (!IsActive() || !IsInteractable() || m_Dropdown != null)
return;
// Get root Canvas.
var list = TMP_ListPool<Canvas>.Get();
gameObject.GetComponentsInParent(false, list);
if (list.Count == 0)
return;
Canvas rootCanvas = list[list.Count - 1];
for (int i = 0; i < list.Count; i++)
{
if (list[i].isRootCanvas)
{
rootCanvas = list[i];
break;
}
}
TMP_ListPool<Canvas>.Release(list);
if (!validTemplate)
{
SetupTemplate();
if (!validTemplate)
return;
}
m_Template.gameObject.SetActive(true);
// popupCanvas used to replacedume the root canvas had the default sorting Layer, next line fixes (case 958281 - [UI] Dropdown list does not copy the parent canvas layer when the panel is opened)
m_Template.GetComponent<Canvas>().sortingLayerID = rootCanvas.sortingLayerID;
// Instantiate the drop-down template
m_Dropdown = CreateDropdownList(m_Template.gameObject);
m_Dropdown.name = "Dropdown List";
m_Dropdown.SetActive(true);
// Make drop-down RectTransform have same values as original.
RectTransform dropdownRectTransform = m_Dropdown.transform as RectTransform;
dropdownRectTransform.SetParent(m_Template.transform.parent, false);
// Instantiate the drop-down list items
// Find the dropdown item and disable it.
DropdownItem itemTemplate = m_Dropdown.GetComponentInChildren<DropdownItem>();
GameObject content = itemTemplate.rectTransform.parent.gameObject;
RectTransform contentRectTransform = content.transform as RectTransform;
itemTemplate.rectTransform.gameObject.SetActive(true);
// Get the rects of the dropdown and item
Rect dropdownContentRect = contentRectTransform.rect;
Rect itemTemplateRect = itemTemplate.rectTransform.rect;
// Calculate the visual offset between the item's edges and the background's edges
Vector2 offsetMin = itemTemplateRect.min - dropdownContentRect.min + (Vector2)itemTemplate.rectTransform.localPosition;
Vector2 offsetMax = itemTemplateRect.max - dropdownContentRect.max + (Vector2)itemTemplate.rectTransform.localPosition;
Vector2 itemSize = itemTemplateRect.size;
m_Items.Clear();
Toggle prev = null;
for (int i = 0; i < options.Count; ++i)
{
OptionData data = options[i];
DropdownItem item = AddItem(data, value == i, itemTemplate, m_Items);
if (item == null)
continue;
// Automatically set up a toggle state change listener
item.toggle.isOn = value == i;
item.toggle.onValueChanged.AddListener(x => OnSelecreplacedem(item.toggle));
// Select current option
if (item.toggle.isOn)
item.toggle.Select();
// Automatically set up explicit navigation
if (prev != null)
{
Navigation prevNav = prev.navigation;
Navigation toggleNav = item.toggle.navigation;
prevNav.mode = Navigation.Mode.Explicit;
toggleNav.mode = Navigation.Mode.Explicit;
prevNav.selectOnDown = item.toggle;
prevNav.selectOnRight = item.toggle;
toggleNav.selectOnLeft = prev;
toggleNav.selectOnUp = prev;
prev.navigation = prevNav;
item.toggle.navigation = toggleNav;
}
prev = item.toggle;
}
// Reposition all items now that all of them have been added
Vector2 sizeDelta = contentRectTransform.sizeDelta;
sizeDelta.y = itemSize.y * m_Items.Count + offsetMin.y - offsetMax.y;
contentRectTransform.sizeDelta = sizeDelta;
float extraSpace = dropdownRectTransform.rect.height - contentRectTransform.rect.height;
if (extraSpace > 0)
dropdownRectTransform.sizeDelta = new Vector2(dropdownRectTransform.sizeDelta.x, dropdownRectTransform.sizeDelta.y - extraSpace);
// Invert anchoring and position if dropdown is partially or fully outside of canvas rect.
// Typically this will have the effect of placing the dropdown above the button instead of below,
// but it works as inversion regardless of initial setup.
Vector3[] corners = new Vector3[4];
dropdownRectTransform.GetWorldCorners(corners);
RectTransform rootCanvasRectTransform = rootCanvas.transform as RectTransform;
Rect rootCanvasRect = rootCanvasRectTransform.rect;
for (int axis = 0; axis < 2; axis++)
{
bool outside = false;
for (int i = 0; i < 4; i++)
{
Vector3 corner = rootCanvasRectTransform.InverseTransformPoint(corners[i]);
if ((corner[axis] < rootCanvasRect.min[axis] && !Mathf.Approximately(corner[axis], rootCanvasRect.min[axis])) ||
(corner[axis] > rootCanvasRect.max[axis] && !Mathf.Approximately(corner[axis], rootCanvasRect.max[axis])))
{
outside = true;
break;
}
}
if (outside)
RectTransformUtility.FlipLayoutOnAxis(dropdownRectTransform, axis, false, false);
}
for (int i = 0; i < m_Items.Count; i++)
{
RectTransform itemRect = m_Items[i].rectTransform;
itemRect.anchorMin = new Vector2(itemRect.anchorMin.x, 0);
itemRect.anchorMax = new Vector2(itemRect.anchorMax.x, 0);
itemRect.ancreplaceddPosition = new Vector2(itemRect.ancreplaceddPosition.x, offsetMin.y + itemSize.y * (m_Items.Count - 1 - i) + itemSize.y * itemRect.pivot.y);
itemRect.sizeDelta = new Vector2(itemRect.sizeDelta.x, itemSize.y);
}
// Fade in the popup
AlphaFadeList(0.15f, 0f, 1f);
// Make drop-down template and item template inactive
m_Template.gameObject.SetActive(false);
itemTemplate.gameObject.SetActive(false);
m_Blocker = CreateBlocker(rootCanvas);
}
19
Source : ChangeAtRuntime.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start ()
{
fix = gameObject.AddComponent<LPFixturePoly>();
fix.DefinePoints(Points);
bod = GetComponent<LPBody>();
bod.Initialise(FindObjectOfType<LPManager>());
}
19
Source : ExplodeonBodyContacts.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start ()
{
partsys = FindObjectOfType<LPParticleSystem>();
bod = GetComponent<LPBody>();
}
19
Source : GoUpandDown.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start ()
{
joint = GetComponent<LPJointPrismatic>();
StartCoroutine("UpandDown");
}
19
Source : Mine.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
public void Splode()
{
IntPtr partsysptr = lpman.ParticleSystems[ParticleSystemImIn].GetPtr();
IntPtr worldPtr = lpman.GetPtr();
IntPtr particlesPointer = LPAPIParticleSystems.GetParticlesInShape(worldPtr, partsysptr
, shape, transform.position.x, transform.position.y
, transform.rotation.eulerAngles.z);
int[] particlesArray = new int[1];
Marshal.Copy(particlesPointer, particlesArray, 0, 1);
int foundNum = particlesArray[0];
if (foundNum > 0)
{
int[] Indices = new int[foundNum + 1];
Marshal.Copy(particlesPointer, Indices, 0, foundNum + 1);
LPAPIParticles.ExplodeSelectedParticles(partsysptr, Indices, transform.position.x, transform.position.y, ExplosionStrenght);
}
GetComponent<LPBody>().Delete();
Destroy(gameObject);
}
19
Source : spawnafterwait.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
IEnumerator SpawnNow()
{
yield return new WaitForSeconds(spawntime);
GetComponent<LPBody>().Initialise(FindObjectOfType<LPManager>());
}
19
Source : StartStopAimer.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start()
{
aimer = GetComponent<LPAimer>();
}
19
Source : LPDrawParticleSystem.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
public void Initialise(LPParticleSystem partsys)
{
GetComponent<ParticleEmitter>().maxSize = GetComponent<ParticleEmitter>().minSize = partsys.ParticleRadius*ParticleDrawScale;
particleEmitterObj = GetComponent<ParticleEmitter>();
}
19
Source : AttachMouseQueryToMouse.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start ()
{
mouseQuery = GetComponent<MouseQueryWorldForBody>();
lpMan = FindObjectOfType<LPManager>();
}
19
Source : Button.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
public virtual Button2 BeOnClicked()
{
GetComponent<SpriteRenderer>().color = Color.red;
On = true;
return this;
}
19
Source : Button.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
public virtual void BeOffClicked()
{
GetComponent<SpriteRenderer>().color = Color.white;
On = false;
}
19
Source : FPScounter.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start ()
{
timeleft = updateInterval;
textm = GetComponent<TextMesh>();
}
19
Source : TrackParentCamera.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start()
{
thisCamera = GetComponent<Camera>();
mainCamera = transform.parent.GetComponent<Camera>();
}
19
Source : Melter.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start ()
{
group = GetComponent<LPParticleGroup>();
sys = FindObjectOfType<LPManager>().ParticleSystems[group.ParticleSystemImIn];
StartCoroutine("Melt");
}
19
Source : Shooter.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start ()
{
lpman = FindObjectOfType<LPManager>();
caster = GetComponent<LPRayCaster>();
shape = GetComponent<LPFixture>().GetShape();
if(AutoShoot)StartCoroutine("shoot");
}
19
Source : TapToBounceParticleGroup.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
private void MoveGroupToMousePosition()
{
// Move towards the mouse position
if (Input.touchCount > 0 || Input.GetMouseButton(0))
{
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector3 diff = mousePos - transform.position;
diff.Normalize();
diff.Scale(new Vector3(10000, 10000, 10000));
LPAPIParticleGroups.ApplyForceToParticleGroup(GetComponent<LPParticleGroup>().GetPtr(), diff.x, diff.y);
}
}
19
Source : TapToBounceParticleGroup.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
private void SetPositionToGroupCenteroid()
{
// Set the position to the particle group center
LPParticleGroup group = GetComponent<LPParticleGroup>();
Vector2 center = group.GetCenter();
if (!(float.IsNaN(center.x)) && !(float.IsNaN(center.y)))
{
transform.position = new Vector3(center.x, center.y, startZ);
}
else
{
transform.position = new Vector3(-1000, -1000, -1000);
}
}
19
Source : TapToBounceParticleGroup.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
IEnumerator SplitGroup()
{
// Splitting a group can be costly so do not perform this operation each frame
while (LPAPIParticleSystems.GetNumberOfParticles(sys.GetPtr()) > 0)
{
LPAPIParticleGroups.SplitParticleGroup(FindObjectOfType<LPManager>().ParticleSystems[0].GetPtr(), FindObjectOfType<LPParticleGroup>().GetPtr());
IntPtr largestGroup = sys.GetLargestGroupDataFromPlugin();
GetComponent<LPParticleGroup>().SetThingPtr(largestGroup);
yield return new WaitForSeconds(1f);
}
}
19
Source : TestUserData.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start ()
{
Debug.Log(LPAPIBody.GetBodyUserData(GetComponent<LPBody>().GetPtr()));
Debug.Log(LPAPIFixture.GetFixtureUserData(GetComponent<LPFixture>().GetPtr()));
}
19
Source : Waterfall.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start ()
{
pg = GetComponent<LPParticleGroup>();
nowcol = pg._Color;
destcol = new Color(Random.Range(0f,1f),Random.Range(0f,1f),Random.Range(0f,1f),Random.Range(0.2f,1f));
StartCoroutine("changecol");
}
19
Source : DeleteBodyOnContact.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start()
{
bod = GetComponent<LPBody>();
lpman = FindObjectOfType<LPManager>();
if (lpman.UseContactListener == false)
{
Debug.LogError("This body destroyer needs 'Use Contact Listener' in the LPManager component in this scene to be set to reue in order to work");
}
}
19
Source : LPParticleDestroyer.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void Start()
{
sys = FindObjectOfType<LPManager>().ParticleSystems[ParticleSystemImIn];
Shape = GetComponent<LPFixture>().GetShape();
}
19
Source : DeleteNeuron.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
public void DeleteN()
{
gameObject.GetComponent<SelectionNeuron>().SelectOff.Invoke();
if (GetComponent<SelectionNeuron>().SelectorNeuronOne != null)
{
DeleteFull(gameObject.GetComponent<SelectionNeuron>().SelectorNeuronOne);
GetComponent<SpaceNeuron>().NeuronList.Remove(GetComponent<SelectionNeuron>().SelectorNeuronOne.GetComponent<InspectorNeuron>().isNeuron);
Destroy(gameObject.GetComponent<SelectionNeuron>().SelectorNeuronOne);
}
if (gameObject.GetComponent<SelectionNeuron>().SelectionList.Count > 0)
{
for (int i = 0; i < gameObject.GetComponent<SelectionNeuron>().SelectionList.Count; i++)
{
DeleteFull(GetComponent<SelectionNeuron>().SelectionList[i]);
GetComponent<SpaceNeuron>().NeuronList.Remove(GetComponent<SelectionNeuron>().SelectionList[i].GetComponent<InspectorNeuron>().isNeuron);
Destroy(GetComponent<SelectionNeuron>().SelectionList[i]);
}
}
gameObject.GetComponent<SelectionNeuron>().SelectionList.Clear();
}
19
Source : DeleteNeuron.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void DeleteFull(GameObject DeleteNeuron)
{
if (DeleteNeuron != null)
{
for (int i = 0; i < DeleteNeuron.GetComponent<InspectorNeuron>().isNeuron.PostSynapses.Count; i++)
{
Synapse DeleteSynapse = DeleteNeuron.GetComponent<InspectorNeuron>().isNeuron.PostSynapses[i];
DeleteSynapse.parentNeuron.PreSynapses.Remove(DeleteSynapse);
GetComponent<SpaceNeuron>().SynapseList.Remove(DeleteSynapse);
DeleteSynapse.DeleteSynapse();
}
for (int i = 0; i < DeleteNeuron.GetComponent<InspectorNeuron>().isNeuron.PreSynapses.Count; i++)
{
Synapse DeleteSynapse = DeleteNeuron.GetComponent<InspectorNeuron>().isNeuron.PreSynapses[i];
DeleteSynapse.targetNeuron.PostSynapses.Remove(DeleteSynapse);
GetComponent<SpaceNeuron>().SynapseList.Remove(DeleteSynapse);
}
}
}
19
Source : IndicatorMuscle.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void LateUpdate()
{
GetComponent<Image>().fillAmount = Box2 / 10;
}
19
Source : InputEvent.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void ModeNewSynaps(RaycastHit2D _hit)
{
if (_hit.collider != null)
{
if (_hit.collider.tag == "Neuron")
{
GetComponent<InsertSynapse>().SynapseInsert(GetComponent<SelectionNeuron>().SelectorNeuronOne, _hit.collider.gameObject);
}
}
}
19
Source : InputEvent.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
void ModeSelection(RaycastHit2D _hit)
{
if (_hit.collider != null)
{
if (_hit.collider.tag == "Neuron")
{
GetComponent<SelectionNeuron>().RayOn(_hit.collider.gameObject);
}
else GetComponent<SelectionNeuron>().RayOn(null);
if (_hit.collider.tag == "Tool")
{
if (toolAction != null) toolAction.GetComponent<ToolSelect>().OffSelectTool();
_hit.collider.GetComponent<ToolSelect>().OnSelectTool();
toolAction = _hit.collider.gameObject;
modeButton = ModeSelectTargetNeuronTool;
}
}
else GetComponent<SelectionNeuron>().RayOn(null);
}
19
Source : InputOne.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
private void OnDownKey()
{
if (N != null) N.Signal(2, 0, 0);
GetComponent<Image>().color = new Color32(255, 255, 0, 130);
transform.GetChild(0).GetComponent<Image>().color = GetComponent<Image>().color;
transform.GetChild(0).GetComponent<LineRenderer>().SetColors(new Color32(255, 255, 0, 130), new Color32(255, 255, 0, 130));
}
19
Source : InputOne.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
private void OnUpKey()
{
GetComponent<Image>().color = new Color32(255, 255, 255, 130);
transform.GetChild(0).GetComponent<Image>().color = GetComponent<Image>().color;
transform.GetChild(0).GetComponent<LineRenderer>().SetColors(new Color32(255, 255, 255, 130), new Color32(255, 255, 255, 130));
}
19
Source : InsertOneNeuron.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
public void InsertNeuron()
{
if ((_panel != null) && (_neurons != null) && (prefabNeuron != null))
{
Vector3 PositionPanel = Camera.main.ScreenToWorldPoint(_panel.transform.position);
PositionPanel.z = 0f;
GameObject clone = Instantiate(prefabNeuron, PositionPanel, transform.rotation) as GameObject;
clone.name = "Neuron";
if (_neurons.transform.childCount < InsertLayer) NewLauers();
clone.transform.parent = _neurons.transform.GetChild(InsertLayer);
clone.GetComponent<InspectorNeuron>().isNeuron = GetComponent<SpaceNeuron>().CreateNeuron(new Vector2(clone.transform.position.x, clone.transform.position.y), InsertLayer, InsertType);
clone.GetComponent<InspectorNeuron>().reColor();
clone.GetComponent<InspectorNeuron>().isNeuron.onAction += clone.GetComponent<InspectorNeuron>().OnActionNeuron;
clone.GetComponent<InspectorNeuron>().isNeuron.deAction += clone.GetComponent<InspectorNeuron>().deActionNeuron;
if (InsertType == 2) (clone.GetComponent<InspectorNeuron>().isNeuron.summator as SummatordIN).DeReActionNeuron += clone.GetComponent<InspectorNeuron>().DeReActionNeuron;
}
}
See More Examples