コード例 #1
0
 public void Awake()
 {
     m_textMesh = GetComponent<TextMesh>();
     bool shouldDisable = m_disableWhilePlaying && !(Application.isEditor && !Application.isPlaying);
     this.enabled = !shouldDisable;
     if (!m_disableWhilePlaying && m_maxWidth > 0.0f)
     {
         UpdateText();
     }
 }
コード例 #2
0
 void InitalizeMesh()
 {
     mesh = gameObject.GetComponent<TextMesh>();
     if (mesh == null)
     {
         mesh = gameObject.AddComponent<TextMesh>();
     }
     controller = gameObject.GetComponent<TextMeshController>();
     if (controller == null)
     {
         controller = gameObject.AddComponent<TextMeshController>();
     }
 }
コード例 #3
0
 protected void MakeTextObject()
 {
     meshGO = Load("Prefabs/Desc Text", transform, new Vector3(0.0f, 0.0f, -4.0f)) as GameObject;
     if (meshGO == null)
     {
     return;
     }
     mesh = meshGO.GetComponentInChildren<TextMesh>();
     background = meshGO.GetComponentInChildren<SpriteRenderer>();
     background.transform.localScale = backgroundScale;
     scale = transform.localScale;
     meshGO.transform.localScale = new Vector3(scale.x, 0.00001f, scale.z);
     meshGO.layer = gameObject.layer;
     foreach (Transform child in meshGO.transform)
     {
     child.gameObject.layer = gameObject.layer;
     }
 }
コード例 #4
0
 /// <summary>
 /// Runs at initialization right after Awake method
 /// </summary>
 private void Start()
 {
     trainingUI_TextMesh = SceneOrganiser.Instance.CreateTrainingUI("TrainingUI", 0.04f, 0, 4, false);
 }
コード例 #5
0
 // Use this for initialization
 void Start()
 {
     Counter = GetComponent <TextMesh>();
 }
コード例 #6
0
 void Start()
 {
     mMesh = GetComponent <TextMesh>();
     StartCoroutine(DelayedInput());
 }
コード例 #7
0
 public static void SetTextMeshAlpha(TextMesh textMesh, float alpha)
 {
     textMesh.color = new Color(textMesh.color.r, textMesh.color.g, textMesh.color.b, alpha);
 }
コード例 #8
0
 // Use this for initialization
 void Start()
 {
     manager = GetComponentInParent <unitAgent> ();
     text    = GetComponent <TextMesh> ();
 }
コード例 #9
0
 // Use this for initialization
 void Start()
 {
     m_attachedText = gameObject.GetComponent <TextMesh>();
     growing        = true;
 }
コード例 #10
0
 public RenameAction(TextMesh textMesh)
 {
     this.textMesh = textMesh;
     this.oldName  = textMesh.text;
 }
コード例 #11
0
            public void AppendOneToAnother()
            {
                const int elementCount0 = 3;
                const int elementCount1 = 6;

                var mesh = new TextMesh();

                mesh.Commands.Add(new DrawCommand {
                    ElemCount = elementCount0
                });
                mesh.PrimReserve(3, 3);
                mesh.AppendIndex(0);
                mesh.AppendIndex(1);
                mesh.AppendIndex(2);
                mesh.AppendVertex(new DrawVertex {
                    pos = new Point(0, 0)
                });
                mesh.AppendVertex(new DrawVertex {
                    pos = new Point(1, 0)
                });
                mesh.AppendVertex(new DrawVertex {
                    pos = new Point(2, 0)
                });

                var meshToAppend = new TextMesh();

                meshToAppend.Commands.Add(new DrawCommand {
                    ElemCount = elementCount1
                });
                meshToAppend.PrimReserve(6, 3);
                meshToAppend.AppendIndex(0);
                meshToAppend.AppendIndex(1);
                meshToAppend.AppendIndex(2);
                meshToAppend.AppendIndex(1);
                meshToAppend.AppendIndex(2);
                meshToAppend.AppendIndex(0);
                meshToAppend.AppendVertex(new DrawVertex {
                    pos = new Point(3, 0)
                });
                meshToAppend.AppendVertex(new DrawVertex {
                    pos = new Point(4, 0)
                });
                meshToAppend.AppendVertex(new DrawVertex {
                    pos = new Point(5, 0)
                });

                mesh.Append(meshToAppend, Vector.Zero);

                Assert.Single(mesh.Commands);
                Assert.Equal(elementCount0 + elementCount1, mesh.Commands[0].ElemCount);

                Assert.Equal(6, mesh.VertexBuffer.Count);
                Assert.Equal(9, mesh.IndexBuffer.Count);

                Assert.Equal(3, mesh.IndexBuffer[3]);
                Assert.Equal(4, mesh.IndexBuffer[4]);
                Assert.Equal(5, mesh.IndexBuffer[5]);
                Assert.Equal(4, mesh.IndexBuffer[6]);
                Assert.Equal(5, mesh.IndexBuffer[7]);
                Assert.Equal(3, mesh.IndexBuffer[8]);

                Assert.Equal(0, mesh.VertexBuffer[0].pos.x);
                Assert.Equal(1, mesh.VertexBuffer[1].pos.x);
                Assert.Equal(2, mesh.VertexBuffer[2].pos.x);
                Assert.Equal(3, mesh.VertexBuffer[3].pos.x);
                Assert.Equal(4, mesh.VertexBuffer[4].pos.x);
                Assert.Equal(5, mesh.VertexBuffer[5].pos.x);
            }
コード例 #12
0
 // Use this for initialization
 void Start()
 {
     _textmesh          = GetComponent <TextMesh> ();
     _textmesh.richText = true;
     _textmesh.text     = "Coins: 0 \nKey: 0 \nDoor Close";
 }
コード例 #13
0
 public void Reset()
 {
     text = GetComponent <TextMesh>();
 }
コード例 #14
0
    public void ForceUpdate()
    {
        if (_meshRenderer == null)
        {
            _material     = null;
            _meshRenderer = this.gameObject.GetComponent <MeshRenderer>();
        }
        if (_textMesh == null)
        {
            _textMesh = this.gameObject.GetComponent <TextMesh>();
        }

        if (_meshRenderer != null)
        {
            _material = _meshRenderer.sharedMaterial;
        }

        string shaderName = _shaderName;

        if (_material == null || _material.shader == null || _material.shader.name != shaderName)
        {
            if (_textMesh != null && _textMesh.font != null)
            {
                if (this.shaderType == ShaderType.Normal)
                {
                    _material = _textMesh.font.material;
                }
                else
                {
                    _material        = _textMesh.font.material;
                    _material.shader = Shader.Find(shaderName);
                }
                if (_meshRenderer != null)
                {
                    _meshRenderer.sharedMaterial = _material;
                }
            }
        }

        if (_material != null && _material.shader != null && _material.shader.name == ShaderName_Outline)
        {
            Texture mainTexture = _material.mainTexture;
            if (mainTexture != null && _textMesh != null)
            {
                Texture2D mainTexture2D = mainTexture as Texture2D;
                if (mainTexture2D != null)
                {
                    float fontSize = (float)_textMesh.fontSize;
                    float width    = Mathf.Max((float)mainTexture2D.width, 1.0f);
                    float height   = Mathf.Max((float)mainTexture2D.height, 1.0f);

                    float shader_outerThickness = this.outerThickness * 0.005f;

                    Vector4 shader_innerThickness = new Vector4(
                        this.innerThickness * 0.005f * fontSize / width,
                        this.innerThickness * 0.005f * fontSize / height,
                        0.0f, 0.0f);

                    if (_cached_outlineColor != this.outlineColor)
                    {
                        _cached_outlineColor = this.outlineColor;
                        if (_material.GetColor("_OutlineColor") != this.outlineColor)
                        {
                            _material.SetColor("_OutlineColor", this.outlineColor);
                        }
                    }
                    if (_cached_outerThickness != shader_outerThickness)
                    {
                        _cached_outerThickness = shader_outerThickness;
                        if (_material.GetFloat("_OuterThickness") != shader_outerThickness)
                        {
                            _material.SetFloat("_OuterThickness", shader_outerThickness);
                        }
                    }
                    if (_cached_innerThickness != shader_innerThickness)
                    {
                        _cached_innerThickness = shader_innerThickness;
                        if (_material.GetVector("_InnerThickness") != shader_innerThickness)
                        {
                            _material.SetVector("_InnerThickness", shader_innerThickness);
                        }
                    }
                }
            }
        }
    }
コード例 #15
0
ファイル: Benchmark02.cs プロジェクト: Mucsi20/Demigod-Stuff
        void Start()
        {
            for (int i = 0; i < NumberOfNPC; i++)
            {
                if (SpawnType == 0)
                {
                    // TextMesh Pro Implementation
                    GameObject go = new GameObject();
                    go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f));

                    TextMeshPro textMeshPro = go.AddComponent <TextMeshPro>();

                    textMeshPro.autoSizeTextContainer = true;
                    textMeshPro.rectTransform.pivot   = new Vector2(0.5f, 0);

                    textMeshPro.alignment     = TextAlignmentOptions.Bottom;
                    textMeshPro.fontSize      = 96;
                    textMeshPro.enableKerning = false;

                    textMeshPro.color = new Color32(255, 255, 0, 255);
                    textMeshPro.text  = "!";
                    textMeshPro.isTextObjectScaleStatic = true;

                    // Spawn Floating Text
                    floatingText_Script           = go.AddComponent <TextMeshProFloatingText>();
                    floatingText_Script.SpawnType = 0;
                }
                else if (SpawnType == 1)
                {
                    // TextMesh Implementation
                    GameObject go = new GameObject();
                    go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f));

                    TextMesh textMesh = go.AddComponent <TextMesh>();
                    textMesh.font = Resources.Load <Font>("Fonts/ARIAL");
                    textMesh.GetComponent <Renderer>().sharedMaterial = textMesh.font.material;

                    textMesh.anchor   = TextAnchor.LowerCenter;
                    textMesh.fontSize = 96;

                    textMesh.color = new Color32(255, 255, 0, 255);
                    textMesh.text  = "!";

                    // Spawn Floating Text
                    floatingText_Script           = go.AddComponent <TextMeshProFloatingText>();
                    floatingText_Script.SpawnType = 1;
                }
                else if (SpawnType == 2)
                {
                    // Canvas WorldSpace Camera
                    GameObject go     = new GameObject();
                    Canvas     canvas = go.AddComponent <Canvas>();
                    canvas.worldCamera = Camera.main;

                    go.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                    go.transform.position   = new Vector3(Random.Range(-95f, 95f), 5f, Random.Range(-95f, 95f));

                    TextMeshProUGUI textObject = new GameObject().AddComponent <TextMeshProUGUI>();
                    textObject.rectTransform.SetParent(go.transform, false);

                    textObject.color     = new Color32(255, 255, 0, 255);
                    textObject.alignment = TextAlignmentOptions.Bottom;
                    textObject.fontSize  = 96;
                    textObject.text      = "!";

                    // Spawn Floating Text
                    floatingText_Script           = go.AddComponent <TextMeshProFloatingText>();
                    floatingText_Script.SpawnType = 0;
                }
            }
        }
コード例 #16
0
ファイル: StatusText.cs プロジェクト: Koolschrank/TypingGame
 private void Start()
 {
     _animator      = GetComponent <Animator>();
     _textMesh      = GetComponentInChildren <TextMesh>();
     _textMesh.text = _text;
 }
コード例 #17
0
ファイル: UI.cs プロジェクト: ReasonMakes/bunting-sky
    private string GetDistanceAndDeltaVUI(GameObject subject, bool isStation)
    {
        Transform playerTransform  = control.generation.instancePlayer.transform.GetChild(0);
        Transform subjectTransform = subject.transform;
        Vector3   playerVelocity   = playerTransform.GetComponent <Rigidbody>().velocity;

        //Distance
        float  conversionRatioUnitsToMetres = 4f; //1 Unity unit = 4 metres
        float  distance        = Vector3.Distance(subjectTransform.position, playerTransform.position) * conversionRatioUnitsToMetres;
        string distanceDisplay = " ?, ";

        if (distance < 1e3f)
        {
            distanceDisplay = Mathf.RoundToInt(distance) + " m";
        }
        else if (distance >= 1e3f)
        {
            distanceDisplay = (distance * 1e-3f).ToString("F2") + " km";
        }
        else if (distance >= 1e6f)
        {
            distanceDisplay = (distance * 1e-6f).ToString("F2") + " Mm";
        }
        else if (distance >= 1e9f)
        {
            distanceDisplay = (distance * 3.33564e-9f).ToString("F2") + " lightsecond";
        }
        else if (distance >= 5.5594e11f)
        {
            distanceDisplay = (distance * 5.5594e-11f).ToString("F2") + " lightminute";
        }
        else if (distance >= 1.057e16f)
        {
            distanceDisplay = (distance * 1.057e-16f).ToString("F2") + " lightyear";
        }

        //DeltaV
        Vector3 subjectVelocity;

        if (isStation)
        {
            subjectVelocity = subjectTransform.GetComponent <StationOrbit>().planetoidToOrbit.GetComponent <Rigidbody>().velocity;
        }
        else
        {
            subjectVelocity = subjectTransform.GetComponent <Rigidbody>().velocity;
        }
        float deltaV = (subjectVelocity - playerVelocity).magnitude;

        //DeltaV direction sign
        Vector3 signPlayerPosition = Vector3.zero; //playerTransform.position - playerTransform.position = 0
        Vector3 signHitPosition    = subjectTransform.position - playerTransform.position;
        Vector3 signPlayerVelocity = Vector3.zero; //playerVelocity - playerVelocity = 0
        Vector3 signHitVelocity    = subjectVelocity - playerVelocity;
        float   signDotProduct     = Vector3.Dot(
            signHitVelocity - signPlayerVelocity,
            signHitPosition - signPlayerPosition
            );
        string signPrint;

        if (signDotProduct > 0 && deltaV >= 1f)
        {
            signPrint = "-";
        }
        else if (signDotProduct < 0 && deltaV >= 1f)
        {
            signPrint = "+";
        }
        else
        {
            signPrint = "";
        }

        //Concatenate
        string deltaVDisplay = signPrint + (int)deltaV + " Δv";

        //Update console
        TextMesh consoleTargetInfoText = control.generation.instancePlayer.transform.Find("Body").Find("FP Model").Find("Interior").Find("Display Strut Right").Find("Target Info Text").GetComponent <TextMesh>();

        consoleTargetInfoText.text = distanceDisplay + "\n" + deltaVDisplay;

        //Return (for waypoint)
        return(distanceDisplay + ", " + deltaVDisplay);
    }
コード例 #18
0
 private bool getEnabled(TextMesh textMesh)
 {
     return(textMesh != null ? textMesh.gameObject.activeSelf : false);
 }
コード例 #19
0
ファイル: TextBattery.cs プロジェクト: ly774508966/airos
 // Use this for initialization
 void Start()
 {
     txt = gameObject.GetComponent <TextMesh>();
     Debug.Log("Text:" + txt + ";" + txt.text);
 }
コード例 #20
0
    public void OnPointerClick(PointerEventData eventData)
    {
        // OnClick code goes here ...
        GameObject objectClicked = eventData.pointerCurrentRaycast.gameObject; // get the object that was pressed

        if (eventData.button != PointerEventData.InputButton.Left)             // Ensure the left button was pressed (OR THE FALCON BUTTON)
        {
            return;
        }

        if (objectClicked.tag == "Tag") // A tag was pressed
        {
            if (MakeWordBank.inTutorial && MakeWordBank.stepOfTutorial != 4 && MakeWordBank.stepOfTutorial != 8)
            {
                return;
            }
            if (MakeWordBank.stepOfTutorial == 8 && MakeWordBank.timeSpentOnStep8 <= 0.25f)
            {
                return;                 //prevents glitch
            }

            if (objectClicked.GetComponentInChildren <Text> ().color == Color.red)
            {
                return;                 //Prevents trasher from clicking on a tag the tagger has selected in multiplayer
            }
            if (objectClicked.GetComponent <Text>() != null && objectClicked.GetComponent <Text>().color == Color.red)
            {
                return;
            }

            Debug.Log(objectClicked.name); // Name of the object
            GameObject currentTag = state.getSelected();

            if (currentTag != null && currentTag.GetComponent <Text>() != null)
            {
                currentTag.GetComponent <Text>().color = Color.black; // Reset the color of the previously selected tag
            }
            state.setSelected(objectClicked);

            //if (MakeWordBank.trasherPanel.transform.localPosition.y >= 3000) { //If the player doesn't have a panel blocking putting tags on the image:
            objectClicked.GetComponentInChildren <Text> ().color = Color.red;
            for (int i = 0; i < MakeWordBank.tags.Length; i++)
            {
                if (objectClicked.GetComponentInChildren <Text> ().text.Equals(MakeWordBank.tags [i].getText()))
                {
                    MakeWordBank.tags [i].isChangingColor = false;
                }
            }
            //}

            if (cursorTag != null)
            {
                Destroy(cursorTag);
            }

            //Make tag that follows cursor:
            cursorTag = Instantiate(state.getSelected().transform.parent.gameObject, canvas.transform);
            cursorTag.transform.LookAt(Vector3.zero);
            //cursorTag.transform.Rotate (new Vector3 (0f, 0f, -3f));
            cursorTag.layer = 5;             //UI Layer
            if (cursorSphere != null)
            {
                cursorSphere.GetComponent <MeshRenderer>().enabled = false;
            }
            //cursorTag.name = currentTag.GetComponent<Text> ().name;
            //cursorTag.transform.localScale = new Vector3 (8.8f, 3.188f, 0.001f);
        }
        else if (objectClicked.tag == "QuitButton" && !MakeWordBank.inTutorial)         // Quit button clicked by falcon
        {
            QuitGameScript.TaskOnClick();
        }
        else if (objectClicked.tag == "Bin") // The bin was pressed, so we move the tag to the bin
        {
            Debug.Log("Bin Clicked");
            GameObject currentTag = state.getSelected();
            if (currentTag != null)
            {
                if (MakeWordBank.sequenceIndex < MakeWordBank.wordBank.Count)
                {
                    if (!MakeWordBank.inPracticeLevel && !MakeWordBank.inTutorial)
                    {
                        DataCollector.AddTag(currentTag.transform.parent.name);
                    }
                    GameObject newTrashedTag = Instantiate(state.getSelected().transform.parent.gameObject, canvas.transform);
                    newTrashedTag.transform.localScale
                        = new Vector3(newTrashedTag.transform.localScale.x / 2.0f, newTrashedTag.transform.localScale.y / 2.5f, newTrashedTag.transform.localScale.z);
                    newTrashedTag.transform.GetChild(0).GetComponent <Text> ().color = Color.black;
                    newTrashedTag.transform.tag             = "TrashedTag";
                    newTrashedTag.transform.GetChild(0).tag = "TrashedTag";
                    int verticalBump = 0;
                    if (trashedTags.Count >= 14 && trashedTags.Count < 28)
                    {
                        verticalBump = 168;                         //To prevent overlap
                    }
                    else if (trashedTags.Count >= 28 && trashedTags.Count < 42)
                    {
                        verticalBump = 606;
                    }
                    else if (trashedTags.Count >= 42)
                    {
                        verticalBump = 774;
                    }

                    int horizontalBump = 0;
                    if (trashedTags.Count >= 14 && trashedTags.Count < 28)
                    {
                        horizontalBump = 50;
                    }
                    else if (trashedTags.Count >= 28 && trashedTags.Count < 42)
                    {
                        horizontalBump = 0;
                    }
                    else if (trashedTags.Count >= 42)
                    {
                        horizontalBump = 50;
                    }
                    newTrashedTag.transform.position = canvas.transform.TransformPoint(new Vector2(320 + horizontalBump, -55 - 12 * trashedTags.Count + verticalBump)) + Vector3.back * -0.25f;
                    newTrashedTag.transform.LookAt(newTrashedTag.transform.position + Vector3.back * newTrashedTag.transform.position.z * -1);
                    trashedTags.Add(newTrashedTag);
                    trashedTags[trashedTags.Count - 1].layer = 5;                     //UI
                }
                MakeWordBank.replaceTag(currentTag, false);
                currentTag.GetComponentInChildren <Text>().color = Color.clear;
                currentTag.GetComponent <Text>().color           = Color.clear; // Reset the color of the previously selected tag
            }
            if (cursorTag != null)
            {
                Destroy(cursorTag);
                cursorTag = null;
                if (cursorSphere != null)
                {
                    cursorSphere.GetComponent <MeshRenderer>().enabled = true;
                }
            }
            state.setSelected(null);
        }
        else if (objectClicked.tag == "Image") // The image area was pressed, so here we cast a tag onto the sphere
        {
            Debug.Log("Image Clicked");
            GameObject currentTag = state.getSelected();
            if (currentTag != null && !currentTag.transform.parent.name.Equals(""))    // TODO: Check if a tag is currently selected and that the tag isn't blank
            {
                Vector3 cursorPosition = state.getCursorPosition();                    // Use the cursor position to cast a ray onto the sphere
                Ray     ray            = Camera.main.ScreenPointToRay(cursorPosition); // The ray that will be casted onto the sphere

                // In the following two lines, since the sphere collider is outside the sphere
                // We move the point of the ray well outside of the sphere, then invert the direction
                // This way, we cast ray to the same point of the sphere, but from the outside rather than the inside
                ray.origin    = ray.GetPoint(100);
                ray.direction = -ray.direction;

                RaycastHit hit; // The raycast

                Debug.DrawRay(ray.origin, ray.direction, Color.red, 5);
                if (Physics.Raycast(ray, out hit))
                {
                    Destroy(cursorTag);
                    cursorTag = null;
                    if (cursorSphere != null)
                    {
                        cursorSphere.GetComponent <MeshRenderer>().enabled = true;
                    }
                    GameObject newObject = Instantiate(tagPrefab, hit.point * 0.95f, Quaternion.identity); // Create the new object using the tagPrefab
                    newObject.transform.LookAt(Vector3.zero);                                              // Make it face the center of the sphere
                    newObject.transform.localScale = new Vector3(0.25f, 0.1f, 0.00001f);
                    newObject.name             = currentTag.transform.parent.name;                         // CHANGE THIS LATER
                    newObject.transform.parent = sphere.transform;
                    newObject.GetComponent <Renderer>().material = new Material(Shader.Find("Diffuse"));

                    // Create the object which will hold the TextMesh
                    GameObject textContainer = new GameObject();
                    textContainer.transform.parent = newObject.transform;

                    // Create the text mesh to be rendered over the plane
                    TextMesh text = textContainer.AddComponent <TextMesh> ();
                    text.text                       = currentTag.transform.parent.name;
                    text.fontSize                   = 20;
                    text.alignment                  = TextAlignment.Center;
                    text.anchor                     = TextAnchor.MiddleCenter;
                    text.name                       = currentTag.transform.parent.name + "_Text";
                    text.transform.parent           = textContainer.transform;
                    text.transform.localScale       = new Vector3(-0.075f, 0.25f, 0.25f);
                    text.transform.localPosition    = Vector3.zero;
                    text.transform.localEulerAngles = Vector3.zero;
                    if (!MakeWordBank.inTutorial && !MakeWordBank.inPracticeLevel)
                    {
                        DataCollector.AddTag(currentTag.transform.parent.name, newObject.transform.position);
                    }

                    //int diff = MakeWordBank.sequenceIndex; //This is just a convoluted way to find out if the image turned over so the trashed tag prefabs can be deleted
                    MakeWordBank.replaceTag(currentTag, true);
                    currentTag.GetComponentInChildren <Text>().color = Color.clear;
                    state.setSelected(null);
                    //diff -= MakeWordBank.sequenceIndex;
                    //if (diff > 0) { //Means image turned over:
                    //	for (int i = 0; i < trashedTags.Count; i++) {
                    //		Destroy (trashedTags [i]);
                    //	}
                    //	trashedTags.Clear();
                    //}


                    // ---- Below is old code used to create the tag whereever the click happened. It isn't being used now but may be useful later
                    // --------------------------------------------------------------------------------------------------------------------------
                    //GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.tag, hit.point * 0.95f, Quaternion.identity);
                    //gameObject.transform.LookAt(Vector3.zero);
                    //gameObject.name = "Tag " + this.tags.Count;
                    //gameObject.transform.localScale = new Vector3(20f, 5f, 1f);
                    //this.tag.GetComponent<MeshRenderer>().shadowCastingMode = ShadowCastingMode.Off;
                    //gameObject.AddComponent(typeof(Tag));
                    //gameObject.transform.parent = this.tagContainer.transform;
                    //this.tags.Add(gameObject);
                    //this.keycam.transform.position = Vector3.zero;
                    //this.keycam.transform.LookAt(this.ray.point);
                    //this.keycam.transform.position = Vector3.MoveTowards(this.keycam.transform.position, this.ray.point, Vector3.Distance(this.keycam.transform.position, this.ray.point) * 0.8f);
                    //this.startTag(gameObject);
                }
            }
        }
    }
コード例 #21
0
        private void generateMenu_ButtonFunction()
        {
            MenuFunction.resetMenu();

            List <string> functionAlreadyDisplayed = new List <string>();

            foreach (KeyValuePair <string, string[]> zuordnung in AppData.function_UIContainer_to_realFunction)
            {
                foreach (string function in zuordnung.Value)
                {
                    if (functionAlreadyDisplayed.Contains(function))
                    {
                        continue;
                    }

                    TextMesh text = Instantiate(Text_Prefab.gameObject).GetComponent <TextMesh>();
                    text.text = function; // alternative text

                    try                   //if something goes wrong during one element
                    {
                        GameObject go = UIContainerBar.Instance.getUIElementPrefab(function);
                        if (go == null)
                        {
                            Destroy(text.gameObject);
                            Debug.Log("Element " + function + " could not be translatet in Function Menu");
                            continue;
                        }

                        //generates the menu element, we listen to select events
                        MenuFunction.addMenuElement(
                            go,
                            function,
                            text.gameObject,
                            OnSelectEvents_functionMenu
                            );
                    }
                    catch
                    {
                        Debug.Log("Element " + function + " could not be generated");
                    }

                    //Tidy up
                    Destroy(text.gameObject); //they made a copy by now

                    functionAlreadyDisplayed.Add(function);
                }
            }

            //for the already given state
            foreach (AppData.uniqueIDDevice.UIContainerData uicd in currentMenuInformationState.myUIContainerData)
            {
                //check all nessesary values for null
                if (uicd.function_UIContainer == null || uicd.adress == null)
                {
                    continue;
                }

                TextMesh text = Instantiate(Text_Prefab.gameObject).GetComponent <TextMesh>();
                text.text = uicd.adress; // alternative text

                GameObject go = UIContainerBar.Instance.getUIElementPrefab(uicd.function_UIContainer);

                //there must be one element in the list, that has this uicd.function_UIContainer as ID
                int?placement = MenuFunction.getElementByID(uicd.function_UIContainer)?.collectionNode.transform.GetSiblingIndex() + 1; //we want +1


                MenuFunction.addMenuElement(
                    go,
                    uicd.adress,
                    text.gameObject,
                    OnSelectEvents_functionMenu,
                    placement.GetValueOrDefault(),
                    OnHoldEvents_functionMenu
                    );

                //MenuFunction.catchNextDeselectionEvent = true;
                MenuFunction.getElementByID(uicd.adress).interactiveToggle.SetSelection(true);

                //they made a copy
                Destroy(text);
            }

            MenuFunction.updateCollection(true);
        }
コード例 #22
0
 void Start()
 {
     text          = GetComponent <TextMesh>();
     textBaseColor = text.color;
 }
コード例 #23
0
 // Use this for initialization
 void Start()
 {
     current_time = 0;
     Renderer     = GetComponent <Renderer>();
     textmesh     = GetComponentInChildren <TextMesh>();
 }
コード例 #24
0
 void Awake()
 {
     text = GetComponent <TextMesh>();
 }
コード例 #25
0
 // Start is called before the first frame update
 void Start()
 {
     Text = GetComponent <TextMesh>();
 }
コード例 #26
0
    // Update is called once per frame
    void Update()
    {
        // Enable movement of the camera
        if (this.gameObject.name.Equals("Room.glb") && !Camera.main.GetComponent <CameraController>().enabled)
        {
            Camera.main.GetComponent <CameraController>().enabled = true;
            GameObject.Find("Canvas").SetActive(false);// Disable the Loading text
        }
        if (this.gameObject.name == "cart")
        {
            return;
        }

        if (product == null)
        {
            product = this.gameObject;
        }
        if (product != null && scene == null && product.transform.childCount > 0)
        {
            scene = product.transform.GetChild(0).gameObject;
        }
        if (scene != null && model == null && scene.transform.childCount > 0)
        {
            model = scene.transform.GetChild(0).gameObject;
            model.AddComponent <MeshCollider>();

            // display product name below model
            GameObject nameText = new GameObject();
            nameText.name = "name" + product.name;
            nameText.transform.position = model.transform.position + new Vector3(0, -2, 0);
            TextMesh nameTextMesh = nameText.AddComponent <TextMesh>();
            nameTextMesh.text      = product.name;
            nameTextMesh.fontSize  = 15;
            nameTextMesh.anchor    = TextAnchor.MiddleCenter;
            nameTextMesh.alignment = TextAlignment.Center;
            nameText.AddComponent(typeof(FollowCamera));

            if (entry.getAdditionalData() != null)
            {
                // get description from metadata and display it
                string description = "";
                if (entry.getAdditionalData().TryGetValue("description", out description))
                {
                    GameObject descriptionText = new GameObject();
                    descriptionText.name = "description" + model.name;
                    descriptionText.transform.position = model.transform.position + new Vector3(0, -4, 0);
                    TextMesh descriptionTextMesh = descriptionText.AddComponent <TextMesh>();
                    descriptionTextMesh.text      = description;
                    descriptionTextMesh.fontSize  = 12;
                    descriptionTextMesh.anchor    = TextAnchor.MiddleCenter;
                    descriptionTextMesh.alignment = TextAlignment.Center;
                    descriptionText.AddComponent(typeof(FollowCamera));
                }

                // get price from metadata and display it
                string priceString = "";
                if (entry.getAdditionalData().TryGetValue("price", out priceString))
                {
                    // display text above model
                    GameObject priceText = new GameObject();
                    priceText.name = "price" + model.name;
                    priceText.transform.position = model.transform.position + new Vector3(0, 8, 0);
                    TextMesh priceTextMesh = priceText.AddComponent <TextMesh>();
                    priceTextMesh.text      = "$" + priceString;
                    priceTextMesh.fontSize  = 20;
                    priceTextMesh.anchor    = TextAnchor.MiddleCenter;
                    priceTextMesh.alignment = TextAlignment.Center;
                    priceText.AddComponent(typeof(FollowCamera));
                }

                // get url from metadata
                string itemURL = "";
                if (entry.getAdditionalData().TryGetValue("url", out itemURL))
                {
                }

                // create Data object
                data = new Data(description, priceString, itemURL);
            }
        }

        // click listener for each model to redirect user to item page and add item to cart
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.transform && model.name == hit.transform.gameObject.name)
                {
                    // redirect to item page
                    if (data.url != "")
                    {
                        Application.OpenURL(data.url);
                    }

                    // simulate adding an item to cart
                    GameObject totalCartGameObject = GameObject.Find("cartTotal");
                    GameObject itemsCartGameObject = GameObject.Find("cartItems");

                    if (totalCartGameObject != null && itemsCartGameObject != null)
                    {
                        string temp         = totalCartGameObject.GetComponent <TextMesh>().text.Substring(1);
                        int    newCartTotal = int.Parse(temp) + int.Parse(data.price);
                        totalCartGameObject.GetComponent <TextMesh>().text = "$" + newCartTotal;

                        temp = itemsCartGameObject.GetComponent <TextMesh>().text.Substring(0, 1);
                        int newCartItems = int.Parse(temp) + 1;
                        itemsCartGameObject.GetComponent <TextMesh>().text = newCartItems + " item(s) in cart";
                    }
                }
            }
        }
    }
コード例 #27
0
    public void createIndicator()
    {
        if (!showIndicator)
        {
            return;
        }
        clearResourceAndObject();
        PrintDebugLog("create Indicator!");
        rw = WaveVR_Resource.instance;
        indicatorPrefab = Resources.Load("ComponentIndicator") as GameObject;

        if (indicatorPrefab == null)
        {
            PrintInfoLog("ComponentIndicator is not found!");
            return;
        }
        else
        {
            PrintDebugLog("ComponentIndicator is found!");
        }

        linePrefab = Resources.Load("LineIndicator") as GameObject;

        if (linePrefab == null)
        {
            PrintInfoLog("LineIndicator is not found!");
            return;
        }
        else
        {
            PrintDebugLog("LineIndicator is found!");
        }

        if (_HMD == null)
        {
            _HMD = WaveVR_Render.Instance.gameObject;
        }

        if (_HMD == null)
        {
            PrintInfoLog("Can't get HMD!");
            return;
        }

        var gc = transform.childCount;

        for (int i = 0; i < gc; i++)
        {
            GameObject go = transform.GetChild(i).gameObject;

            PrintInfoLog("child name is " + go.name);
        }

        PrintInfoLog("showIndicatorAngle: " + showIndicatorAngle + ", hideIndicatorByRoll: " + hideIndicatorByRoll + ", basedOnEmitter: " + basedOnEmitter);
        PrintInfoLog("Line settings--\n lineLength: " + lineLength + ", lineStartWidth: " + lineStartWidth + ", lineEndWidth: " + lineEndWidth + ", lineColor: " + lineColor);
        PrintInfoLog("Text settings--\n textCharacterSize: " + textCharacterSize + ", zhCharactarSize: " + zhCharactarSize + ", textFontSize: " + textFontSize + ", textColor: " + textColor);

        foreach (ButtonIndication bi in buttonIndicationList)
        {
            PrintInfoLog("keyType: " + bi.keyType + ", alignment: " + bi.alignment + ", offset: " + bi.indicationOffset + ", useMultiLanguage: " + bi.useMultiLanguage +
                         ", indication: " + bi.indicationText + ", followRotation: " + bi.followButtonRotation);

            // find component by name
            string partName      = null;
            string partName1     = null;
            string partName2     = null;
            string indicationKey = null;
            switch (bi.keyType)
            {
            case ButtonIndication.KeyIndicator.Trigger:
                partName      = "_[CM]_TriggerKey";
                partName1     = "__CM__TriggerKey";
                partName2     = "__CM__TriggerKey.__CM__TriggerKey";
                indicationKey = "TriggerKey";
                break;

            case ButtonIndication.KeyIndicator.TouchPad:
                partName      = "_[CM]_TouchPad";
                partName1     = "__CM__TouchPad";
                partName2     = "__CM__TouchPad.__CM__TouchPad";
                indicationKey = "TouchPad";
                break;

            case ButtonIndication.KeyIndicator.Grip:
                partName      = "_[CM]_Grip";
                partName1     = "__CM__Grip";
                partName2     = "__CM__Grip.__CM__Grip";
                indicationKey = "Grip";
                break;

            case ButtonIndication.KeyIndicator.DPad_Left:
                partName      = "_[CM]_DPad_Left";
                partName1     = "__CM__DPad_Left";
                partName2     = "__CM__DPad_Left.__CM__DPad_Left";
                indicationKey = "DPad_Left";
                break;

            case ButtonIndication.KeyIndicator.DPad_Right:
                partName      = "_[CM]_DPad_Right";
                partName1     = "__CM__DPad_Right";
                partName2     = "__CM__DPad_Right.__CM__DPad_Right";
                indicationKey = "DPad_Right";
                break;

            case ButtonIndication.KeyIndicator.DPad_Up:
                partName      = "_[CM]_DPad_Up";
                partName1     = "__CM__DPad_Up";
                partName2     = "__CM__DPad_Up.__CM__DPad_Up";
                indicationKey = "DPad_Up";
                break;

            case ButtonIndication.KeyIndicator.DPad_Down:
                partName      = "_[CM]_DPad_Down";
                partName1     = "__CM__DPad_Down";
                partName2     = "__CM__DPad_Down.__CM__DPad_Down";
                indicationKey = "DPad_Down";
                break;

            case ButtonIndication.KeyIndicator.App:
                partName      = "_[CM]_AppButton";
                partName1     = "__CM__AppButton";
                partName2     = "__CM__AppButton.__CM__AppButton";
                indicationKey = "AppKey";
                break;

            case ButtonIndication.KeyIndicator.Home:
                partName      = "_[CM]_HomeButton";
                partName1     = "__CM__HomeButton";
                partName2     = "__CM__HomeButton.__CM__HomeButton";
                indicationKey = "HomeKey";
                break;

            case ButtonIndication.KeyIndicator.Volume:
                partName      = "_[CM]_VolumeKey";
                partName1     = "__CM__VolumeKey";
                partName2     = "__CM__VolumeKey.__CM__VolumeKey";
                indicationKey = "VolumeKey";
                break;

            case ButtonIndication.KeyIndicator.VolumeUp:
                partName      = "_[CM]_VolumeUp";
                partName1     = "__CM__VolumeUp";
                partName2     = "__CM__VolumeUp.__CM__VolumeUp";
                indicationKey = "VolumeUp";
                break;

            case ButtonIndication.KeyIndicator.VolumeDown:
                partName      = "_[CM]_VolumeDown";
                partName1     = "__CM__VolumeDown";
                partName2     = "__CM__VolumeDown.__CM__VolumeDown";
                indicationKey = "VolumeDown";
                break;

            case ButtonIndication.KeyIndicator.DigitalTrigger:
                partName      = "_[CM]_DigitalTriggerKey";
                partName1     = "__CM__DigitalTriggerKey";
                partName2     = "__CM__DigitalTriggerKey.__CM__DigitalTriggerKey";
                indicationKey = "DigitalTriggerKey";
                break;

            default:
                partName      = "_[CM]_unknown";
                partName1     = "__CM__unknown";
                partName2     = "__CM__unknown.__CM__unknown";
                indicationKey = "unknown";
                PrintDebugLog("Unknown key type!");
                break;
            }

            Transform tmp = transform.Find(partName);
            if (tmp == null)
            {
                tmp = transform.Find(partName1);
                if (tmp == null)
                {
                    tmp = transform.Find(partName2);
                }
            }

            if (tmp != null)
            {
                ComponentsIndication tmpCom = new ComponentsIndication();

                tmpCom.Name                 = partName;
                tmpCom.SourceObject         = tmp.gameObject;
                tmpCom.alignment            = bi.alignment;
                tmpCom.followButtonRoration = bi.followButtonRotation;

                Vector3 linePos;
                tmpCom.LineIndicator = null;

                linePos = transform.TransformPoint(new Vector3(0, tmp.localPosition.y, tmp.localPosition.z) + bi.indicationOffset);
                Quaternion spawnRot = Quaternion.identity;
                if (bi.followButtonRotation == true)
                {
                    spawnRot = transform.rotation;
                }

                GameObject lineGO = Instantiate(linePrefab, linePos, spawnRot);
                lineGO.name = partName + "Line";

                var li = lineGO.GetComponent <IndicatorLine>();
                li.lineColor  = lineColor;
                li.lineLength = lineLength;
                li.startWidth = lineStartWidth;
                li.endWidth   = lineEndWidth;
                li.alignment  = bi.alignment;
                li.updateMeshSettings();

                if (bi.followButtonRotation == true)
                {
                    lineGO.transform.parent = tmpCom.SourceObject.transform;
                }
                lineGO.SetActive(false);
                tmpCom.LineIndicator = lineGO;

                tmpCom.DestObject = null;

                Vector3 spawnPos;
                if (bi.alignment == ButtonIndication.Alignment.RIGHT)
                {
                    spawnPos = transform.TransformPoint(new Vector3(lineLength, tmp.localPosition.y, tmp.localPosition.z) + bi.indicationOffset);
                }
                else
                {
                    spawnPos = transform.TransformPoint(new Vector3(lineLength * (-1), tmp.localPosition.y, tmp.localPosition.z) + bi.indicationOffset);
                }

                GameObject destGO = Instantiate(indicatorPrefab, spawnPos, transform.rotation);
                destGO.name = partName + "Ind";
                if (bi.followButtonRotation == true)
                {
                    destGO.transform.parent = tmpCom.SourceObject.transform;
                }

                PrintInfoLog(" Source PartName: " + tmp.gameObject.name + " pos: " + tmp.position + " Rot: " + tmp.rotation);
                PrintInfoLog(" Line Name: " + lineGO.name + " pos: " + lineGO.transform.position + " Rot: " + lineGO.transform.rotation);
                PrintInfoLog(" Destination Name: " + destGO.name + " pos: " + destGO.transform.position + " Rot: " + destGO.transform.rotation);

                int childC = destGO.transform.childCount;
                for (int i = 0; i < childC; i++)
                {
                    GameObject c = destGO.transform.GetChild(i).gameObject;
                    if (bi.alignment == ButtonIndication.Alignment.LEFT)
                    {
                        float tx = c.transform.localPosition.x;
                        c.transform.localPosition = new Vector3(tx * (-1), c.transform.localPosition.y, c.transform.localPosition.z);
                    }
                    TextMesh     tm = c.GetComponent <TextMesh>();
                    MeshRenderer mr = c.GetComponent <MeshRenderer>();

                    if (tm == null)
                    {
                        PrintInfoLog(" tm is null ");
                    }
                    if (mr == null)
                    {
                        PrintInfoLog(" mr is null ");
                    }

                    if (tm != null && mr != null)
                    {
                        tm.characterSize = textCharacterSize;
                        if (c.name != "Shadow")
                        {
                            mr.material.SetColor("_Color", textColor);
                        }
                        else
                        {
                            PrintDebugLog(" Shadow found ");
                        }
                        tm.fontSize = textFontSize;
                        if (bi.useMultiLanguage)
                        {
                            sysLang    = rw.getSystemLanguage();
                            sysCountry = rw.getSystemCountry();
                            PrintDebugLog(" System language is " + sysLang);
                            if (sysLang.StartsWith("zh"))
                            {
                                PrintDebugLog(" Chinese language");
                                tm.characterSize = zhCharactarSize;
                            }

                            // use default string - multi-language
                            if (bi.indicationText == "system")
                            {
                                tm.text = rw.getString(indicationKey);
                                PrintInfoLog(" Name: " + destGO.name + " uses default multi-language -> " + tm.text);
                            }
                            else
                            {
                                tm.text = rw.getString(bi.indicationText);
                                PrintInfoLog(" Name: " + destGO.name + " uses custom multi-language -> " + tm.text);
                            }
                        }
                        else
                        {
                            if (bi.indicationText == "system")
                            {
                                tm.text = indicationKey;
                            }
                            else
                            {
                                tm.text = bi.indicationText;
                            }

                            PrintInfoLog(" Name: " + destGO.name + " didn't uses multi-language -> " + tm.text);
                        }

                        if (bi.alignment == ButtonIndication.Alignment.LEFT)
                        {
                            tm.anchor    = TextAnchor.MiddleRight;
                            tm.alignment = TextAlignment.Right;
                        }
                    }
                }

                destGO.SetActive(false);
                tmpCom.DestObject = destGO;
                tmpCom.Offset     = bi.indicationOffset;

                PrintInfoLog(tmpCom.Name + " line -> " + tmpCom.LineIndicator.name + " destObjName -> " + tmpCom.DestObject.name);
                compInd.Add(tmpCom);
            }
            else
            {
                PrintInfoLog("Neither " + partName + " or " + partName1 + " or " + partName2 + " is not in the model!");
            }
        }

        Emitter = null;
        if (basedOnEmitter)
        {
            WaveVR_RenderModel wrm = this.GetComponentInChildren <WaveVR_RenderModel>();

            if (wrm != null)
            {
                GameObject modelObj = wrm.gameObject;

                int modelchild = modelObj.transform.childCount;
                for (int j = 0; j < modelchild; j++)
                {
                    GameObject childName = modelObj.transform.GetChild(j).gameObject;
                    if (childName.name == "__CM__Emitter" || childName.name == "_[CM]_Emitter")
                    {
                        Emitter = childName;
                    }
                }
            }
        }

        needRedraw = false;
    }
コード例 #28
0
ファイル: EnemyMove.cs プロジェクト: caniescape/DevilDefense
    private void Start()
    {
        es = GameObject.Find("EnemySpawnPoint").GetComponent <EnemySpawner>();

        hpText = transform.GetChild(0).GetComponent <TextMesh>();
    }
コード例 #29
0
 void Start()
 {
     textMesh = GetComponent <TextMesh> ();
     StartCoroutine("Maths");
 }
コード例 #30
0
 void Start()
 {
     light      = sun.GetComponent <Light> ();
     statusText = this.gameObject.GetComponent <TextMesh> ();
 }
コード例 #31
0
 private static JSONClass SerializeTextMesh(TextMesh mesh)
 {
     JSONClass fieldData = new JSONClass();
     fieldData.Add("alignment", new JSONData(mesh.alignment.ToString()));
     fieldData.Add("anchor", new JSONData(mesh.anchor.ToString()));
     fieldData.Add("size", new JSONData(mesh.characterSize));
     JSONClass textColor = ConvertColor(mesh.color);
     fieldData.Add("color", textColor);
     fieldData.Add("text", new JSONData(mesh.text));
     return fieldData;
 }
コード例 #32
0
ファイル: DatingDude.cs プロジェクト: pli41/LoveBar
 void InitializeCountDownUI()
 {
     TextAnim      = countDown_Object.GetComponent <Animator>();
     countDownText = countDown_Object.GetComponent <TextMesh>();
 }
コード例 #33
0
    /* GameObject[] FindClosestEnemy()
     * {
     *     float distance = Mathf.Infinity;
     *     Vector3 position = transform.position;
     *     foreach (GameObject go in enemy)
     *     {
     *         Vector3 diff = go.transform.position - position;
     *         float curDistance = diff.sqrMagnitude;
     *         if (curDistance < distance)
     *         {
     *             fifthclosest = fourthclosest;
     *             fourthclosest = thirdclosest;
     *             thirdclosest = secondclosest;
     *             secondclosest = closest;
     *             closest = go;
     *             distance = curDistance;
     *         }
     *     }
     *     //return closest;
     *     return new GameObject[] { closest, secondclosest, thirdclosest, fourthclosest, fifthclosest };
     * }*/

    void Update()
    {
        //audioS = GetComponent<AudioSource>();
        //audioS1 = GetComponent<AudioSource>();
        ids = GameObject.Find("Depart").GetComponent <Gesetz>().id;
        idd = GameObject.Find("Military").GetComponent <Gesetz1>().id;
        //idr = GameObject.Find("Hospital").GetComponent<Gesetz2>().id;
        bc = GetComponent <BoxCollider2D>();
        if (style >= 1)
        {
            //ield return new WaitForSeconds(10);
            //  StartCoroutine(coroutine6);
            //zom = Random.Range(0, 5);
            boolean = true;
        }
        else
        {
            boolean = false;
        }
        if (boolean == true)
        {
            StartCoroutine(WaitAndPrint6());
            style   = 0;
            boolean = false;
        }
        if (zom >= 9)
        {
            i = 1;
        }
        if (zom >= 10)
        {
            //StartCoroutine(coroutine7);

            Local();
        }
        if (tocompare == 1)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep1 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp1 = zom;
        }
        if (tocompare == 2)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep2 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp2 = zom;
        }
        if (tocompare == 3)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep3 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp3 = zom;
        }
        if (tocompare == 4)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep4 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp4 = zom;
        }
        if (tocompare == 5)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep5 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp5 = zom;
        }
        if (tocompare == 6)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep6 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp6 = zom;
        }
        if (tocompare == 7)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep7 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp7 = zom;
        }
        if (tocompare == 8)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep8 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp8 = zom;
        }
        if (tocompare == 9)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep9 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp9 = zom;
        }
        if (tocompare == 10)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep10 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp10 = zom;
        }
        if (tocompare == 11)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep11 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp11 = zom;
        }
        if (tocompare == 12)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep12 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp12 = zom;
        }
        if (tocompare == 13)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep13 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp13 = zom;
        }
        if (tocompare == 14)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep14 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp14 = zom;
        }
        if (tocompare == 15)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep15 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp15 = zom;
        }
        if (tocompare == 16)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep16 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp16 = zom;
        }
        if (tocompare == 17)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep17 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp17 = zom;
        }
        if (tocompare == 18)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep18 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp18 = zom;
        }
        if (tocompare == 19)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep19 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp19 = zom;
        }
        if (tocompare == 20)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep20 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp20 = zom;
        }
        if (tocompare == 21)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep21 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp21 = zom;
        }
        if (tocompare == 22)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep22 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp22 = zom;
        }
        if (tocompare == 23)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep23 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp23 = zom;
        }
        if (tocompare == 24)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep24 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp24 = zom;
        }
        if (tocompare == 25)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep25 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp25 = zom;
        }
        if (tocompare == 26)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep26 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp26 = zom;
        }
        if (tocompare == 27)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep27 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp27 = zom;
        }
        if (tocompare == 28)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep28 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp28 = zom;
        }
        if (tocompare == 29)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep29 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp29 = zom;
        }
        if (tocompare == 30)
        {
            GameObject.Find("Field").GetComponent <Totalsum>().livep30 = cit;
            GameObject.Find("Field").GetComponent <Totalsum>().deadp30 = zom;
        }


        obsh = pol + arm;
        if (zom > cit)
        {
            fire.SetActive(true);
        }
        else
        {
            fire.SetActive(false);
        }
        if (pol > 0)
        {
            texter3.SetActive(false);
            texter1.SetActive(true);
            if (zom > 0)
            {
                texter2.SetActive(true);
            }
        }
        else
        {
            texter3.SetActive(true);
        }
        tex1      = texter1.GetComponent <TextMesh>();
        tex1.text = obsh.ToString();
        //tex1 = texter1.GetComponent<TextMesh>();
        //tex1.text = arm.ToString();
        tex2      = texter2.GetComponent <TextMesh>();
        tex2.text = zom.ToString();
        tex3      = texter3.GetComponent <TextMesh>();
        tex3.text = cit.ToString();
        if (cit <= 0)
        {
            StopCoroutine(coroutine7);
        }

        /*nearest = FindClosestEnemy()[0].name;
         *  nearest1 = FindClosestEnemy()[1].name;
         *  nearest2 = FindClosestEnemy()[2].name;
         *  nearest3 = FindClosestEnemy()[3].name;
         *  nearest4 = FindClosestEnemy()[4].name;
         *  _zom1 = FindClosestEnemy()[1].GetComponent<Common>().zom;
         *  _zom2 = FindClosestEnemy()[2].GetComponent<Common>().zom;
         *  zom0 = FindClosestEnemy()[3].GetComponent<Common>().zom;
         *  zom1 = FindClosestEnemy()[4].GetComponent<Common>().zom;
         *  // _zom2 = FindClosestEnemy()[2].GetComponent<ForSec>().zom;
         *  _zom = zom0 + zom1;
         *  zombi = _zom1 + _zom2;
         *  dead = _zom1 + _zom2 + zom0 + zom1;
         *  dead = dead / 4;*/
        if (isTouched())
        {
            Debug.Log("Trrr");
            if (ids == 1)
            {
                pol += 2;
                GameObject.Find("Depart").GetComponent <Gesetz>().id = 0;
            }
            if (idd == 1)
            {
                arm += 1;
                GameObject.Find("Military").GetComponent <Gesetz1>().id = 0;
            }

            //SetVolume(PlayerPrefs.GetInt("volume", 50) != 50 ? true : false);
        }
        if (cit <= 0)
        {
            if (bulbul == true)
            {
                StartCoroutine(coroutine10);
                bulbul = false;
            }
        }
    }
コード例 #34
0
ファイル: UI.cs プロジェクト: ReasonMakes/bunting-sky
    private void UpdateWaypointAndTargetUI()
    {
        //Console
        TextMesh consoleTargetInfoText         = control.generation.instancePlayer.transform.Find("Body").Find("FP Model").Find("Interior").Find("Display Strut Right").Find("Target Info Text").GetComponent <TextMesh>();
        TextMesh consoleTargetTypeAndTitleText = control.generation.instancePlayer.transform.Find("Body").Find("FP Model").Find("Interior").Find("Display Strut Left").Find("Target Type And Title Text").GetComponent <TextMesh>();

        //Waypoint
        renderWaypoint = false;
        float maxDist = 10000f;
        //Transform playerFpCamMountTran = playerInstanced.transform.GetChild(0).gameObject.GetComponent<Player>().fpCamMountTran;

        Vector3 waypointRaycastOrigin;
        Vector3 waypointRaycastDirection;

        if (displayMap)
        {
            //Camera dimensions
            float orthographicHeight = 2f * Camera.main.orthographicSize;
            float orthographicWidth  = orthographicHeight * Camera.main.aspect;

            //Cursor coordinate conversion
            float cursorNormalizedScreenSpaceX = ((Input.mousePosition.x - (Screen.width / 2f)) / Screen.width) * 2f;
            float cursorNormalizedScreenSpaceY = ((Input.mousePosition.y - (Screen.height / 2f)) / Screen.height) * 2f;

            float cursorWorldSpaceX = Camera.main.transform.position.x + (cursorNormalizedScreenSpaceX * orthographicWidth / 2f);
            float cursorWorldSpaceY = Camera.main.transform.position.z + (cursorNormalizedScreenSpaceY * orthographicHeight / 2f);

            //Set raycast origin
            waypointRaycastOrigin = new Vector3(
                cursorWorldSpaceX,
                Camera.main.transform.position.y,
                //we use y instead of z here because the orientation is rotated 90 degrees
                cursorWorldSpaceY
                );
            waypointRaycastDirection = Vector3.down;

            //Debug.Log("x: " + cursorNormalizedScreenSpaceX + "\ny: " + cursorNormalizedScreenSpaceY);
        }
        else
        {
            //Set raycast origin
            waypointRaycastOrigin    = Camera.main.transform.position;
            waypointRaycastDirection = Camera.main.transform.forward;
        }

        if (Physics.Raycast(waypointRaycastOrigin, waypointRaycastDirection, maxDist))
        {
            RaycastHit hit = new RaycastHit();
            Physics.Raycast(waypointRaycastOrigin, waypointRaycastDirection, out hit, maxDist);
            //Debug.DrawRay(waypointRaycastOrigin, waypointRaycastDirection * hit.distance, Color.green, Time.deltaTime, false);

            if (hit.collider.gameObject.name == control.generation.cBodyStar.name + "(Clone)")
            {
                //Waypoint
                waypointTextType.text  = "Star";
                waypointTextTitle.text = hit.collider.gameObject.GetComponent <CelestialName>().title;
                waypointTextBody.text  = GetDistanceAndDeltaVUI(hit.collider.gameObject, false);

                //Console waypoint
                consoleTargetTypeAndTitleText.text = waypointTextType.text + "\n" + waypointTextTitle.text;

                //Update UI
                SetWaypointUI(hit);
            }
            else if (hit.collider.gameObject.name == control.generation.cBodyPlanetoid.name + "(Clone)")
            {
                //Waypoint
                waypointTextType.text  = "Planetoid";
                waypointTextTitle.text = hit.collider.gameObject.GetComponent <CelestialName>().title;
                waypointTextBody.text  = GetDistanceAndDeltaVUI(hit.collider.gameObject, false);

                //Console waypoint
                consoleTargetTypeAndTitleText.text = waypointTextType.text + "\n" + waypointTextTitle.text;

                //Update UI
                SetWaypointUI(hit);
            }
            else if (!displayMap && hit.collider.gameObject.name == control.generation.station.name + "(Clone)")
            {
                //Waypoint
                waypointTextType.text  = "Station";
                waypointTextTitle.text = hit.collider.gameObject.GetComponent <HumanName>().title;
                waypointTextBody.text  = GetDistanceAndDeltaVUI(hit.collider.gameObject, true);

                //Console waypoint
                consoleTargetTypeAndTitleText.text = waypointTextType.text + "\n" + waypointTextTitle.text;

                //Update UI
                SetWaypointUI(hit);
            }
            else if (!displayMap && hit.collider.gameObject.name == control.generation.cBodyAsteroid.name + "(Clone)")
            {
                //Waypoint
                waypointTextType.text  = "Asteroid";
                waypointTextTitle.text = "Class: " + hit.collider.gameObject.GetComponent <CBodyAsteroid>().sizeClassDisplay;
                waypointTextBody.text  = GetDistanceAndDeltaVUI(hit.collider.gameObject, false);

                //Console waypoint
                consoleTargetTypeAndTitleText.text = waypointTextType.text + "\n" + waypointTextTitle.text;

                //Update UI
                SetWaypointUI(hit);
            }
            else
            {
                //Debug.Log("Undefined object " + hit.collider.gameObject.name + " hit " + hit.distance + " units away");
            }
        }
        else if (control.generation.instancePlayer.GetComponentInChildren <Player>().targetObject != null)
        {
            //Console target
            consoleTargetTypeAndTitleText.text = targetTypeAndTitle;
            GetDistanceAndDeltaVUI(control.generation.instancePlayer.GetComponentInChildren <Player>().targetObject, false);
        }
        else
        {
            //Console default
            consoleTargetTypeAndTitleText.text = "No target";
            consoleTargetInfoText.text         = "\n";
        }

        //Don't render when in first-person
        if (!Player.destroyed && Player.firstPerson)
        {
            renderWaypoint = false;
            waypointImage.gameObject.SetActive(true);
        }
        else
        {
            waypointImage.gameObject.SetActive(renderWaypoint);
        }
        waypointTextType.gameObject.SetActive(renderWaypoint);
        waypointTextTitle.gameObject.SetActive(renderWaypoint);
        waypointTextBody.gameObject.SetActive(renderWaypoint);

        //Target
        if (renderTarget)
        {
            SetPlayerTargetUI();
        }
    }