Exemplo n.º 1
0
    public virtual void OnEnable()
    {
        _target = (Fragmentum)target;

        if (_target.GetComponent<Renderer>() == null)
        {
            error = V_FR_ERROR.InvalidRenderer;
        }

        if (_target.renderer.sharedMaterials.Length == 0)
        {
            error = V_FR_ERROR.NoMaterials;
        }

        if (_target.GetComponent<SkinnedMeshRenderer>())
        {
            error = V_FR_ERROR.NoSkinnedMeshRendererSupport;
        }
        else if (_target.GetComponent<MeshFilter>())
            mesh = _target.GetComponent<MeshFilter>().sharedMesh;
        else
            error = V_FR_ERROR.InvalidRenderer;

        icon = Resources.Load("Fragmentum_Icon_Editor") as Texture2D;

        facebookIcon = Resources.Load("facebook_icon") as Texture2D;
        youtubeIcon = Resources.Load("youtube_icon") as Texture2D;

        textStyle.fontStyle = FontStyle.Bold;
    }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        if (_target.enabled == false)
            return;

        if (error != V_FR_ERROR.Ok && error != V_FR_ERROR.NotFractumMaterial)
        {
            GUILayout.Space(5);

            textStyle.normal.textColor = Color.red;
            EditorGUILayout.LabelField("Warning: " + error.ToString(), textStyle);

            About();

            return;
        }

        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        {
            GUILayout.Space(10);

            string fragmentumTag = "FragmentumTag";
            string tag = _target.renderer.sharedMaterial.GetTag(fragmentumTag, false, "nothing");

            if (tag.IndexOf("Fragmentum") == -1)
            {
                error = V_FR_ERROR.NotFractumMaterial;

                GUILayout.Space(5);
                textStyle.normal.textColor = Color.red;
                EditorGUILayout.LabelField("Warning: " + error.ToString(), textStyle);

                About();

                return;
            }

        EditorGUI.EndDisabledGroup();

            GUILayout.Space(5);
            //Activator
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            _target.fActivator = (Fragmentum.FRAGMENTUM_ACTIVATOR)EditorGUILayout.EnumPopup("Activator", _target.fActivator);
            EditorGUI.EndDisabledGroup();
            if (_target.fActivator == Fragmentum.FRAGMENTUM_ACTIVATOR.Plane)
            {
                if (!_target.planeObject)
                    GUI.backgroundColor = Color.red;
                _target.planeObject = (Transform)EditorGUILayout.ObjectField("   Activator Object", _target.planeObject, typeof(Transform), true);
                GUI.backgroundColor = Color.white;
            }

            if (_target.fActivator == Fragmentum.FRAGMENTUM_ACTIVATOR.Sphere)
            {
                if (!_target.sphereObject)
                    GUI.backgroundColor = Color.red;

                _target.sphereObject = (Transform)EditorGUILayout.ObjectField("   Activator Object", _target.sphereObject, typeof(Transform), true);
                GUI.backgroundColor = Color.white;

                if (_target.sphereObjectRadius == 0)
                    GUI.backgroundColor = Color.red;
                _target.sphereObjectRadius = EditorGUILayout.FloatField("   Activator Radius", _target.sphereObjectRadius);
                GUI.backgroundColor = Color.white;
            }

        }

        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        {
            GUILayout.Space(5);

            //_target.bUseNoise = EditorGUILayout.Toggle("Use Noise", _target.bUseNoise);

            UpdateShader();
        }

        EditorGUI.EndDisabledGroup();

        GUILayout.Space(10);
        _target.useUpdateFunction = EditorGUILayout.Toggle("Use Update Function", _target.useUpdateFunction);

        //Info();

        About();
    }
Exemplo n.º 3
0
    void UpdateShader()
    {
        if (error != V_FR_ERROR.Ok)
            return;

        string matName = _target.renderer.sharedMaterial.ToString();

        if (matName.IndexOf("null") != -1)
        {
            error = V_FR_ERROR.MaterialNull;
            return;
        }

        string fragmentumTag = "FragmentumTag";
        string tag = _target.renderer.sharedMaterial.GetTag(fragmentumTag, false, "nothing");

        if(tag.IndexOf("Fragmentum") == -1)
        {
            error = V_FR_ERROR.NotFractumMaterial;

            return;
        }

        ModifyKeyWords();
    }
Exemplo n.º 4
0
    public override void OnInspectorGUI()
    {
        if (_target.enabled == false)
            return;

        GUILayout.Space(5);
        GUI.backgroundColor = Color.red;
        if (GUILayout.Button("Fragmentum 2 is available.\n With SM2 and SM3 support.\nFor Mac, Linux, iOS and Android.", GUILayout.Height(60)))
        {
            Application.OpenURL("https://www.assetstore.unity3d.com/#/content/8264");
        }
        GUI.backgroundColor = Color.white;
        GUILayout.Space(5);

        if (error != V_FR_ERROR.Ok && error != V_FR_ERROR.NotFractumMaterial)
        {
            GUILayout.Space(5);

            textStyle.normal.textColor = Color.red;
            EditorGUILayout.LabelField("Warning: " + error.ToString(), textStyle);

            About();

            return;
        }

        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        {
            GUILayout.Space(10);

            string fragmentumTag = "FragmentumTag";
            string tag = _target.renderer.sharedMaterial.GetTag(fragmentumTag, false, "nothing");

            if (tag.IndexOf("Fragmentum") == -1)
            {
                error = V_FR_ERROR.NotFractumMaterial;

                GUILayout.Space(5);
                textStyle.normal.textColor = Color.red;
                EditorGUILayout.LabelField("Warning: " + error.ToString(), textStyle);

                About();

                return;
            }

        EditorGUI.EndDisabledGroup();

            GUILayout.Space(5);
            //Activator
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            _target.fActivator = (Fragmentum.FRAGMENTUM_ACTIVATOR)EditorGUILayout.EnumPopup("Activator", _target.fActivator);
            EditorGUI.EndDisabledGroup();
            if (_target.fActivator == Fragmentum.FRAGMENTUM_ACTIVATOR.Plane)
            {
                if (!_target.planeObject)
                    GUI.backgroundColor = Color.red;
                _target.planeObject = (Transform)EditorGUILayout.ObjectField("   Activator Object", _target.planeObject, typeof(Transform), true);
                GUI.backgroundColor = Color.white;
            }

            if (_target.fActivator == Fragmentum.FRAGMENTUM_ACTIVATOR.Sphere)
            {
                if (!_target.sphereObject)
                    GUI.backgroundColor = Color.red;

                _target.sphereObject = (Transform)EditorGUILayout.ObjectField("   Activator Object", _target.sphereObject, typeof(Transform), true);
                GUI.backgroundColor = Color.white;

                if (_target.sphereObjectRadius == 0)
                    GUI.backgroundColor = Color.red;
                _target.sphereObjectRadius = EditorGUILayout.FloatField("   Activator Radius", _target.sphereObjectRadius);
                GUI.backgroundColor = Color.white;
            }

        }

        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        {
            GUILayout.Space(5);

            //_target.bUseNoise = EditorGUILayout.Toggle("Use Noise", _target.bUseNoise);

            UpdateShader();
        }

        EditorGUI.EndDisabledGroup();

        GUILayout.Space(10);
        _target.useUpdateFunction = EditorGUILayout.Toggle("Use Update Function", _target.useUpdateFunction);

        //Info();

        About();
    }