• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# UICamera类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UICamera的典型用法代码示例。如果您正苦于以下问题:C# UICamera类的具体用法?C# UICamera怎么用?C# UICamera使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UICamera类属于命名空间,在下文中一共展示了UICamera类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Start

	void Start ()
	{
		mTrans = transform;
		mUITex = GetComponent<UITexture>();
		mCam = UICamera.FindCameraForLayer(gameObject.layer);

		mWidth = mUITex.width;
		mHeight = mUITex.height;
		Color[] cols = new Color[mWidth * mHeight];

		for (int y = 0; y < mHeight; ++y)
		{
			float fy = (y - 1f) / mHeight;

			for (int x = 0; x < mWidth; ++x)
			{
				float fx = (x - 1f) / mWidth;
				int index = x + y * mWidth;
				cols[index] = Sample(fx, fy);
			}
		}

		mTex = new Texture2D(mWidth, mHeight, TextureFormat.RGB24, false);
		mTex.SetPixels(cols);
		mTex.filterMode = FilterMode.Trilinear;
		mTex.wrapMode = TextureWrapMode.Clamp;
		mTex.Apply();
		mUITex.mainTexture = mTex;

		Select(value);
	}
开发者ID:ChungH,项目名称:BNG,代码行数:31,代码来源:UIColorPicker.cs


示例2: InitFuc

    /// <summary>
    /// Init all roots and configs
    /// </summary>
    void InitFuc()
    {
        
        Application.runInBackground = playInBackGround;
        Debuger.EnableLog = enableDebuger;
        manager = this.gameObject.AddComponent<SceneManager>();
        manager.cacheRoot = transform.FindChild("CacheRoot");
        manager.uiRoot = transform.FindChild("UI Root");
        manager.senceRoot = transform.FindChild("SceneRoot");
        manager.playerRoot = transform.FindChild("PlayerRoot");
        manager.ghostRoot = transform.FindChild("GhostRoot");
        uicamera = manager.uiRoot.FindChild("Camera").GetComponent<UICamera>();
        tool = this.gameObject.AddComponent<Utility>();
        connector = this.gameObject.AddComponent<Connector>();
        this.gameObject.AddComponent<CacheFactory>();
        ConfigFactory.InitResourceConfig();
        ConfigFactory.ReadSystemConfig();
        
        this.gameObject.AddComponent<ConfigInfo>();

        ConfigInfo.ReadUIRules();
        GUIManager.instance.Loading.gameObject.SetActive(true);
        GUIManager.instance.FloatMessagePanel.gameObject.SetActive(true);
        GUIManager.instance.FloatTip.gameObject.SetActive(true);

        GUIManager.LoadingPercent(10);
        ConfigInfo.Init();
        ConfigInfo.InitPreGameConfigs();
        GUIManager.FinishLoading();
        StartGame();
    }
开发者ID:xiaozhuzhaoge,项目名称:QinCloudSuper,代码行数:34,代码来源:Init.cs


示例3: Awake

    void Awake()
    {
        m_myTransform = transform;
        FillFullNameData(m_myTransform);
        m_instance = m_myTransform.GetComponentsInChildren<InstanceMissionChooseUIViewManager>(true)[0];

        m_lblSweepNum = m_myTransform.FindChild(m_widgetToFullName["InstanceLeftChallengeNum"]).GetComponentsInChildren<UILabel>(true)[0];
        m_lblResetNum = m_myTransform.FindChild(m_widgetToFullName["InstanceLeftResetNum"]).GetComponentsInChildren<UILabel>(true)[0];

        m_camInstanceMissionChooseUI = FindTransform("InstanceMissionChooseUICamera").GetComponentsInChildren<Camera>(true)[0];
        m_uicamInstanceMissionChooseUI = m_myTransform.FindChild(m_widgetToFullName["InstanceMissionChooseUICamera"]).GetComponentsInChildren<UICamera>(true)[0];
  
        m_goInstanceMissionChooseUIMapListGrid = m_myTransform.FindChild(m_widgetToFullName["InstanceMissionChooseUIMapListGrid"]).gameObject;
        m_tranInstanceMissionChooseUIPageDOT = FindTransform("InstanceMissionChooseUIPageDOT");
        m_goGOInstanceMissionChooseUI = m_myTransform.FindChild(m_widgetToFullName["GOInstanceMissionChooseUI"]).gameObject;
        m_goGOInstanceMissionChooseUI.SetActive(false);

        m_goGOInstanceMissionChooseUIMapList = FindTransform("GOInstanceMissionChooseUIMapList").gameObject;
        m_goGOInstanceMissionChooseUINormal = FindTransform("GOInstanceMissionChooseUINormal").gameObject;
        m_goGOInstanceMissionChooseUIRandom = FindTransform("GOInstanceMissionChooseUIRandom").gameObject;

        m_chooseMogoSingleButtonList = FindTransform("InstanceMissionChooseUIChoose").GetComponentsInChildren<MogoSingleButtonList>(true)[0];
        m_chooseMogoSingleButtonList.SetCurrentDownButton(0);
        m_lblInstanceMissionChooseUIChooseNormalText = FindTransform("InstanceMissionChooseUIChooseNormalText").GetComponentsInChildren<UILabel>(true)[0];
        m_lblInstanceMissionChooseUIChooseNormalTextDown = FindTransform("InstanceMissionChooseUIChooseNormalTextDown").GetComponentsInChildren<UILabel>(true)[0];
        m_lblInstanceMissionChooseUIChooseRandomText = FindTransform("InstanceMissionChooseUIChooseRandomText").GetComponentsInChildren<UILabel>(true)[0];
        m_lblInstanceMissionChooseUIChooseRandomTextDown = FindTransform("InstanceMissionChooseUIChooseRandomTextDown").GetComponentsInChildren<UILabel>(true)[0];
        m_lblInstanceMissionChooseUIRandomBtnEnterTip = FindTransform("InstanceMissionChooseUIRandomBtnEnterTip").GetComponentsInChildren<UILabel>(true)[0];

        m_spInstanceMissionChooseUIChooseRandomBGUp = FindTransform("InstanceMissionChooseUIChooseRandomBGUp").GetComponentsInChildren<UISprite>(true)[0];
        m_spInstanceMissionChooseUIChooseRandomBGDown = FindTransform("InstanceMissionChooseUIChooseRandomBGDown").GetComponentsInChildren<UISprite>(true)[0];

        m_dragCamera = m_myTransform.FindChild(m_widgetToFullName["InstanceMissionChooseUIMapListCamera"]).GetComponentsInChildren<Camera>(true)[0];
        Camera SourceCamera = GameObject.Find("MogoMainUI").transform.FindChild("Camera").GetComponentsInChildren<Camera>(true)[0];
        m_dragCamera.GetComponentsInChildren<UIViewport>(true)[0].sourceCamera = SourceCamera;

        m_dragableCameraMapList = m_dragCamera.transform.GetComponentsInChildren<MyDragableCamera>(true)[0];
        m_dragableCameraMapList.LeftArrow = FindTransform("InstanceMissionChooseUIArrowL").gameObject;
        m_dragableCameraMapList.RightArrow = FindTransform("InstanceMissionChooseUIArrowR").gameObject;

        FillNewInstanceUIChooseGridData();

        // 随机副本特效
        m_goInstanceMissionChooseUIRandomFx = FindTransform("InstanceMissionChooseUIRandomFx").gameObject;

        // ChineseData
        m_lblInstanceMissionChooseUIChooseRandomText.text = LanguageData.GetContent(46975);
        m_lblInstanceMissionChooseUIChooseRandomTextDown.text = LanguageData.GetContent(46975);
        m_lblInstanceMissionChooseUIRandomBtnEnterTip.text = LanguageData.GetContent(46976);

        Initialize();
    }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:52,代码来源:InstanceMissionChooseUIViewManager.cs


示例4: Start

    void Start()
    {
        uiCamera = GameObject.FindObjectOfType(typeof(UICamera)) as UICamera;

        // Disable standard NGUI inputs
        uiCamera.useMouse = false;
        uiCamera.useTouch = false;

        TouchManager.Instance.TouchesBegan += TouchManagerBegan;
        TouchManager.Instance.TouchesMoved += TouchManagerMoved;
        TouchManager.Instance.TouchesEnded += TouchManagerEnded;
        TouchManager.Instance.TouchesCancelled += TouchManagerCancelled;
    }
开发者ID:liuxiangchong100,项目名称:TouchScriptNGUI,代码行数:13,代码来源:TouchScriptNGUI.cs


示例5: PreCreate

	private static void PreCreate ()
	{
		if (m_uiRoot == null)
		{
			int uiLayer = LayerMask.NameToLayer("UI");

			m_uiRootObj = new GameObject("UI Root(2D)");
			m_uiRootObj.layer = uiLayer;

			UIRoot uiRoot = m_uiRootObj.AddComponent<UIRoot>();
			{
				uiRoot.scalingStyle = UIRoot.Scaling.FixedSize;

				if ((Double)Screen.width / Screen.height < 1.49)
					uiRoot.manualHeight = 768;
				else
					uiRoot.manualHeight = 640;

			}

			m_cameraObj = new GameObject("Camera");
			m_cameraObj.transform.parent = m_uiRootObj.transform;

			m_camera = m_cameraObj.AddComponent<Camera>();
			{
				float depth = -1f;

				m_camera.gameObject.layer = uiLayer;
				m_camera.depth = depth + 1;
				m_camera.backgroundColor = Color.black;
				m_camera.cullingMask = 1 << uiLayer;

				//Use Simple2D Camera
				m_camera.orthographicSize = 1f;
				m_camera.orthographic = true;
				m_camera.nearClipPlane = -2f;
				m_camera.farClipPlane = 2f;
				m_camera.gameObject.AddComponent<UICamera>();

				//m_camera.gameObject.AddComponent<UITick>();
			}

			m_uiCamera = m_cameraObj.AddComponent<UICamera>();

			m_uiRootObj.AddComponent<UIPanel>();

			m_uiRoot = uiRoot;
		}
	}
开发者ID:fengqk,项目名称:Art,代码行数:49,代码来源:GUIRoot.cs


示例6: Start

	public override void Start()
	{
		base.Start();
		_nguiCamera = NguiUtils.GetComponentInParents<UICamera>(gameObject);
		var anchor = NguiUtils.GetComponentInParents<UIAnchor>(gameObject);
		if (anchor == null)
		{
			Debug.LogWarning("There have to be an UIAnchor upper in the hierarchy");
			return;
		}
		if (anchor.side != UIAnchor.Side.BottomLeft &&
			anchor.side != UIAnchor.Side.BottomRight &&
			anchor.side != UIAnchor.Side.TopLeft &&
			anchor.side != UIAnchor.Side.TopRight)
		{
			Debug.LogWarning("Parent UIAnchor have to be a corner one (BottomLeft, BottomRight, TopLeft or TopRight)");
		}
		_anchor = anchor.transform;
	}
开发者ID:Niller,项目名称:LastStand,代码行数:19,代码来源:NguiProjectedPositionBinding.cs


示例7: CreateUIRoot

    void CreateUIRoot()
    {
        GameObject uiRootobj = new GameObject("UIRoot");
        UiRoot = uiRootobj.AddComponent<UIRoot>();
        CBase.Assert(UiRoot);
        UiRoot.scalingStyle = UIRoot.Scaling.ConstrainedOnMobiles;
        UiRoot.manualHeight = 1920;

        GameObject panelRootObj = new GameObject("PanelRoot");
        CTool.SetChild(panelRootObj.transform, uiRootobj.transform);

        Transform panelTrans = panelRootObj.transform;
        PanelRoot = panelRootObj.AddComponent<UIPanel>();
        CBase.Assert(PanelRoot);

        GameObject uiCamObj = new GameObject("UICamera");
        CTool.SetChild(uiCamObj.transform, UiRoot.transform);
        UiCamera = uiCamObj.AddComponent<UICamera>();
        UiCamera.cachedCamera.cullingMask = 1 << (int)CLayerDef.UI;
        UiCamera.cachedCamera.clearFlags = CameraClearFlags.Depth;
        UiCamera.cachedCamera.orthographic = true;
        UiCamera.cachedCamera.orthographicSize = 1;
        UiCamera.cachedCamera.nearClipPlane = -2;
        UiCamera.cachedCamera.farClipPlane = 2;
        //panelTrans.gameObject.isStatic = true;

        foreach (UIAnchor.Side side in Enum.GetValues(typeof(UIAnchor.Side)))
        {
            GameObject anchorObj = new GameObject(side.ToString());
            CTool.SetChild(anchorObj.transform, panelTrans);
            AnchorSide[side.ToString()] = anchorObj.transform;
        }

        GameObject nullAnchor = new GameObject("Null");
        CTool.SetChild(nullAnchor.transform, panelTrans);
        AnchorSide["Null"] = nullAnchor.transform;
        AnchorSide[""] = AnchorSide[UIAnchor.Side.Center.ToString()]; // default

        NGUITools.SetLayer(uiRootobj, (int)CLayerDef.UI);

    }
开发者ID:mr-kelly,项目名称:ProjectWeak,代码行数:41,代码来源:CNGUIBridge.cs


示例8: Awake

    void Awake()
    {
        Instance = this;

        currentMenu = MenuType.Main;
        
        Transform UIRoot = transform.FindChild("UI Root");
      
        MainCamera = UIRoot.FindChild("Camera").GetComponent<UICamera>();
        MainCamera.enabled = true;
        MainCamera.GetComponent<Camera>().enabled = true;
        
        // Get transforms for each menu
        MainMenu        = UIRoot.FindChild("Main Menu");
        SettingsMenu    = UIRoot.FindChild("Settings Menu");
        LeaderboardMenu = UIRoot.FindChild("Leaderboard Menu");
        GameMenu        = UIRoot.FindChild("Game Menu");
        CustomizeMenu       = UIRoot.FindChild("Customize Menu");
        
        ToggleMenusOn();
    }
开发者ID:Kurukshetran,项目名称:Gravity,代码行数:21,代码来源:Manager_Menu.cs


示例9: OnEnable

	void OnEnable() {
		Time.timeScale = PAUSED_TIME_SCALE;
		GameObject uiRoot = GameObject.Find("UI Root");
		if(uiRoot!=null) {
			UICamera camera = uiRoot.GetComponentInChildren<UICamera>();
			if(camera!=null) {
				camera.eventType = UICamera.EventType.UI_3D;
				cameraRef = camera;	
				if(Application.loadedLevelName=="Garage") {
					blur = camera.GetComponent<CC_RadialBlur>();
					if(blur==null) {
						blur = camera.gameObject.AddComponent<CC_RadialBlur>();
					}
					blur.enabled = true;
			/*		analogTV = camera.GetComponent<CC_AnalogTV>();
					if(analogTV==null) {
						analogTV = camera.gameObject.AddComponent<CC_AnalogTV>();
					}*/
					//analogTV.enabled = true;
				}
			}
		}
	}
开发者ID:cupsster,项目名称:gtmanager,代码行数:23,代码来源:NGUIDisabler.cs


示例10: ChangeSelection

	/// <summary>
	/// Selection change is delayed on purpose. This way selection changes during event processing won't cause
	/// the newly selected widget to continue processing when it is it's turn. Example: pressing 'tab' on one
	/// button selects the next button, and then it also processes its 'tab' in turn, selecting the next one.
	/// </summary>

	System.Collections.IEnumerator ChangeSelection ()
	{
		yield return new WaitForEndOfFrame();
		mCurrentSelection = mNextSelection;
		mNextSelection = null;

		if (mCurrentSelection != null)
		{
			current = this;
			currentCamera = mCam;
			UICamera.currentScheme = mNextScheme;
			Notify(mCurrentSelection, "OnSelect", true);
			current = null;
		}
	}
开发者ID:10people,项目名称:UnityLibrary,代码行数:21,代码来源:UICamera.cs


示例11: SetSelection

	/// <summary>
	/// Change the selection.
	/// </summary>

	static protected void SetSelection (GameObject go, ControlScheme scheme)
	{
		if (mNextSelection != null)
		{
			mNextSelection = go;
		}
		else if (mCurrentSelection != go)
		{
			if (mCurrentSelection != null)
			{
				UICamera uicam = FindCameraForLayer(mCurrentSelection.layer);

				if (uicam != null)
				{
					current = uicam;
					currentCamera = uicam.mCam;
					UICamera.currentScheme = scheme;
					Notify(mCurrentSelection, "OnSelect", false);
					current = null;
				}
			}

			mCurrentSelection = null;
			mNextSelection = go;
			mNextScheme = scheme;

			if (UICamera.list.size > 0)
			{
				UICamera cam = (mNextSelection != null) ? FindCameraForLayer(mNextSelection.layer) : UICamera.list[0];
				if (cam != null) cam.StartCoroutine(cam.ChangeSelection());
			}
		}
	}
开发者ID:10people,项目名称:UnityLibrary,代码行数:37,代码来源:UICamera.cs


示例12: IsVisible

 private static bool IsVisible(ref UICamera.DepthEntry de)
 {
     UIPanel uIPanel = NGUITools.FindInParents<UIPanel>(de.go);
     while (uIPanel != null)
     {
         if (!uIPanel.IsVisible(de.point))
         {
             return false;
         }
         uIPanel = uIPanel.parentPanel;
     }
     return true;
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:13,代码来源:UICamera.cs


示例13: Awake

 void Awake()
 {
     uiCamera = GetComponent<UICamera>();
 }
开发者ID:LAB75JP,项目名称:pixelsense_game,代码行数:4,代码来源:UICameraW7Touch.cs


示例14: ChangeSelection

	/// <summary>
	/// Selection change is delayed on purpose. This way selection changes during event processing won't cause
	/// the newly selected widget to continue processing when it is it's turn. Example: pressing 'tab' on one
	/// button selects the next button, and then it also processes its 'tab' in turn, selecting the next one.
	/// </summary>

	System.Collections.IEnumerator ChangeSelection ()
	{
		yield return new WaitForEndOfFrame();
		Notify(mCurrentSelection, "OnSelect", false);
		mCurrentSelection = mNextSelection;
		mNextSelection = null;

		if (mCurrentSelection != null)
		{
			current = this;
			currentCamera = mCam;
			UICamera.currentScheme = mNextScheme;
			inputHasFocus = (mCurrentSelection.GetComponent<UIInput>() != null);
			Notify(mCurrentSelection, "OnSelect", true);
			current = null;
		}
		else inputHasFocus = false;
	}
开发者ID:satela,项目名称:xjhU3d,代码行数:24,代码来源:UICamera.cs


示例15: Update

	/// <summary>
	/// Update the text based on input.
	/// </summary>
	
	protected virtual void Update ()
	{
#if UNITY_EDITOR
		if (!Application.isPlaying) return;
#endif
		if (!isSelected || mSelectTime == Time.frameCount) return;

		if (mDoInit) Init();
#if MOBILE
		// Wait for the keyboard to open. Apparently mKeyboard.active will return 'false' for a while in some cases.
		if (mWaitForKeyboard)
		{
			if (mKeyboard != null && !mKeyboard.active) return;
			mWaitForKeyboard = false;
		}
#endif
		// Unity has issues bringing up the keyboard properly if it's in "hideInput" mode and you happen
		// to select one input in the same Update as de-selecting another.
		if (mSelectMe != -1 && mSelectMe != Time.frameCount)
		{
			mSelectMe = -1;
			mSelectionEnd = string.IsNullOrEmpty(mValue) ? 0 : mValue.Length;
			mDrawStart = 0;
			mSelectionStart = selectAllTextOnFocus ? 0 : mSelectionEnd;
			label.color = activeTextColor;
#if MOBILE
			RuntimePlatform pf = Application.platform;
			if (pf == RuntimePlatform.IPhonePlayer
				|| pf == RuntimePlatform.Android
				|| pf == RuntimePlatform.WP8Player
 #if UNITY_4_3
				|| pf == RuntimePlatform.BB10Player
 #else
				|| pf == RuntimePlatform.BlackBerryPlayer
				|| pf == RuntimePlatform.MetroPlayerARM
				|| pf == RuntimePlatform.MetroPlayerX64
				|| pf == RuntimePlatform.MetroPlayerX86
 #endif
			)
			{
				string val;
				TouchScreenKeyboardType kt;

				if (inputShouldBeHidden)
				{
					TouchScreenKeyboard.hideInput = true;
					kt = (TouchScreenKeyboardType)((int)keyboardType);
 #if UNITY_METRO
					val = "";
 #else
					val = "|";
 #endif
				}
				else if (inputType == InputType.Password)
				{
					TouchScreenKeyboard.hideInput = false;
					kt = TouchScreenKeyboardType.Default;
					val = mValue;
					mSelectionStart = mSelectionEnd;
				}
				else
				{
					TouchScreenKeyboard.hideInput = false;
					kt = (TouchScreenKeyboardType)((int)keyboardType);
					val = mValue;
					mSelectionStart = mSelectionEnd;
				}

				mWaitForKeyboard = true;
				mKeyboard = (inputType == InputType.Password) ?
					TouchScreenKeyboard.Open(val, kt, false, false, true) :
					TouchScreenKeyboard.Open(val, kt, !inputShouldBeHidden && inputType == InputType.AutoCorrect,
						label.multiLine && !hideInput, false, false, defaultText);
 #if UNITY_METRO
				mKeyboard.active = true;
 #endif
			}
			else
#endif // MOBILE
			{
				Vector2 pos = (UICamera.current != null && UICamera.current.cachedCamera != null) ?
					UICamera.current.cachedCamera.WorldToScreenPoint(label.worldCorners[0]) :
					label.worldCorners[0];
				pos.y = Screen.height - pos.y;
				Input.imeCompositionMode = IMECompositionMode.On;
				Input.compositionCursorPos = pos;
			}

			UpdateLabel();
			if (string.IsNullOrEmpty(Input.inputString)) return;
		}
#if MOBILE
		if (mKeyboard != null)
		{
 #if UNITY_METRO
			string text = Input.inputString;
//.........这里部分代码省略.........
开发者ID:dev-celvin,项目名称:DK,代码行数:101,代码来源:UIInput.cs


示例16: CompareFunc

	/// <summary>
	/// Static comparison function used for sorting.
	/// </summary>

	static int CompareFunc (UICamera a, UICamera b)
	{
		if (a.cachedCamera.depth < b.cachedCamera.depth) return 1;
		if (a.cachedCamera.depth > b.cachedCamera.depth) return -1;
		return 0;
	}
开发者ID:OvertimeStudios,项目名称:CreepyBuster,代码行数:10,代码来源:UICamera.cs


示例17: Start

 // Use this for initialization
 void Start()
 {
     cam_Comp = GetComponent<UICamera>();
 }
开发者ID:HuvaaKoodia,项目名称:SummerProject2013,代码行数:5,代码来源:MenuHandler.cs


示例18: Start

	public void Start()
	{
		if(CNetwork.IsServer)
		{
			// Offset its position
			gameObject.GetComponent<CNetworkView>().SetPosition(new Vector3(0.0f, 0.0f, s_UIOffset));
			gameObject.GetComponent<CNetworkView>().SetEulerAngles(Quaternion.identity.eulerAngles);

			if(m_DUICamera3D != null)
			{
				m_Cached3DCamera = m_DUICamera3D.GetComponent<UICamera>();
				m_Cached3DCamera.m_IsDUI = true;
			}
			
			if(m_DUICamera2D != null)
			{
				m_Cached2DCamera = m_DUICamera2D.GetComponent<UICamera>();
				m_Cached2DCamera.m_IsDUI = true;
			}

			// Increment the offset
			s_UIOffset += 10.0f;
		}
	}
开发者ID:nulhax,项目名称:VOID,代码行数:24,代码来源:CDUIRoot.cs


示例19: CreateUIRoot

    //void CreateUGUI()
    //{
    //    var canvasObj = new GameObject("UICanvas");
    //    UICanvas = canvasObj.AddComponent<Canvas>();
    //    UICanvas.renderMode = RenderMode.ScreenSpaceOverlay;
    //    //UICanvas.worldCamera = UiCamera.cachedCamera;
    //    canvasObj.AddComponent<GraphicRaycaster>();
    //    var scaler = canvasObj.AddComponent<CanvasScaler>();
    //    scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;  // 屏幕固定大小
    //    scaler.referenceResolution = new Vector2(1080, 1920);
    //    var evtSysObj = new GameObject("EventSystem");
    //    KTool.SetChild(evtSysObj, canvasObj);
    //    evtSysObj.AddComponent<EventSystem>();
    //}
    private void CreateUIRoot()
    {
        GameObject uiRootobj = GameObject.Find("NGUIRoot") ?? new GameObject("NGUIRoot");
        UiRoot = uiRootobj.GetComponent<UIRoot>() ?? uiRootobj.AddComponent<UIRoot>();
        Debuger.Assert(UiRoot);
        UiRoot.scalingStyle = UIRoot.Scaling.FixedSizeOnMobiles;

        // 尝试将NGUI转化成跟2dToolkit镜头一致显示
        UiRoot.manualHeight = 1080;
        //GameDef.ScreenPixelY;//(int)(GameDef.ScreenPixelY / (GameDef.ScreenPixelY / 2f / GameDef.DefaultPixelPerMeters)); // fit width!
        //UiRoot.manualWidth = 1920;//GameDef.ScreenPixelX;

        // 屏幕中间位置
        //UiRoot.transform.localPosition = new Vector3(GameDef.ScreenPixelX / 2f / GameDef.DefaultPixelPerMeters,
        //    GameDef.ScreenPixelY / 2f / GameDef.DefaultPixelPerMeters, -50);
        //var scale = 1 / GameDef.DefaultPixelPerMeters;
        //// 覆盖NGUI的Uiroot自动缩放
        //UiRoot.transform.localScale = new Vector3(scale, scale, scale);
        //UiRoot.enabled = false;

        GameObject panelRootObj = new GameObject("PanelRoot");
        KTool.SetChild(panelRootObj.transform, uiRootobj.transform);

        Transform panelTrans = panelRootObj.transform;
        PanelRoot = panelRootObj.AddComponent<UIPanel>();
        Debuger.Assert(PanelRoot);
        PanelRoot.generateNormals = true;

        var uiCamTrans = uiRootobj.transform.Find("UICamera");
        GameObject uiCamObj = uiCamTrans != null ? uiCamTrans.gameObject : new GameObject("UICamera");

        KTool.SetChild(uiCamObj.transform, UiRoot.transform);
        UiCamera = uiCamObj.GetComponent<UICamera>() ?? uiCamObj.AddComponent<UICamera>();
        UiCamera.cachedCamera.cullingMask = 1 << (int)UnityLayerDef.UI;
        UiCamera.cachedCamera.clearFlags = CameraClearFlags.Depth;
        UiCamera.cachedCamera.orthographic = true;
        UiCamera.cachedCamera.orthographicSize = GameDef.ScreenPixelY / GameDef.DefaultPixelPerMeters / 2f;
        // 9.6,一屏19.2米,跟GameCamera一致
        UiCamera.cachedCamera.nearClipPlane = -500;
        UiCamera.cachedCamera.farClipPlane = 500;

        foreach (UIAnchor.Side side in Enum.GetValues(typeof(UIAnchor.Side)))
        {
            GameObject anchorObj = new GameObject(side.ToString());
            KTool.SetChild(anchorObj.transform, panelTrans);
            AnchorSide[side.ToString()] = anchorObj.transform;
        }

        GameObject nullAnchor = new GameObject("Null");
        KTool.SetChild(nullAnchor.transform, panelTrans);
        AnchorSide["Null"] = nullAnchor.transform;
        AnchorSide[""] = AnchorSide[UIAnchor.Side.Center.ToString()]; // default

        NGUITools.SetLayer(uiRootobj, (int)UnityLayerDef.UI);

        PressWidget = new GameObject("PressWidget").AddComponent<UIWidget>();
        NGUITools.SetLayer(PressWidget.gameObject, (int)UnityLayerDef.UI);
        KTool.SetChild(PressWidget.gameObject, panelRootObj);
        PressWidget.SetDimensions(2000, 2000);
        var col = PressWidget.gameObject.AddComponent<BoxCollider>();
        col.size = new Vector3(2000, 2000);
        PressWidget.autoResizeBoxCollider = true;
        PressWidget.gameObject.SetActive(false);
        //UICamera.onDragStart = (go) =>
        //{
        //    if (go != null)  // 点击任意NGUI控件,出现阻挡
        //        PressWidget.gameObject.SetActive(true);
        //};
        //UICamera.onPress = (go, state) =>
        //{
        //    if (!state)  // 点击任意NGUI控件,出现阻挡
        //        PressWidget.gameObject.SetActive(false);

        //    //if (go != null)
        //    //{
        //    //    if (go.GetComponent<UIButton>() == null)
        //    //    {
        //    //        if (go.GetComponent<UIEventListener>() != null && go.GetComponent<UISprite>() != null)
        //    //        {
        //    //            if (Debug.isDebugBuild)
        //    //            {
        //    //                Debug.LogWarning("自动加UIButton和ButtonScale - " + go.name, go);
        //    //            }
        //    //            // 当不包含ButtonScale动画
        //    //            // 并且拥有EventListener和UISprite!
        //    //            // 统一加上ButtonScale!
//.........这里部分代码省略.........
开发者ID:mr-kelly,项目名称:KEngine,代码行数:101,代码来源:KNGUIBridge.cs


示例20: Awake

	void Awake()
	{
		myCamera = GetComponent<UICamera>();
		originalLayerMask = myCamera.eventReceiverMask;
	}
开发者ID:JulyMars,项目名称:frozen_free_fall,代码行数:5,代码来源:UICameraInputEnabler.cs



注:本文中的UICamera类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UICollectionView类代码示例发布时间:2022-05-24
下一篇:
C# UIButton类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap