Ejemplo n.º 1
0
    private void CreatePreset()
    {
#if UNITY_EDITOR
        GenericPreset newPreset = target is MaterialExplorer?
                                  GenericPreset.Create(((MaterialExplorer)target).properties) :
                                      GenericPreset.Create(target, GetPropertyNames(propertiesCSV));

        string path = presetsPath + "/Presets";
        if (!AssetDatabase.IsValidFolder(path))
        {
            AssetDatabase.CreateFolder(presetsPath, "Presets");
        }

        string        newName  = string.IsNullOrEmpty(newPresetName) ? "Generic" + DateTime.Now.Ticks : newPresetName;
        string        fullPath = path + "/" + newName + ".asset";
        GenericPreset existing = AssetDatabase.LoadAssetAtPath <GenericPreset> (fullPath);

        if (existing != null)
        {
            fullPath = path + "/" + newName + "_" + DateTime.Now.Ticks + ".asset";
        }

        AssetDatabase.CreateAsset(newPreset, fullPath);
#endif
    }
Ejemplo n.º 2
0
    public static IEnumerator TransitionFromToCoroutine(object originData, GenericPreset goal, MonoBehaviour target, float duration, UnityAction onCompleted = null, GenericPreset store = null)
    {
        GenericPreset origin = null;

        if (originData == null && target is MaterialExplorer)
        {
            origin = GenericPreset.Create((( MaterialExplorer )target).Explore(goal));
        }

        if (originData is string [])
        {
            GenericPreset.Create(target, originData as string []);
        }

        if (store == null)
        {
            store = ScriptableObject.CreateInstance <GenericPreset> ();
        }


        float startTime = Time.time;
        float t         = 0f;

        while (t < 1f)
        {
            //Debug.LogFormat ( "Transition generic preset {0}", t );

            GenericPreset.Lerp(origin, goal, t, store);
            t = (Time.time - startTime) / duration;

            if (target is MaterialExplorer)
            {
                store.ApplyMaterial((( MaterialExplorer )target).material);
            }
            else
            {
                store.Apply(target);
            }

            yield return(new WaitForFixedUpdate());
        }

        if (target is MaterialExplorer)
        {
            store.ApplyMaterial((( MaterialExplorer )target).material);
        }
        else
        {
            store.Apply(target);
        }
    }
Ejemplo n.º 3
0
    protected void Start()
    {
        values           = GenericPreset.Create(target, GenericPresetsUtil.GetPropertyNames(propertiesCSV));
        presetProperties = new PresetProperties {
            p = values.properties
        };

        firebase = FirebaseManager.Instance;

        if (firebase == null)
        {
            firebase = gameObject.AddComponent <FirebaseManager> ();
            FirebaseManager.IsAdmin = true;
            firebase.id             = "default";
        }

        if (firebase != null)
        {
            firebase.ExecuteOnInitialisation(OnFirebaseReady);
        }
    }