Ejemplo n.º 1
0
 void AddSpatialButton(PlanSnap script)
 {
     if (!script.gameObject.GetComponent <SpatialButton>())
     {
         SpatialButton button = script.gameObject.AddComponent <SpatialButton>();
         button.calledOnClick.AddListener(script.StartAR);
     }
 }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            SpatialButton myScript = (SpatialButton)target;

            if (GUILayout.Button("Simulate Click"))
            {
                myScript.calledOnClick.Invoke();
            }

            DrawDefaultInspector();
        }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        gameObject.name    = photosphereImage.name;
        photosphereManager = FindObjectOfType <PhotosphereManager> ();

        //apply overrides or get info from manager
        if (smallSizeOverride == 0)
        {
            if (photosphereManager)
            {
                smallSize = photosphereManager.smallSize;
            }
            else
            {
                smallSize = .1f;
            }
        }
        else
        {
            smallSize = smallSizeOverride;
        }
        if (largeSizeOverride == 0f)
        {
            if (photosphereManager)
            {
                largeSize = photosphereManager.largeSize;
            }
            else
            {
                largeSize = 40f;
            }
        }
        else
        {
            largeSize = largeSizeOverride;
        }
        if (animationTimeOverride == 0f)
        {
            if (photosphereManager)
            {
                animationTime = photosphereManager.animationTime;
            }
            else
            {
                animationTime = 2f;
            }
        }
        else
        {
            animationTime = animationTimeOverride;
        }
        if (basePhotosphereMaterialOverride == null)
        {
            if (photosphereManager)
            {
                basePhotosphereMaterial = photosphereManager.basePhotosphereMaterial;
            }
            else
            {
                basePhotosphereMaterial = new Material(Shader.Find("Standard"));
            }
        }
        else
        {
            basePhotosphereMaterial = basePhotosphereMaterialOverride;
        }
        if (selectedSphereMaterialOverride == null)
        {
            if (photosphereManager)
            {
                selectedSphereMaterial = photosphereManager.selectedSphereMaterial;
            }
            else
            {
                selectedSphereMaterial       = new Material(Shader.Find("Standard"));
                selectedSphereMaterial.color = new Color(.5f, 1, 1, .5f);
            }
        }
        else
        {
            selectedSphereMaterial = selectedSphereMaterialOverride;
        }



        //setup materials
        largeMaterial = GenerateSphereMaterial(basePhotosphereMaterial, photosphereImage);
        if (photosphereThumbnail != null)
        {
            smallMaterial = GenerateSphereMaterial(basePhotosphereMaterial, photosphereThumbnail);
        }
        else
        {
            try
            {
                photosphereThumbnail = GenerateThumbnail(photosphereImage);
                smallMaterial        = GenerateSphereMaterial(basePhotosphereMaterial, photosphereThumbnail);
            }
            catch (System.Exception ex)
            {
                Debug.LogWarning(photosphereImage.name + " is not read/write enabled. " +
                                 "Defaulting to large image on both large and small spheres. " +
                                 "This will hurt performance. Please go to import settinss and " +
                                 "'enable read/write' under 'Advanced'. System Exception: " + ex);
                smallMaterial = GenerateSphereMaterial(basePhotosphereMaterial, photosphereImage);
            }
        }

        //setup selected sphere stuff
        selectedSphere.name = gameObject.name + " Selected";
        selectedSphere.transform.position   = transform.position;
        selectedSphere.transform.localScale = new Vector3(smallSize * .9f, smallSize * .9f, smallSize * .9f);
        MeshFilter meshFilter = selectedSphere.AddComponent <MeshFilter>();

        meshFilter.mesh = GetComponent <MeshFilter>().mesh;
        MeshRenderer meshRenderer = selectedSphere.AddComponent <MeshRenderer>();

        meshRenderer.material = selectedSphereMaterial;
        selectedSphere.AddComponent <SphereCollider>();
        selectedSphere.layer = gameObject.layer;
        //make button on selected sphere to close it
        selectedSphere.AddComponent <SpatialButton>();
        SpatialButton selectedSphereButton = selectedSphere.GetComponent <SpatialButton>();

        selectedSphereButton.calledOnClick.AddListener(DeselectSphere);

        //sets the current sphere to the small material
        GetComponent <MeshRenderer>().material = smallMaterial;

        //apply default settings to all the balls
        foreach (var item in FindObjectsOfType <PhotosphereBall>())
        {
            item.Shrink();
        }
    }