Exemple #1
0
    public static void Preview(MenuShop.CShopData item)
    {
        if (MenuPreview.go != null)
        {
            MenuPreview.go.name = string.Concat(new object[]
            {
                "item_",
                Time.time,
                " ",
                UnityEngine.Random.Range(0, 1000)
            });
            UnityEngine.Object.Destroy(MenuPreview.go);
        }
        MenuPreview.currData = item;
        if (MenuPreview.currData == null)
        {
            return;
        }
        string[] array = MenuPreview.currData.iconname.Split(new char[]
        {
            '_'
        });
        if (array.Length != 3)
        {
            return;
        }
        MenuPreview.go = ItemPreview.Create("w_" + array[0]);
        if (MenuPreview.go == null)
        {
            MonoBehaviour.print("error create preview w_" + array[0]);
            return;
        }
        ItemPreview.SetSkin(MenuPreview.go, MenuPreview.currData.iconname);
        Transform[] componentsInChildren = MenuPreview.go.GetComponentsInChildren <Transform>();
        Transform[] array2 = componentsInChildren;
        for (int i = 0; i < array2.Length; i++)
        {
            Transform transform = array2[i];
            transform.gameObject.layer = 0;
        }
        RotateModel rotateModel = MenuPreview.go.AddComponent <RotateModel>();

        rotateModel.fullrotate = true;
    }
Exemple #2
0
    private GameObject[] floorLights = new GameObject[3];                                   //The lights on each floor

    void Start()                                                                            //Use this for initialization
    {
        Canvas[] canvases = GetComponentsInChildren <Canvas>();                             //Get the canvases

        for (int i = 0; i < canvases.Length; i++)                                           //For all the text elements
        {
            if (canvases[i].name == "Interaction")
            {
                interactionCanvas = canvases[i]; //Get the interaction canvas
            }
            else if (canvases[i].name == "Item")
            {
                itemCanvas = canvases[i]; //Get the item canvas
            }
        }

        interactionMessage = interactionCanvas.GetComponentInChildren <UnityEngine.UI.Text>();           //Get the message text

        UnityEngine.UI.Text[] textElements = itemCanvas.GetComponentsInChildren <UnityEngine.UI.Text>(); //Get the UI text

        for (int i = 0; i < textElements.Length; i++)                                                    //For all the text elements
        {
            if (textElements[i].name == "Title")                                                         //If this is the title
            {
                itemTitle = textElements[i];                                                             //Get the title of the item
            }
            else if (textElements[i].name == "Description")                                              //If this is the description
            {
                itemDescription = textElements[i];                                                       //Get the title of the item
            }
        }

        model = itemCanvas.GetComponentInChildren <MeshFilter>();                     //Get the model
        modelTextureRenderer = model.GetComponent <Renderer>();                       //Get the texture renderer

        GameObject[] gameObjectSearch = FindObjectsOfType <GameObject>();             //Get all the gameobjects

        for (int i = 0; i < gameObjectSearch.Length; i++)                             //For all the gameobjects
        {
            if (gameObjectSearch[i].name == "ModelIdentity")                          //If the model identity has been found
            {
                modelIdentity = gameObjectSearch[i];                                  //Get the model's identity
            }
            else if (gameObjectSearch[i].name.Contains("Elevator 1"))                 //If the first elevator has been found
            {
                elevatorAnimators[0] = gameObjectSearch[i].GetComponent <Animator>(); //Get the first elevator's animator
                elevatorAnimators[0].Play("Open Door");
            }
            else if (gameObjectSearch[i].name.Contains("Elevator 2"))                 //If the second elevator has been found
            {
                elevatorAnimators[1] = gameObjectSearch[i].GetComponent <Animator>(); //Get the second elevator's animator
                elevatorAnimators[1].Play("Open Door");
            }
            else if (gameObjectSearch[i].name.Contains("Elevator 3"))                 //If the third elevator has been found
            {
                elevatorAnimators[2] = gameObjectSearch[i].GetComponent <Animator>(); //Get the third elevator's animator
                elevatorAnimators[2].Play("Open Door");
            }
            else if (gameObjectSearch[i].name.Contains("Lights 1")) //If the first floor lights have been found
            {
                floorLights[0] = gameObjectSearch[i];               //Get the first floor's lights
            }
            else if (gameObjectSearch[i].name.Contains("Lights 2")) //If the second floor lights have been found
            {
                floorLights[1] = gameObjectSearch[i];               //Get the first floor's lights
            }
            else if (gameObjectSearch[i].name.Contains("Lights 3")) //If the third floor lights have been found
            {
                floorLights[2] = gameObjectSearch[i];               //Get the first floor's lights
            }
        }

        floorLights[1].SetActive(false);                                                                       //Disable the second floor lights
        floorLights[2].SetActive(false);                                                                       //Disable the third floor lights

        rotateModelScript = GetComponentInChildren <RotateModel>();                                            //Get the script

        fpsController = GetComponent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>();     //Get the first person controller

        model.transform.position  = new Vector3(model.transform.position.x, -100, model.transform.position.z); //Move the model real far away
        interactionCanvas.enabled = false;                                                                     //Disable the interaction canvas
        itemCanvas.enabled        = false;                                                                     //Disable the item canvas
    }
Exemple #3
0
 private void Start()
 {
     rotateModel = gameObject.GetComponent <RotateModel>();
 }
 void Awake()
 {
     instance = this;
 }