Наследование: MonoBehaviour
Пример #1
0
    public override void Awake()
    {
        base.Awake();

        if( componentToOnOff != null ) {
            if( componentToOnOff is VJBaseModifier ) {
                _modifierToOnOff = componentToOnOff as VJBaseModifier;
                _componentEnabled = _modifierToOnOff.isModifierEnabled;
            } else {
                _componentEnabled = componentToOnOff.enabled;
            }
        }
    }
Пример #2
0
    public override void Awake()
    {
        base.Awake();

        if (componentToOnOff != null)
        {
            if (componentToOnOff is VJBaseModifier)
            {
                _modifierToOnOff  = componentToOnOff as VJBaseModifier;
                _componentEnabled = _modifierToOnOff.isModifierEnabled;
            }
            else
            {
                _componentEnabled = componentToOnOff.enabled;
            }
        }
    }
Пример #3
0
    public override void OnInspectorGUI()
    {
        // Setup the SerializedProperties
        serializedObject.Update();
        GUI.changed = false;

        // modifier = target as VJBaseModifier;

        if (!serializedObject.isEditingMultipleObjects)
        {
            if (!isModifierEnabledProperty.boolValue)
            {
                EditorGUILayout.HelpBox("Diabled from On-Off Switch", MessageType.None);
            }
        }

        VJAbstractManager[] managers = UnityEngine.Object.FindObjectsOfType(typeof(VJAbstractManager)) as VJAbstractManager[];
        if (managers.Length > 0)
        {
            string[] options_managers = new string[managers.Length];
            for (int i = 0; i < managers.Length; ++i)
            {
                options_managers[i] = managers[i].gameObject.name;
                if (managerProperty.objectReferenceValue == managers[i])
                {
                    index = i;
                }
            }
            if (managerProperty.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("Manager is currently null. please select and set value.", MessageType.Warning);
            }

            index = EditorGUILayout.Popup(
                "Manager:",
                index,
                options_managers);

            managerProperty.objectReferenceValue = managers[index];

            GameObject             go      = managers[index].gameObject;
            VJAbstractDataSource[] sources = go.GetComponents <VJAbstractDataSource>() as VJAbstractDataSource[];
            if (sources.Length > 0)
            {
                string[] options_sources = new string[sources.Length];
                for (int i = 0; i < sources.Length; ++i)
                {
                    options_sources[i] = sources[i].sourceName;
                    if (datasourceProperty.objectReferenceValue == sources[i])
                    {
                        index_src = i;
                    }
                }

                EditorGUI.showMixedValue = datasourceProperty.hasMultipleDifferentValues;
                index_src = EditorGUILayout.Popup(
                    "DataSource:",
                    (datasourceProperty.hasMultipleDifferentValues?-1:index_src),
                    options_sources);
                EditorGUI.showMixedValue = false;

                //modifier.source = sources[index_src];
                if (index_src >= sources.Length)
                {
                    index_src = 0;
                }
                if (index_src >= 0)
                {
                    datasourceProperty.objectReferenceValue = sources[index_src];
                }
                if (datasourceProperty.objectReferenceValue == null)
                {
                    EditorGUILayout.HelpBox("DataSource is currently null. please select and set value.", MessageType.Warning);
                }

                if (boostByOtherSourceProperty.boolValue)
                {
                    int index_boostMgrs = 0;
                    for (int i = 0; i < managers.Length; ++i)
                    {
                        if (boostManagerProperty.objectReferenceValue == managers[i])
                        {
                            index_boostMgrs = i;
                        }
                    }
                    EditorGUI.showMixedValue = boostManagerProperty.hasMultipleDifferentValues;
                    index_boostMgrs          = EditorGUILayout.Popup(
                        "BoostManager:",
                        index_boostMgrs,
                        options_managers);
                    EditorGUI.showMixedValue = false;
                    boostManagerProperty.objectReferenceValue = managers[index_boostMgrs];

                    go = managers[index_boostMgrs].gameObject;
                    VJAbstractDataSource[] boostSources = go.GetComponents <VJAbstractDataSource>() as VJAbstractDataSource[];
                    index_src = 0;
                    if (boostSources.Length > 0)
                    {
                        string[] options_boostSources = new string[boostSources.Length];
                        for (int i = 0; i < boostSources.Length; ++i)
                        {
                            options_boostSources[i] = boostSources[i].sourceName;
                            if (boostDatasourceProperty.objectReferenceValue == boostSources[i])
                            {
                                index_src = i;
                            }
                        }

                        EditorGUI.showMixedValue = boostDatasourceProperty.hasMultipleDifferentValues;
                        index_src = EditorGUILayout.Popup(
                            "DataSource:",
                            (boostDatasourceProperty.hasMultipleDifferentValues?-1:index_src),
                            options_boostSources);
                        EditorGUI.showMixedValue = false;

                        if (index_src >= 0)
                        {
                            boostDatasourceProperty.objectReferenceValue = boostSources[index_src];
                        }
                    }
                }
                //EditorUtility.SetDirty(target);
            }
            else
            {
                EditorGUILayout.LabelField("No DataSource found");
            }
        }
        else
        {
            EditorGUILayout.LabelField("No VJManager found");
        }

        serializedObject.ApplyModifiedProperties();

        base.OnInspectorGUI();

        if (GUILayout.Button("Target Children"))
        {
            if (serializedObject.isEditingMultipleObjects)
            {
                foreach (UnityEngine.Object o in targets)
                {
                    VJBaseModifier m = o as VJBaseModifier;
                    m.multiple = true;
                    m.SetVisibleChildrenAsTarget();
                }
            }
            else
            {
                VJBaseModifier m = target as VJBaseModifier;
                m.multiple = true;
                m.SetVisibleChildrenAsTarget();
            }
        }

        Rect r = GUILayoutUtility.GetLastRect();

        r.width -= 16;
        r.x     += 8;
        if (serializedObject.isEditingMultipleObjects)
        {
            foreach (UnityEngine.Object o in targets)
            {
                //EditorGUILayout.Space();
                VJBaseModifier m = o as VJBaseModifier;
                r.y     += 20;
                r.height = 16;
                EditorGUILayout.BeginVertical();
                GUILayout.Space(20.0f);
                EditorGUI.ProgressBar(r, m.lastReturnedValue / VJAbstractDataSource.s_prog_max, m.gameObject.name + " value:" + m.lastReturnedValue);
                EditorGUILayout.EndVertical();
            }
        }
        else
        {
            VJBaseModifier m = target as VJBaseModifier;
            r.y     += 20;
            r.height = 16;
            EditorGUILayout.BeginVertical();
            GUILayout.Space(20.0f);
            EditorGUI.ProgressBar(r, m.lastReturnedValue / VJAbstractDataSource.s_prog_max, "value:" + m.lastReturnedValue);
            EditorGUILayout.EndVertical();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
    public override void OnInspectorGUI()
    {
        GUI.changed = false;

        modifier = target as VJBaseModifier;

        if(!modifier.isModifierEnabled) {
            EditorGUILayout.HelpBox("Diabled from On-Off Switch", MessageType.None);
        }

          		VJAbstractManager[] managers = UnityEngine.Object.FindObjectsOfType(typeof(VJAbstractManager)) as VJAbstractManager[];
          		if( managers.Length > 0 ) {
            string[] options_managers = new string[managers.Length];
            for(int i = 0; i < managers.Length; ++i) {
                options_managers[i] = managers[i].gameObject.name;
                if( modifier.manager == managers[i] ) {
                    index = i;
                }
            }

            index = EditorGUILayout.Popup(
                "Manager:",
                index,
                options_managers);

            modifier.manager = managers[index];
            //EditorUtility.SetDirty(target);

            GameObject go = managers[index].gameObject;
            VJAbstractDataSource[] sources = go.GetComponents<VJAbstractDataSource>() as VJAbstractDataSource[];
            if( sources.Length > 0 ) {
                string[] options_sources = new string[sources.Length];
                for(int i = 0; i < sources.Length; ++i) {
                    options_sources[i] = sources[i].sourceName;
                    if( modifier.source == sources[i] ) {
                        index_src = i;
                    }
                }

                index_src = EditorGUILayout.Popup(
                    "DatSource:",
                    index_src,
                    options_sources);

                modifier.source = sources[index_src];
                //EditorUtility.SetDirty(target);
            } else {
                EditorGUILayout.LabelField("No DataSource found");
            }
          		} else {
          			EditorGUILayout.LabelField("No VJManager found");
          		}

        base.OnInspectorGUI();

        //		modifier.multiple = EditorGUILayout.Toggle("Multiple", modifier.multiple);
        //		if(modifier.multiple) {
        ////			Rect r = GUILayoutUtility.GetLastRect();
        ////			r.x += 8;
        ////			r.width -= 16;
        ////			r.y += 20;
        ////			r.height = 16;
        //			//GUILayout.Space(72.0f);
        //			EditorGUILayout.PropertyField (serializedObject.FindProperty ("targets"), GUIContent.none);
        //		}

        if(GUILayout.Button("Target Children")) {
            modifier.multiple = true;
            modifier.SetVisibleChildrenAsTarget();
        }

        //EditorGUILayout.Space();
        Rect r = GUILayoutUtility.GetLastRect();
        r.x += 8;
        r.width -= 16;
        r.y += 20;
        r.height = 16;
        EditorGUILayout.BeginVertical();
        GUILayout.Space(32.0f);
        EditorGUI.ProgressBar(r, modifier.lastReturnedValue / VJAbstractDataSource.s_prog_max, "value:"+modifier.lastReturnedValue);
        EditorGUILayout.EndVertical();

        if (GUI.changed) {
            EditorUtility.SetDirty(target);
        }
    }
Пример #5
0
    public override void OnInspectorGUI()
    {
        GUI.changed = false;

        modifier = target as VJBaseModifier;

        if (!modifier.isModifierEnabled)
        {
            EditorGUILayout.HelpBox("Diabled from On-Off Switch", MessageType.None);
        }

        VJAbstractManager[] managers = UnityEngine.Object.FindObjectsOfType(typeof(VJAbstractManager)) as VJAbstractManager[];
        if (managers.Length > 0)
        {
            string[] options_managers = new string[managers.Length];
            for (int i = 0; i < managers.Length; ++i)
            {
                options_managers[i] = managers[i].gameObject.name;
                if (modifier.manager == managers[i])
                {
                    index = i;
                }
            }

            index = EditorGUILayout.Popup(
                "Manager:",
                index,
                options_managers);

            modifier.manager = managers[index];
            //EditorUtility.SetDirty(target);

            GameObject             go      = managers[index].gameObject;
            VJAbstractDataSource[] sources = go.GetComponents <VJAbstractDataSource>() as VJAbstractDataSource[];
            if (sources.Length > 0)
            {
                string[] options_sources = new string[sources.Length];
                for (int i = 0; i < sources.Length; ++i)
                {
                    options_sources[i] = sources[i].sourceName;
                    if (modifier.source == sources[i])
                    {
                        index_src = i;
                    }
                }

                index_src = EditorGUILayout.Popup(
                    "DatSource:",
                    index_src,
                    options_sources);

                modifier.source = sources[index_src];
                //EditorUtility.SetDirty(target);
            }
            else
            {
                EditorGUILayout.LabelField("No DataSource found");
            }
        }
        else
        {
            EditorGUILayout.LabelField("No VJManager found");
        }

        base.OnInspectorGUI();

//		modifier.multiple = EditorGUILayout.Toggle("Multiple", modifier.multiple);
//		if(modifier.multiple) {
////			Rect r = GUILayoutUtility.GetLastRect();
////			r.x += 8;
////			r.width -= 16;
////			r.y += 20;
////			r.height = 16;
//			//GUILayout.Space(72.0f);
//			EditorGUILayout.PropertyField (serializedObject.FindProperty ("targets"), GUIContent.none);
//		}

        if (GUILayout.Button("Target Children"))
        {
            modifier.multiple = true;
            modifier.SetVisibleChildrenAsTarget();
        }

        //EditorGUILayout.Space();
        Rect r = GUILayoutUtility.GetLastRect();

        r.x     += 8;
        r.width -= 16;
        r.y     += 20;
        r.height = 16;
        EditorGUILayout.BeginVertical();
        GUILayout.Space(32.0f);
        EditorGUI.ProgressBar(r, modifier.lastReturnedValue / VJAbstractDataSource.s_prog_max, "value:" + modifier.lastReturnedValue);
        EditorGUILayout.EndVertical();


        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }