Find() public static method

public static Find ( string name ) : GameObject
name string
return GameObject
Beispiel #1
0
    void Update()
    {
        _timerBetweenNullChecks += Time.deltaTime;

        if (_timerBetweenNullChecks < 1.0f)
        {
            return;
        }

        _timerBetweenNullChecks = 0.0f;

        if (mainCanvas == null)
        {
            mainCanvas = GameObject.Find("MainCanvas_NEW");
        }

        if (gameOverCanvas == null)
        {
            gameOverCanvas = GameObject.FindWithTag("GameOverCanvas");
        }

        if (pauseMenuCanvas == null)
        {
            pauseMenuCanvas = GameObject.FindWithTag("PauseMenuCanvas");
        }
    }
Beispiel #2
0
    ///--------------------------------------------------------------------------------------
    /// <summary>
    /// 创建UI界面
    /// </summary>
    ///--------------------------------------------------------------------------------------
    public void InitFrames( )
    {
        //---------------------Lua面板---------------------------
        // 初始化 Lua 和注册各个空间的 wrap
        LuaManager.Start();

        UIRoot = GameObject.Find("UI Root");
        if (LuaManager != null)
        {
            LuaManager.DoFile("GUI/UIPanelManager");
            object[] panels = CallMethod("LuaScriptPanel");
            //---------------------Lua面板---------------------------
            foreach (object o in panels)
            {
                string name = o.ToString().Trim();
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                LuaManager.DoFile("GUI/" + name);
                //Debug.LogWarning("LoadLua---->>>>" + name + ".lua");
            }
            //------------------------------------------------------------
            CallMethod("InitUIManagerOK");
        }
    }
Beispiel #3
0
    protected virtual void Awake()
    {
        Transform = transform;
        GameObject = gameObject;
        attack = new Attack(Damage, OwnType, AimType.Foe);
        navAgent = GetComponent<NavMeshAgent>();

        if (OwnType == OwnType.Allien)
            mainTarget = GameObject.Find("planet").transform;
    }
Beispiel #4
0
        private void Start()
        {
            if (Canvas == null)
            {
                Canvas = GameObject.Find("UI");
            }
            _canvasGraphicRaycaster = Canvas.GetComponent <GraphicRaycaster>();
            _canvasEventSystem      = Canvas.GetComponent <EventSystem>();

            _eventMediator = Object.FindObjectOfType <EventMediator>();

            _eventMediator.SubscribeToEvent(CombatSceneLoaded, this);
            _eventMediator.SubscribeToEvent(PlayerTurn, this);
            _eventMediator.SubscribeToEvent(AiTurn, this);
            _eventMediator.SubscribeToEvent(EndTurn, this);

            _combatManager = FindObjectOfType <CombatManager>();
        }
Beispiel #5
0
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        if (mainCanvas == null)
        {
            mainCanvas = GameObject.Find("MainCanvas_NEW");
        }

        if (gameOverCanvas == null)
        {
            gameOverCanvas = GameObject.Find("GameOverCanvas");
        }

        if (pauseMenuCanvas == null)
        {
            pauseMenuCanvas = GameObject.Find("PauseMenuCanvas");
        }

        SetupHUD();
    }
Beispiel #6
0
        private bool MouseHitUi()
        {
            if (Canvas == null)
            {
                Canvas = GameObject.Find("UI");
            }
            _canvasGraphicRaycaster = Canvas.GetComponent <GraphicRaycaster>();
            _canvasEventSystem      = FindObjectOfType <EventSystem>();

            var pointerEventData = new PointerEventData(_canvasEventSystem)
            {
                position = Input.mousePosition
            };

            var results = new List <RaycastResult>();

            _canvasGraphicRaycaster.Raycast(pointerEventData, results);

            return(results.Any());
        }
Beispiel #7
0
    ///--------------------------------------------------------------------------------------
    /// <summary>
    /// 界面的Update逻辑
    /// </summary>
    ///--------------------------------------------------------------------------------------
    public void Update( )
    {
        if (UIRoot == null)
        {
            UIRoot = GameObject.Find("UI Root");
        }

        foreach (var item in m_mapFrame)
        {
            GUIFrame pFrame = item.Value as GUIFrame;
            if (pFrame != null && pFrame.IsLoaded() && pFrame.IsNeedUpdate)
            {
                pFrame.Update();
            }
        }

        for (int i = 0; i < m_mapDestory.Count; i++)
        {
            GUIFrame pFrame = m_mapDestory[i];
            DetachUIRoot(pFrame, true);
            pFrame.Destroy();
        }
        m_mapDestory.Clear();
    }
Beispiel #8
0
        private void SetupPosesListView(List <HVRHandPose> poses)
        {
            var posesParent = GameObject.Find("RecordedPosesCloneHolder");

            if (!posesParent)
            {
                posesParent = new GameObject("RecordedPosesCloneHolder");
            }

            foreach (Transform child in posesParent.transform)
            {
                DestroyImmediate(child.gameObject);
            }

            Poses = poses;
            var listview = _root.Q <ScrollView>("RecordedPoses");

            listview.Clear();

            foreach (var pose in poses)
            {
                var row = new VisualElement();
                row.AddToClassList("poserow");

                var field = new ObjectField("Pose:");
                field.objectType = typeof(HVRHandPose);
                field.value      = pose;
                row.Add(field);
                field.AddToClassList("poserow-field");

                var clone = Instantiate(HVRSettings.Instance.GetPoserHand(pose.SnappedLeft ? HVRHandSide.Left : HVRHandSide.Right), posesParent.transform, true);

                var posableHand = clone.GetComponent <HVRPosableHand>();
                if (posableHand != null)
                {
                    posableHand.Pose(pose);
                }

                var attach = new Button(() =>
                {
                    if (!SelectedGrabPoints)
                    {
                        EditorUtility.DisplayDialog("Error!", "Please set GrabPoints field.", "Ok!");
                        return;
                    }

                    var grabPoint = new GameObject("GrabPoint");
                    grabPoint.transform.parent        = SelectedGrabPoints.transform;
                    grabPoint.transform.localPosition = Vector3.zero;
                    var poser         = grabPoint.AddComponent <HVRHandPoser>();
                    var posable       = grabPoint.AddComponent <HVRPosableGrabPoint>();
                    posable.HandPoser = poser;
                    grabPoint.transform.localPosition = Vector3.zero;//.position = pose.SnappedLeft ? pose.LeftHand.Position : pose.RightHand.Position;
                    grabPoint.transform.localRotation = Quaternion.identity;

                    var clonedPose = posableHand.CreateFullHandPose(posableHand.MirrorAxis);

                    clonedPose.RightHand.Rotation = Quaternion.Inverse(grabPoint.transform.rotation) * clonedPose.RightHand.Rotation;
                    clonedPose.LeftHand.Rotation  = Quaternion.Inverse(grabPoint.transform.rotation) * clonedPose.LeftHand.Rotation;

                    clonedPose.RightHand.Position = Vector3.zero;
                    clonedPose.LeftHand.Position  = Vector3.zero;

                    poser.PrimaryPose      = new HVRHandPoseBlend();
                    poser.PrimaryPose.Pose = clonedPose;
                    poser.PrimaryPose.SetDefaults();

                    var grabbable = grabPoint.GetComponentInParent <HVRGrabbable>();
                    string name;
                    if (grabbable)
                    {
                        name = grabbable.name + "-" + pose.name;
                    }
                    else
                    {
                        name = DateTime.Now.Ticks.ToString();
                    }

                    poser.PrimaryPose.Pose = HVRSettings.Instance.SavePoseToDefault(clonedPose, name, "");


                    //EditorUtility.SetDirty(pose);
                    //AssetDatabase.SaveAssets();
                    //AssetDatabase.Refresh();
                })
                {
                    text = "Attach"
                };

                var delete = new Button(() =>
                {
                    row.RemoveFromHierarchy();
                    DestroyImmediate(clone);
                })
                {
                    text = "-"
                };

                var focus = new Button(() =>
                {
                    Selection.activeGameObject = clone;
                    SceneView.FrameLastActiveSceneView();
                })
                {
                    text = "Focus"
                };

                attach.AddToClassList("poserow-button");
                delete.AddToClassList("poserow-button");
                focus.AddToClassList("poserow-button");

                row.Add(focus);
                row.Add(attach);
                row.Add(delete);

                listview.Insert(listview.childCount, row);
            }
        }