Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        SkyboxFade fade = (SkyboxFade)target;

        serializedObject.Update();
        if (fade.UseAmbientColor)
        {
            DrawDefaultInspector();
        }
        else
        {
            string[] exlcudeVars = new string[1];
            exlcudeVars [0] = "AmbientColor";
            DrawPropertiesExcluding(serializedObject, exlcudeVars);
        }
        if (GUILayout.Button("Set Scene Skybox"))
        {
            fade.SetToSkybox();
        }
        if (GUILayout.Button("Set As Starting Skybox"))
        {
            if (EditorUtility.DisplayDialog("Set As Starting Skybox", "This will set the starting skybox to the skybox attatched to this Skybox Fade. Are you sure you want to make this change?", "Okay", "Cancel"))
            {
                fade.SetAsStartingSkybox();
            }
        }
        serializedObject.ApplyModifiedProperties();
    }
Exemplo n.º 2
0
    public void SetClosestSkybox()
    {
        Page page = (Page)target;

        if (page != null && Selection.activeObject == page.gameObject)
        {
            int        siblingIndex = page.transform.GetSiblingIndex();
            SkyboxFade isThereSb    = page.GetComponent <SkyboxFade> ();
            while (siblingIndex >= 1 && isThereSb == null)
            {
                isThereSb = page.transform.parent.GetChild(--siblingIndex).GetComponent <SkyboxFade> ();
            }
            if (isThereSb)
            {
                isThereSb.SetToSkybox();
                if (!isThereSb.UseAmbientColor)
                {
                    isThereSb = null;

                    //Continue until you can set the previous ambient light
                    while (siblingIndex >= 1 && isThereSb == null)
                    {
                        Debug.Log(siblingIndex);
                        isThereSb = page.transform.parent.GetChild(--siblingIndex).GetComponent <SkyboxFade> ();
                        if (isThereSb != null && !isThereSb.UseAmbientColor)
                        {
                            //Only accept this script if it is using ambient color;
                            isThereSb = null;
                        }
                    }
                    //If there is a preivious Fade Skybox that uses an ambient light, use that light, otherwise use Startup's default light
                    if (isThereSb)
                    {
                        isThereSb.SetToAmbientLight();
                    }
                    else
                    {
                        GameObject.Find("Main").GetComponent <StartUp> ().SetStartupAmbientLightData();
                    }
                }
            }
            else
            {
                GameObject.Find("Main").GetComponent <StartUp> ().SetStartupSkyboxData();
            }
        }
    }