Exemplo n.º 1
0
 void Awake()
 {
     if (GameObject.Find("SUIMONO_Module") != null)
     {
         moduleObject = GameObject.Find("SUIMONO_Module").gameObject.GetComponent <Suimono.Core.SuimonoModule>() as Suimono.Core.SuimonoModule;
     }
     if (GameObject.Find("SUIMONO_Surface_Ocean") != null)
     {
         oceanObject = GameObject.Find("SUIMONO_Surface_Ocean").gameObject.GetComponent <Suimono.Core.SuimonoObject>() as Suimono.Core.SuimonoObject;
     }
 }
Exemplo n.º 2
0
    void Start()
    {
        //get main object
        lightObject   = GameObject.Find("Directional Light").GetComponent <Transform>();
        suimonoObject = GameObject.Find("SUIMONO_Surface").GetComponent <Suimono.Core.SuimonoObject>();
        uiCanvasScale = this.transform.GetComponent <CanvasScaler>();

        //find UI objects
        sliderTOD      = GameObject.Find("Slider_TOD").GetComponent <Slider>();
        sliderBeaufort = GameObject.Find("Slider_Beaufort").GetComponent <Slider>();
    }
    void LateUpdate()
    {
        #if UNITY_EDITOR
        if (convertToSuimono)
        {
            convertToSuimono = false;
            if (CheckAllResources())
            {
                if (moduleObject != null)
                {
                    if (moduleObject.suimonoModuleLibrary != null)
                    {
                        if (moduleObject.suimonoModuleLibrary.surfaceObject != null)
                        {
                            //Disconnect from prefab;
                                                        #if UNITY_EDITOR
                                                        #if !UNITY_2018_3_OR_NEWER
                            PrefabUtility.DisconnectPrefabInstance(this.gameObject);
                                                        #endif
                                                        #endif

                            Debug.Log("Passed!");

                            //instantiate new surface object with current object settings
                            mainObj = Instantiate(moduleObject.suimonoModuleLibrary.surfaceObject, transform.position, transform.rotation) as GameObject;
                            mainObj.GetComponent <Transform>().localScale = transform.localScale;
                            mainObj.name = "SUIMONO_Surface_" + gameObject.name;

                            //Set Surface properties
                            surfaceObj       = mainObj.GetComponent <Transform>().Find("Suimono_Object");
                            surfaceComponent = mainObj.GetComponent <Suimono.Core.SuimonoObject>() as Suimono.Core.SuimonoObject;
                            surfaceComponent.enableCustomMesh = true;
                            surfaceComponent.customMesh       = gameObject.GetComponent <MeshFilter>().sharedMesh;
                            surfaceObj.GetComponent <MeshFilter>().sharedMesh = gameObject.GetComponent <MeshFilter>().sharedMesh;

                            //Set Scale properties
                            scaleObj = mainObj.GetComponent <Transform>().Find("Suimono_ObjectScale");
                            scaleObj.gameObject.SetActive(false);

                            //Remove original object
                            gameObject.SetActive(false);
                        }
                    }
                }
                else
                {
                    Debug.Log("Suimono Module not found!");
                }
            }
        }
        #endif
    }