本文整理汇总了C#中GameObject.RequireComponent方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.RequireComponent方法的具体用法?C# GameObject.RequireComponent怎么用?C# GameObject.RequireComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject.RequireComponent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStart
public void OnStart()
{
foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col0"))
{
_col0Lights.Add(obj.RequireComponent<CLight>());
_allLights.Add(obj.RequireComponent<CLight>());
}
foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col1"))
{
_col1Lights.Add(obj.RequireComponent<CLight>());
_allLights.Add(obj.RequireComponent<CLight>());
}
foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col2"))
{
_col2Lights.Add(obj.RequireComponent<CLight>());
_allLights.Add(obj.RequireComponent<CLight>());
}
foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col3"))
{
_col3Lights.Add(obj.RequireComponent<CLight>());
_allLights.Add(obj.RequireComponent<CLight>());
}
chilloutFace = GameObject.GetGameObjectByName("lastchilloutface");
faceRender = chilloutFace.RequireComponent<CSkinMeshRenderer>();
faceTransform = chilloutFace.RequireComponent<CTransform>();
faceRender.setEnabled(false);
distortScript = GetScript<DistortForTime>(gameObject);
currAliveTimer = MMath.GetRandomLimitedFloat(_monsterMinActiveTime, _monsterMaxActiveTime);
sound = gameObject.RequireComponent<CSound>();
}
示例2: OnStart
public void OnStart()
{
//base.OnStart();
currAliveTimer = MMath.GetRandomLimitedFloat(_monsterMinActiveTime, _monsterMaxActiveTime);
currDeadTimer = MMath.GetRandomLimitedFloat(_monsterMinRestTime, _monsterMaxRestTime);
chilloutFace = GameObject.GetGameObjectByName("maxChill");
faceRender = chilloutFace.RequireComponent<CSkinMeshRenderer>();
faceTransform = chilloutFace.RequireComponent<CTransform>();
faceRender.setEnabled(false);
distortScript = GetScript<DistortForTime>(gameObject);
}
示例3: OnStart
public void OnStart()
{
//idle.OnEnter = State_Idle_Enter;
//idle.OnUpdate = State_Idle_Update;
//idle.OnExit = State_Idle_Exit;
//
//jump.OnEnter = State_Jump_Enter;
//jump.OnUpdate = State_Jump_Update;
//jump.OnExit = State_Jump_Exit;
//
//crouch.OnEnter = State_Crouch_Enter;
//crouch.OnUpdate = State_Crouch_Update;
//crouch.OnExit = State_Crouch_Exit;
//
//move.OnEnter = State_Move_Enter;
//move.OnUpdate = State_Move_Update;
//move.OnExit = State_Move_Exit;
//
//smc.SetState(idle);
//
// Self
oculusCam = gameObject.RequireComponent<CCamera>();
gameCam = GameObject.GetGameObjectByName("Camera").RequireComponent<CCamera>();
PickCam1 = GameObject.GetGameObjectByName("PickCam1");
CMeshRenderer mesh = PickCam1.RequireComponent<CMeshRenderer>();
mesh.setEnabled(false);
}
示例4: OnStart
public void OnStart()
{
Input.SetMouseVisible(false);
Input.SetMouseLock(true);
playerScript = GetScript<FirstPersonPlayer>(Common.GetStealthPlayer());
rcCarScript = GetScript<RCCar>(Common.GetRCCarJoystick());
cameraCam = Common.GetSurveillancePlayerStaticCameraCam();
camScript = GetScript<CameraCam>(cameraCam);
ocuCam = Common.GetSurveillancePlayerCam();
prevPickedInteractable = null;
pickedInteractable = null;
prevPickedObject = null;
pickedObject = null;
camInMapIndex = 0;
camInMap = Common.GetCamsInMap();
mCurrMouseMovement = new Vector2(0.0f, 0.0f);
mMousePositionFromOcuCam = new Vector3(0.0f, 0.0f, 1.3f);
// Set the mouse cursor position to center of oculus screen
gameObject.transform.SetPosition(ocuCam.transform.position +
(Vector3)ocuCam.transform.GetForwardVector() * mMousePositionFromOcuCam.Z);
// Calculate the limits for the mouse on the ocuScreen
CCamera ocuCameraComp = ocuCam.RequireComponent<CCamera>();
mMouseLimits = new Vector2();
mMouseLimits.X = mMousePositionFromOcuCam.Z / ocuCameraComp.GetNearZ() * ocuCameraComp.GetNearWindowWidth() * 0.5f;
mMouseLimits.Y = mMousePositionFromOcuCam.Z / ocuCameraComp.GetNearZ() * ocuCameraComp.GetNearWindowHeight() * 0.5f;
ocuCameraScreen = Common.GetCameraScreen().RequireComponent<CCamera>();
}
示例5: OnStart
public void OnStart()
{
screenImage = GameObject.GetGameObjectByName(Common.prefix + screenImageName);
screenImageMesh = screenImage.RequireComponent<CMeshRenderer>();
fadeScreen = GameObject.GetGameObjectByName(Common.prefix + fadeScreenName);
Common.SetOpacityToGameObject(fadeOpacity, fadeScreen); // Start with full black
mLoadingState = (int)LOADING_STATE.MENU_DIGIPEN;
mLoadingTimer = 0.0f;
mLoadingFirstTime = true;
}
示例6: OnStart
public void OnStart()
{
playerCamera = Common.GetStealthPlayerCamera();
#if ZERO
Cursor = GameObject.GetGameObjectByName("Mouse");
//Cursor.SetParent(gameObject);
Cursor.transform.SetPosition(0, 0, 1.7f, CTransform.TransformSpace.LOCAL);
zAxis = new Vector3(0, 0, 1);
MapScreen = GameObject.GetGameObjectByName("MapScreen").RequireComponent<CMeshRenderer>();
Plane = GameObject.GetGameObjectByName("Plane");
paperViewer = GetScript<PaperViewer>(Plane);
SurvCam = GameObject.GetGameObjectByName("Cam_Surv").RequireComponent<CCamera>();
ocuCam = GameObject.GetGameObjectByName("Cam_Oculus").RequireComponent<CCamera>();
DoorCode1 = GameObject.GetGameObjectByName("DoorCodes1");
DoorCode2 = GameObject.GetGameObjectByName("DoorCodes2");
PickCam1 = GameObject.GetGameObjectByName("PickCam1");
PickCam2 = GameObject.GetGameObjectByName("PickCam2");
PickCam3 = GameObject.GetGameObjectByName("PickCam3");
PickCam4 = GameObject.GetGameObjectByName("PickCam4");
PickCam5 = GameObject.GetGameObjectByName("PickCam5");
PickCam6 = GameObject.GetGameObjectByName("PickCam6");
PickCam1.RequireComponent<CMeshRenderer>().setEnabled(false);
PickCam2.RequireComponent<CMeshRenderer>().setEnabled(false);
PickCam3.RequireComponent<CMeshRenderer>().setEnabled(false);
PickCam4.RequireComponent<CMeshRenderer>().setEnabled(false);
PickCam5.RequireComponent<CMeshRenderer>().setEnabled(false);
PickCam6.RequireComponent<CMeshRenderer>().setEnabled(false);
Input.SetMouseLock(true);
Input.SetMouseVisible(false);
#endif
}
示例7: OnStart
public void OnStart()
{
if (gameObject.transform.GetParent() != null)
{
gameObject.transform.SetParent(null);
}
speedX = 0;
speedZ = 0;
currSpeed = speedNormal;
speedWhenJumped = 0.0f;
canJump = true;
// playerBox is actually my own gameObject
playerBox = gameObject; // GameObject.GetGameObjectByName("PlayerBoxCollider");
playerBoxMesh = playerBox.RequireComponent<CMeshRenderer>();
playerBoxMesh.setEnabled(false);
playerCamera = Common.GetStealthPlayerCamera();
playerCamScript = GetScript<FirstPersonCamera>(playerCamera);
player = Common.GetStealthPlayerMesh();
anim = player.RequireComponent<CAnimationController>();
anim.mIsPlaying = true;
playerPhysics = gameObject.RequireComponent<CPhysics>();
playerPhysics.mColliderType = 1;
idle = new State(smc, State_Idle_Enter, State_Idle_Update, State_Idle_Exit);
move = new State(smc, State_Move_Enter, State_Move_Update, State_Move_Exit);
jump = new State(smc, State_Jump_Enter, State_Jump_Update, State_Jump_Exit);
crouch = new State(smc, State_Crouch_Enter, State_Crouch_Update, State_Crouch_Exit);
sprinting = new State(smc, State_Sprinting_Enter, State_Sprinting_Update, State_Sprinting_Exit, 0.5f);
sprinting.NextState = sprinting;
notsprinting = new State(smc, State_NotSprinting_Enter, State_NotSprinting_Update, State_NotSprinting_Exit);
smc.SetState(idle);
sprint_smc.SetState(notsprinting);
footstepID = GetSoundComponent().GetUniqueEvent("P1_FOOTSTEPS.vente", 0);
}
示例8: OnStart
public void OnStart()
{
mSound = gameObject.RequireComponent<CSound>();
mSound.PlayIndependentEvent("MUSIC_HUB_LOOP.vente", false, 0);
menuPointer = GameObject.GetGameObjectByName(Common.prefix + menuPointerName);
Common.SetOpacityToGameObject(0.0f, menuPointer);
menuPointerInitPos = new Vector3(-2.75f, 1.23f, -0.11f);
menuPointer.transform.SetPosition(menuPointerInitPos);
screenImage = GameObject.GetGameObjectByName(Common.prefix + screenImageName);
screenImageMesh = screenImage.RequireComponent<CDiffuseRenderer>();
fadeScreen = GameObject.GetGameObjectByName(Common.prefix + fadeScreenName);
Common.SetOpacityToGameObject(fadeOpacity, fadeScreen); // Start with full black
Common.GetMenuFullscreenX().setEnabled(false);
Common.GetMenuMuteX().setEnabled(false);
Common.GetMenuVolumeFont().setEnabled(false);
mLoadingFirstTime = true;
mPrevMainMenuState = -1;
mMainMenuState = -1;
}
示例9: OnStart
public void OnStart()
{
sound = gameObject.RequireComponent<CSound>();
redButton = GameObject.GetGameObjectByName("redButton");
greenButton = GameObject.GetGameObjectByName("greenButton");
blueButton = GameObject.GetGameObjectByName("blueButton");
consoleScreen = Common.GetSurveillancePlayerConsoleScreen();
consoleScript = GetScript<OcuConsoleScreen>(consoleScreen);
//lights = GameObject.GetGameObjectsWithTag("phase1light");
GameObject doorObj = GameObject.GetGameObjectByName("Terminal1Door");
door1Script = GetScript<DoorMain>(doorObj);
doorObj = GameObject.GetGameObjectByName("Terminal2Door");
door2Script = GetScript<DoorMain>(doorObj);
GameObject checkpoint = GameObject.GetGameObjectByName("Checkpoint1a");
checkpointScript = GetScript<DeathCheckpointTriggerArea>(checkpoint);
chilloutFace = GameObject.GetGameObjectByName("chilloutface 1");
cFace = (chilloutFace.RequireComponent<CMeshRenderer>());
GameObject lightObj = GameObject.GetGameObjectByName("Light1a");
lightAtDoor = lightObj.RequireComponent<CLight>();
lightAtDoor.setEnabled(false);
foreach (GameObject obj in GameObject.GetGameObjectsWithTag("phase1light"))
{
lights.Add(obj.RequireComponent<CLight>());
}
sequence.Add(1); sequence.Add(3); sequence.Add(2);
if(lights.Count == 0)
{
}
geneticsAccessLeftLightObj = GameObject.GetGameObjectByName("GLD_LeftLight");
geneticsAccessLeftLight = geneticsAccessLeftLightObj.RequireComponent<CLight>();
}
示例10: InitMesh
void InitMesh()
{
if (!hasInit)
{
if (gameObject.transform.GetParent() != null)
{
hasInit = true;
camInMapIcon = gameObject.transform.GetParent().gameObject;
camInMapMesh = camInMapIcon.RequireComponent<CForwardRenderer>();
originalColor = camInMapMesh.GetMaterial().GetColor();
GameObject cameraCam = Common.GetSurveillancePlayerStaticCameraCam();
camScript = GetScript<CameraCam>(cameraCam);
ocuCam = Common.GetSurveillancePlayerCam();
sound = gameObject.RequireComponent<CSound>();
camInMapSelector = Common.GetCameraInMapSelector().RequireComponent<CForwardRenderer>();
camInMapSelector.setEnabled(false);
notActiveCamColor1 = new Color(0.1f, 0.1f, 0.1f, 1.0f);
disabledCamColor1 = new Color(SharpMocha.YELLOW);
enabledCamColor1 = new Color(SharpMocha.GREEN);
isVisible = isvisible;
isActive = isactive; // To call the set functions
if (isactive)
isEnabled = isenabled;
}
}
}
示例11: OnStart
public void OnStart()
{
geneticsAccessRightLightObj = GameObject.GetGameObjectByName("GLD_RightLight");
geneticsAccessRightLight = geneticsAccessRightLightObj.RequireComponent<CLight>();
geneticsLabDoor = GameObject.GetGameObjectByName("GeneticsLabDoor");
doorScript = GetScript<DoorMain>(geneticsLabDoor);
GameObject doorTerminal = GameObject.GetGameObjectByName("Terminal2Door");
doorTerminalScript = GetScript<DoorMain>(doorTerminal);
boobyTrapControllerObj = GameObject.GetGameObjectByName("TSR_SeqScrambler");
boobyTrapScript = GetScript<BoobyTrapControllerScript>(boobyTrapControllerObj);
GameObject triggerArea = GameObject.GetGameObjectByName("TrapTrigger");
trapAreaScript = GetScript<ConsoleSequenceInitiator>(triggerArea);
//ADD SEQUENCES MANUALLY HERE
List<int> redRoomTrapSeq = new List<int>();
redRoomTrapSeq.Add(43); redRoomTrapSeq.Add(82); redRoomTrapSeq.Add(13); redRoomTrapSeq.Add(35);
sequence.validSequence = redRoomTrapSeq;
sound = gameObject.RequireComponent<CSound>();
}