private void _dataList_DrawElement(Rect area, int index, bool isActive, bool isFocused)
        {
            Rect position;
            var  el = _dataList.serializedProperty.GetArrayElementAtIndex(index);

            position = CalcNextRect(ref area);
            SPEditorGUI.PropertyField(position, el.FindPropertyRelative(PROP_DATA_MODE));

            //TODO - member
            position = CalcNextRect(ref area);
            var memberProp = el.FindPropertyRelative(PROP_DATA_MEMBER);

            System.Type propType;
            memberProp.stringValue = i_TweenValueInspector.ReflectedPropertyAndCustomTweenAccessorField(position,
                                                                                                        EditorHelper.TempContent("Property", "The property on the target to set."),
                                                                                                        _targetProp.objectReferenceValue,
                                                                                                        memberProp.stringValue,
                                                                                                        com.spacepuppy.Dynamic.DynamicMemberAccess.ReadWrite,
                                                                                                        out propType);

            position = CalcNextRect(ref area);
            SPEditorGUI.PropertyField(position, el.FindPropertyRelative(PROP_DATA_EASE));

            position = CalcNextRect(ref area);
            this.DrawOption(position, ref propType, el.FindPropertyRelative(PROP_DATA_OPTION));

            position = CalcNextRect(ref area);
            SPEditorGUI.PropertyField(position, el.FindPropertyRelative(PROP_DATA_DUR));

            if (propType != null)
            {
                switch (el.FindPropertyRelative(PROP_DATA_MODE).GetEnumValue <TweenHash.AnimMode>())
                {
                case TweenHash.AnimMode.To:
                {
                    position = CalcNextRect(ref area);
                    this.DrawVariant(position, EditorHelper.TempContent("To Value"), propType, el.FindPropertyRelative(PROP_DATA_VALUES));

                    position = CalcNextRect(ref area);
                }
                break;

                case TweenHash.AnimMode.From:
                {
                    position = CalcNextRect(ref area);
                    this.DrawVariant(position, EditorHelper.TempContent("From Value"), propType, el.FindPropertyRelative(PROP_DATA_VALUES));
                }
                break;

                case TweenHash.AnimMode.By:
                {
                    position = CalcNextRect(ref area);
                    this.DrawVariant(position, EditorHelper.TempContent("By Value"), propType, el.FindPropertyRelative(PROP_DATA_VALUES));
                }
                break;

                case TweenHash.AnimMode.FromTo:
                {
                    position = CalcNextRect(ref area);
                    this.DrawVariant(position, EditorHelper.TempContent("Start Value"), propType, el.FindPropertyRelative(PROP_DATA_VALUES));

                    position = CalcNextRect(ref area);
                    this.DrawVariant(position, EditorHelper.TempContent("End Value"), propType, el.FindPropertyRelative(PROP_DATA_VALUEE));
                }
                break;

                case TweenHash.AnimMode.RedirectTo:
                {
                    position = CalcNextRect(ref area);
                    this.DrawVariant(position, EditorHelper.TempContent("Start Value"), propType, el.FindPropertyRelative(PROP_DATA_VALUES));

                    position = CalcNextRect(ref area);
                    this.DrawVariant(position, EditorHelper.TempContent("End Value"), propType, el.FindPropertyRelative(PROP_DATA_VALUEE));
                }
                break;
                }
            }
        }
Exemplo n.º 2
0
        /////////////////////////////////////////
        internal static void DrawLeftBottom(SceneView sceneView)
        {
            Rect rcPop    = new Rect(8, 0, 0, 24);
            Rect rcRad    = new Rect(12, 0, 160 - 4, 16);
            Rect rcToggle = new Rect(rcPop.max.x, 0, 16, 16);

            var cameras = UnityObject.FindObjectsOfType <Camera>();

            rcPop.y = Screen.height - (24 * 2) - (8 * 2);

            if (E.i.syncScene2Game)
            {
                string[] displayNames = new string[] { "None", "" };
                ArrayUtility.AddRange(ref displayNames, cameras.Select(c => c.name).ToArray());

                rcPop.width = 160;

                //GUI.skin = EditorGUIUtility.GetBuiltinSkin( EditorSkin.Inspector );
                s_cameraSelect = EditorGUI.Popup(rcPop, s_cameraSelect, displayNames, Styles.popup);

                // Match GameView

                int index = s_cameraSelect - 2;

                if (index >= 0 && index < cameras.Length)
                {
                    var camera = cameras[index];
                    if (s_gameviewMatch)
                    {
                        var a = camera.transform.rotation * Vector3.forward;
                        a *= 25.0f;
                        sceneView.pivot    = camera.transform.position + a;
                        sceneView.rotation = camera.transform.rotation;
                        sceneView.size     = 25.0f;

                        s_gameviewMatch = false;
                    }
                    else
                    {
                        camera.transform.position = sceneView.camera.transform.position;
                        camera.transform.rotation = sceneView.camera.transform.rotation;
                    }
                }
                else
                {
                    rcRad.y = rcPop.y - 16;
                    if (UnitySymbol.Has("UNITY_2019_3_OR_NEWER"))
                    {
                        rcRad.y -= 2;
                    }
                    var cont = EditorHelper.TempContent(S._MatchGameView);
                    var sz   = EditorStyles.toggle.CalcSize(cont);
                    rcRad.width = sz.x;
                    var rc = rcRad.AddW(2);
                    EditorGUI.DrawRect(rc, E.i.uiBkColor);
                    s_gameviewMatch = GUI.Toggle(rcRad, s_gameviewMatch, S._MatchGameView, Styles.toggle);
                }
            }


            // orthographic
            if (E.i.toggleOrthographic)
            {
                rcToggle.y = rcPop.y + 1;
                rcToggle.x = rcPop.x + rcPop.width;
                if (UnitySymbol.Has("UNITY_2019_3_OR_NEWER"))
                {
                    rcToggle.x += 2;
                }
                var cont = EditorHelper.TempContent("Iso");
                var sz   = EditorStyles.toggle.CalcSize(cont);
                rcToggle.width = sz.x;

                var rc = rcToggle.AddW(2);
                EditorGUI.DrawRect(rc, E.i.uiBkColor);
                sceneView.orthographic = GUI.Toggle(rcToggle, sceneView.orthographic, cont, Styles.toggle);
            }
        }
        private void NormalizeActionAndWeightArrays()
        {
            var go = GameObjectUtil.GetGameObjectFromSource(this.serializedObject.targetObject);

            if (go == null)
            {
                return;
            }

            var propActions    = this.serializedObject.FindProperty(PROP_ACTIONS);
            var propWeights    = this.serializedObject.FindProperty(PROP_WEIGHTS);
            var currentActions = go.GetComponents <IAIAction>();

            IAIAction[] serializedActions = new IAIAction[propActions.arraySize];
            for (int i = 0; i < serializedActions.Length; i++)
            {
                serializedActions[i] = propActions.GetArrayElementAtIndex(i).objectReferenceValue as IAIAction;
            }

            if (currentActions.Length == serializedActions.Length && currentActions.Compare(serializedActions))
            {
                if (propWeights.arraySize != serializedActions.Length)
                {
                    propWeights.arraySize = serializedActions.Length;
                }
                return;
            }

            var serializedWeights = (EditorHelper.GetTargetObjectOfProperty(propWeights) as DiminishingWeightOverDuration[]);

            if (serializedWeights == null)
            {
                serializedWeights = new DiminishingWeightOverDuration[] { }
            }
            ;
            else
            {
                serializedWeights = serializedWeights.ToArray();
            }

            propActions.arraySize = currentActions.Length;
            var   weights       = new List <DiminishingWeightOverDuration>();
            float defaultWeight = this.serializedObject.FindProperty(PROP_DEFAULTWEIGHT).floatValue;

            for (int i = 0; i < currentActions.Length; i++)
            {
                propActions.GetArrayElementAtIndex(i).objectReferenceValue = currentActions[i] as Component;

                int j = serializedActions.IndexOf(currentActions[i]);
                if (j >= 0 && j < serializedWeights.Length && serializedWeights[j] != null)
                {
                    weights.Add(serializedWeights[j]);
                }
                else
                {
                    Debug.Log(currentActions[i].GetType().Name + " had no weight");
                    weights.Add(new DiminishingWeightOverDuration(defaultWeight));
                }
            }
            this.serializedObject.ApplyModifiedProperties();
            EditorHelper.SetTargetObjectOfProperty(propWeights, weights.ToArray());
            this.serializedObject.Update();
        }
Exemplo n.º 4
0
        protected void showAbout()
        {
            EditorHelper.BannerFB();

            GUILayout.Space(3);
            GUILayout.Label(Util.Constants.ASSET_NAME, EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            {
                GUILayout.BeginVertical(GUILayout.Width(60));
                {
                    GUILayout.Label("Version:");

                    GUILayout.Space(12);

                    GUILayout.Label("Web:");

                    GUILayout.Space(2);

                    GUILayout.Label("Email:");
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.Width(170));
                {
                    GUILayout.Space(0);

                    GUILayout.Label(Util.Constants.ASSET_VERSION);

                    GUILayout.Space(12);

                    EditorGUILayout.SelectableLabel(Util.Constants.ASSET_AUTHOR_URL, GUILayout.Height(16), GUILayout.ExpandHeight(false));

                    GUILayout.Space(2);

                    EditorGUILayout.SelectableLabel(Util.Constants.ASSET_CONTACT, GUILayout.Height(16), GUILayout.ExpandHeight(false));
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                {
                    //GUILayout.Space(0);
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.Width(64));
                {
                    if (GUILayout.Button(new GUIContent(string.Empty, EditorHelper.Logo_Asset, "Visit asset website")))
                    {
                        Application.OpenURL(EditorConstants.ASSET_URL);
                    }

                    if (!Util.Constants.isPro)
                    {
                        if (GUILayout.Button(new GUIContent(" Upgrade", "Upgrade " + Util.Constants.ASSET_NAME + " to the PRO-version")))
                        {
                            Application.OpenURL(Util.Constants.ASSET_PRO_URL);
                        }
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            GUILayout.Label("© 2017-2019 by " + Util.Constants.ASSET_AUTHOR);

            EditorHelper.SeparatorUI();

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button(new GUIContent(" AssetStore", EditorHelper.Logo_Unity, "Visit the 'Unity AssetStore' website.")))
                {
                    Application.OpenURL(Util.Constants.ASSET_CT_URL);
                }

                if (GUILayout.Button(new GUIContent(" " + Util.Constants.ASSET_AUTHOR, EditorHelper.Logo_CT, "Visit the '" + Util.Constants.ASSET_AUTHOR + "' website.")))
                {
                    Application.OpenURL(Util.Constants.ASSET_AUTHOR_URL);
                }
            }
            GUILayout.EndHorizontal();

            EditorHelper.SeparatorUI();

            aboutTab = GUILayout.Toolbar(aboutTab, new string[] { "Readme", "Versions", "Update" });

            if (aboutTab == 2)
            {
                scrollPosAboutUpdate = EditorGUILayout.BeginScrollView(scrollPosAboutUpdate, false, false);
                {
                    Color fgColor = GUI.color;

                    GUI.color = Color.yellow;

                    if (updateStatus == UpdateStatus.NO_UPDATE)
                    {
                        GUI.color = Color.green;
                        GUILayout.Label(updateText);
                    }
                    else if (updateStatus == UpdateStatus.UPDATE)
                    {
                        GUILayout.Label(updateText);

                        if (GUILayout.Button(new GUIContent(" Download", "Visit the 'Unity AssetStore' to download the latest version.")))
                        {
                            //Application.OpenURL(Constants.ASSET_URL);
                            UnityEditorInternal.AssetStore.Open("content/" + EditorConstants.ASSET_ID);
                        }
                    }
                    else if (updateStatus == UpdateStatus.UPDATE_PRO)
                    {
                        GUILayout.Label(updateText);

                        if (GUILayout.Button(new GUIContent(" Upgrade", "Upgrade to the PRO-version in the 'Unity AssetStore'.")))
                        {
                            Application.OpenURL(Util.Constants.ASSET_PRO_URL);
                        }
                    }
                    else if (updateStatus == UpdateStatus.UPDATE_VERSION)
                    {
                        GUILayout.Label(updateText);

                        if (GUILayout.Button(new GUIContent(" Upgrade", "Upgrade to the newer version in the 'Unity AssetStore'")))
                        {
                            Application.OpenURL(Util.Constants.ASSET_CT_URL);
                        }
                    }
                    else if (updateStatus == UpdateStatus.DEPRECATED)
                    {
                        GUILayout.Label(updateText);

                        if (GUILayout.Button(new GUIContent(" More Information", "Visit the 'crosstales'-site for more information.")))
                        {
                            Application.OpenURL(Util.Constants.ASSET_AUTHOR_URL);
                        }
                    }
                    else
                    {
                        GUI.color = Color.cyan;
                        GUILayout.Label(updateText);
                    }

                    GUI.color = fgColor;
                }
                EditorGUILayout.EndScrollView();

                if (updateStatus == UpdateStatus.NOT_CHECKED || updateStatus == UpdateStatus.NO_UPDATE)
                {
                    bool isChecking = !(worker == null || (worker != null && !worker.IsAlive));

                    GUI.enabled = Util.Helper.isInternetAvailable && !isChecking;

                    if (GUILayout.Button(new GUIContent(isChecking ? "Checking... Please wait." : " Check For Update", EditorHelper.Icon_Check, "Checks for available updates of " + Util.Constants.ASSET_NAME)))
                    {
                        worker = new System.Threading.Thread(() => UpdateCheck.UpdateCheckForEditor(out updateText, out updateStatus));
                        worker.Start();
                    }

                    GUI.enabled = true;
                }
            }
            else if (aboutTab == 0)
            {
                if (readme == null)
                {
                    string path = Application.dataPath + EditorConfig.ASSET_PATH + "README.txt";

                    try
                    {
                        readme = System.IO.File.ReadAllText(path);
                    }
                    catch (System.Exception)
                    {
                        readme = "README not found: " + path;
                    }
                }

                scrollPosAboutReadme = EditorGUILayout.BeginScrollView(scrollPosAboutReadme, false, false);
                {
                    GUILayout.Label(readme);
                }
                EditorGUILayout.EndScrollView();
            }
            else
            {
                if (versions == null)
                {
                    string path = Application.dataPath + EditorConfig.ASSET_PATH + "Documentation/VERSIONS.txt";

                    try
                    {
                        versions = System.IO.File.ReadAllText(path);
                    }
                    catch (System.Exception)
                    {
                        versions = "VERSIONS not found: " + path;
                    }
                }

                scrollPosAboutVersions = EditorGUILayout.BeginScrollView(scrollPosAboutVersions, false, false);
                {
                    GUILayout.Label(versions);
                }

                EditorGUILayout.EndScrollView();
            }

            EditorHelper.SeparatorUI();

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button(new GUIContent(string.Empty, EditorHelper.Social_Discord, "Communicate with us via 'Discord'.")))
                {
                    Application.OpenURL(Util.Constants.ASSET_SOCIAL_DISCORD);
                }

                if (GUILayout.Button(new GUIContent(string.Empty, EditorHelper.Social_Facebook, "Follow us on 'Facebook'.")))
                {
                    Application.OpenURL(Util.Constants.ASSET_SOCIAL_FACEBOOK);
                }

                if (GUILayout.Button(new GUIContent(string.Empty, EditorHelper.Social_Twitter, "Follow us on 'Twitter'.")))
                {
                    Application.OpenURL(Util.Constants.ASSET_SOCIAL_TWITTER);
                }

                if (GUILayout.Button(new GUIContent(string.Empty, EditorHelper.Social_Linkedin, "Follow us on 'LinkedIn'.")))
                {
                    Application.OpenURL(Util.Constants.ASSET_SOCIAL_LINKEDIN);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(6);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Retrieve the actual data objects that are referenced
 /// </summary>
 /// <param name="serialDataProperty">The property that defines the location of the data to retrieve</param>
 /// <returns>Returns an array of the Data objects that were found or null if unable to find them</returns>
 private static SerialData[] GetPropertyValues(SerializedProperty serialDataProperty)
 {
     SerialData[] collection;
     EditorHelper.GetPropertyValues(serialDataProperty, out collection);
     return(collection);
 }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (EditorHelper.AssertMultiObjectEditingNotSupported(position, property, label))
            {
                return;
            }

            this.Init(property, label);

            //const float WIDTH_FOLDOUT = 5f;
            //if(!_alwaysExpanded) property.isExpanded = EditorGUI.Foldout(new Rect(position.xMin, position.yMin, WIDTH_FOLDOUT, EditorGUIUtility.singleLineHeight), property.isExpanded, GUIContent.none);
            if (!_alwaysExpanded)
            {
                property.isExpanded = EditorGUI.Foldout(new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight), property.isExpanded, GUIContent.none, true);
            }

            if (_alwaysExpanded || property.isExpanded)
            {
                if (_drawWeight)
                {
                    this.CalculateTotalWeight();
                }

                if (!_alwaysExpanded)
                {
                    GUI.Box(position, GUIContent.none);
                }

                position = new Rect(position.xMin + MARGIN, position.yMin + MARGIN, position.width - MARGIN * 2f, position.height - MARGIN * 2f);
                EditorGUI.BeginProperty(position, label, property);

                position = this.DrawList(position, property);
                position = this.DrawYieldToggle(position, property);
                position = this.DrawAdvancedTargetSettings(position, property);

                EditorGUI.EndProperty();

                if (Application.isPlaying && !property.serializedObject.isEditingMultipleObjects)
                {
                    var w    = position.width * 0.6f;
                    var pad  = (position.width - w) / 2f;
                    var rect = new Rect(position.xMin + pad, position.yMax + -BTN_ACTIVATE_HEIGHT + 2f, w, 20f);
                    if (GUI.Button(rect, "Activate Trigger"))
                    {
                        var targ = EditorHelper.GetTargetObjectOfProperty(property) as Trigger;
                        if (targ != null)
                        {
                            targ.ActivateTrigger(property.serializedObject.targetObject, null);
                        }
                    }
                }
            }
            else
            {
                EditorGUI.BeginProperty(position, label, property);

                ReorderableListHelper.DrawRetractedHeader(position, label, EditorHelper.TempContent("Trigger Targets"));

                EditorGUI.EndProperty();
            }
        }
        public void OnGUI(Rect position, SerializedProperty property)
        {
            //if (property.propertyType != SerializedPropertyType.ObjectReference || !TypeUtil.IsType(_restrictionType, typeof(Component), typeof(IComponent)))
            if (property.propertyType != SerializedPropertyType.ObjectReference || (!this.AllowNonComponents && !ComponentUtil.IsAcceptableComponentType(this.RestrictionType)))
            {
                this.DrawAsMismatchedAttribute(position, property);
                return;
            }

            this.Init();

            GameObject targGo;

            if (this.ForceOnlySelf)
            {
                targGo = GameObjectUtil.GetGameObjectFromSource(property.serializedObject.targetObject);
                if (targGo == null)
                {
                    this.DrawAsMismatchedAttribute(position, property);
                    return;
                }

                if (property.objectReferenceValue == null)
                {
                    property.objectReferenceValue = this.GetTargetFromSource(targGo);
                }
            }

            targGo = GameObjectUtil.GetGameObjectFromSource(property.objectReferenceValue);
            if (property.objectReferenceValue == null)
            {
                //SPEditorGUI.DefaultPropertyField(position, property, label);
                if (!this.ForceOnlySelf)
                {
                    this.DrawObjectRefField(position, property);
                }
                else
                {
                    EditorGUI.LabelField(position, "Malformed serializable field.");
                }
            }
            else if (this.AllowNonComponents)
            {
                if (targGo == null)
                {
                    this.DrawObjectRefField(position, property);
                }
                else
                {
                    this.ChoiceSelector.BeforeGUI(this, property, this.ComponentRestrictionType, this.AllowProxy);
                    var components = this.ChoiceSelector.GetComponents();

                    var fullsize = position;
                    if (components.Length == 0 ||
                        (this.ShowXButton && SPEditorGUI.XButton(ref position, "Clear Selected Object", this.XButtonOnRightSide)))
                    {
                        property.objectReferenceValue = null;
                        fullsize = this.DrawDotDotButton(fullsize, property);
                        this.DrawObjectRefField(fullsize, property);

                        this.ChoiceSelector.GUIComplete(property, -1);
                    }
                    else
                    {
                        position = this.DrawDotDotButton(position, property);
                        var names = this.ChoiceSelector.GetPopupEntries();
                        System.Array.Resize(ref names, names.Length + 1);
                        names[names.Length - 1] = EditorHelper.TempContent(targGo.name + " (...GameObject)");

                        int oi = (property.objectReferenceValue is GameObject) ? names.Length - 1 : this.ChoiceSelector.GetPopupIndexOfComponent(property.objectReferenceValue as Component);
                        int ni = EditorGUI.Popup(position, oi, names);

                        if (oi != ni)
                        {
                            if (ni == names.Length - 1)
                            {
                                property.objectReferenceValue = targGo;
                            }
                            else
                            {
                                property.objectReferenceValue = this.ChoiceSelector.GetComponentAtPopupIndex(ni);
                            }

                            //if (ni < components.Length)
                            //    property.objectReferenceValue = this.ChoiceSelector.GetComponentAtPopupIndex(ni);
                            //else
                            //    property.objectReferenceValue = targGo;
                        }

                        this.ChoiceSelector.GUIComplete(property, ni);
                    }
                }
            }
            else
            {
                this.ChoiceSelector.BeforeGUI(this, property, this.ComponentRestrictionType, this.AllowProxy);
                var components = this.ChoiceSelector.GetComponents();

                var fullsize = position;
                if (components.Length == 0 ||
                    (this.ShowXButton && SPEditorGUI.XButton(ref position, "Clear Selected Object", this.XButtonOnRightSide)))
                {
                    property.objectReferenceValue = null;
                    fullsize = this.DrawDotDotButton(fullsize, property);
                    this.DrawObjectRefField(fullsize, property);

                    this.ChoiceSelector.GUIComplete(property, -1);
                }
                else
                {
                    position = this.DrawDotDotButton(position, property);
                    var names = this.ChoiceSelector.GetPopupEntries();
                    int oi    = this.ChoiceSelector.GetPopupIndexOfComponent(property.objectReferenceValue as Component);
                    int ni    = EditorGUI.Popup(position, oi, names);
                    if (oi != ni)
                    {
                        property.objectReferenceValue = this.ChoiceSelector.GetComponentAtPopupIndex(ni);
                    }

                    this.ChoiceSelector.GUIComplete(property, ni);
                }
            }
        }
 private static void AddVoiceInitalizer()
 {
     EditorHelper.InstantiatePrefab("VoiceInitalizer");
     GAApi.Event(typeof(RTVoiceMenu).Name, "Add VoiceInitalizer");
 }
Exemplo n.º 9
0
 public static void SetSelectHeroModels()
 {
     EditorHelper.ExportSelection("SetSelectCharacterModel ", ImporterHeroModel.ImportSelectFolder, SelectionMode.TopLevel);
 }
 private static void AddSequencer()
 {
     EditorHelper.InstantiatePrefab("Sequencer");
     GAApi.Event(typeof(RTVoiceMenu).Name, "Add Sequencer");
 }
 private static void AddLoudspeaker()
 {
     EditorHelper.InstantiatePrefab("Loudspeaker");
     GAApi.Event(typeof(RTVoiceMenu).Name, "Add Loudspeaker");
 }
 private static void AddSpeechText()
 {
     EditorHelper.InstantiatePrefab("SpeechText");
     GAApi.Event(typeof(RTVoiceMenu).Name, "Add SpeechText");
 }
 private static void AddAudioFileGenerator()
 {
     EditorHelper.InstantiatePrefab("AudioFileGenerator");
     GAApi.Event(typeof(RTVoiceMenu).Name, "Add AudioFileGenerator");
 }
 private static void AddRTVoice()
 {
     EditorHelper.InstantiatePrefab(Util.Constants.RTVOICE_SCENE_OBJECT_NAME);
     GAApi.Event(typeof(RTVoiceMenu).Name, "Add " + Util.Constants.RTVOICE_SCENE_OBJECT_NAME);
 }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var targ = (Interval)EditorHelper.GetTargetObjectOfProperty(property);

            var   attrib             = this.fieldInfo.GetCustomAttributes(typeof(Interval.ConfigAttribute), false).Cast <Interval.ConfigAttribute>().FirstOrDefault();
            bool  reverse            = (attrib != null) ? attrib.Reverse : false;
            float minValue           = (attrib != null) ? attrib.MinValue : float.NegativeInfinity;
            float maxValue           = (attrib != null) ? attrib.MaxValue : float.PositiveInfinity;
            bool  discreteValuesOnly = (attrib != null) ? attrib.DiscreteValuesOnly : false;


            GUIContent[] subLabels;
            float        labelWidth;

            if (reverse)
            {
                subLabels  = (attrib != null) ? new GUIContent[] { EditorHelper.TempContent(attrib.MaxLabel), EditorHelper.TempContent(attrib.MinLabel) } : _defaultLabels;
                labelWidth = (attrib != null) ? attrib.LabelWidth : 30f;
                _values[1] = targ.Min;
                _values[0] = targ.Max;
            }
            else
            {
                subLabels  = (attrib != null) ? new GUIContent[] { EditorHelper.TempContent(attrib.MinLabel), EditorHelper.TempContent(attrib.MaxLabel) } : _defaultLabels;
                labelWidth = (attrib != null) ? attrib.LabelWidth : 30f;
                _values[0] = targ.Min;
                _values[1] = targ.Max;
            }

            EditorGUI.BeginProperty(position, label, property);
            EditorGUI.BeginChangeCheck();
            SPEditorGUI.MultiFloatField(position, label, subLabels, _values, labelWidth);
            if (EditorGUI.EndChangeCheck())
            {
                _values[0] = Mathf.Clamp(_values[0], minValue, maxValue);
                _values[1] = Mathf.Clamp(_values[1], minValue, maxValue);
                if (discreteValuesOnly)
                {
                    _values[0] = Mathf.Round(_values[0]);
                }
                if (discreteValuesOnly)
                {
                    _values[1] = Mathf.Round(_values[1]);
                }

                if (reverse)
                {
                    targ.SetExtents(_values[1], _values[0]);
                }
                else
                {
                    targ.SetExtents(_values[0], _values[1]);
                }
                EditorHelper.SetTargetObjectOfProperty(property, targ);
            }
            EditorGUI.EndProperty();
        }
Exemplo n.º 16
0
        // **************************************************************************************************
        // Following properties and function only valid while editing
        // **************************************************************************************************

#if UNITY_EDITOR
        /// <summary>
        /// Allow the motion to render it's own GUI
        /// </summary>
        public override bool OnInspectorGUI()
        {
            bool lIsDirty = false;

            lIsDirty = base.OnInspectorGUI();

            EditorGUILayout.BeginVertical(GUI.skin.box);

            EditorGUILayout.BeginHorizontal();

            if (EditorHelper.BoolField(IsYawEnabled, "Yaw Enabled", RigController, 16f))
            {
                lIsDirty     = true;
                IsYawEnabled = EditorHelper.FieldBoolValue;
            }

            EditorGUILayout.LabelField(new GUIContent("Yaw", "Manages the rotation around the character's up axis."));

            EditorGUILayout.EndHorizontal();

            if (IsYawEnabled)
            {
                if (EditorHelper.FloatField("Speed", "Degrees per second to rotate.", YawSpeed, RigController))
                {
                    lIsDirty = true;
                    YawSpeed = EditorHelper.FieldFloatValue;
                }

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(new GUIContent("Range", "Angular range (min & max) for the rotation from -180 to 180"), GUILayout.Width(EditorGUIUtility.labelWidth - (EditorGUIUtility.currentViewWidth < 292 ? 18f : 4f)));

                if (EditorHelper.FloatField(MinYaw, "Min Yaw", RigController))
                {
                    lIsDirty = true;
                    MinYaw   = EditorHelper.FieldFloatValue;
                }

                if (EditorHelper.FloatField(MaxYaw, "Max Yaw", RigController))
                {
                    lIsDirty = true;
                    MaxYaw   = EditorHelper.FieldFloatValue;
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);

            EditorGUILayout.BeginHorizontal();

            if (EditorHelper.BoolField(IsPitchEnabled, "Pitch Enabled", RigController, 16f))
            {
                lIsDirty       = true;
                IsPitchEnabled = EditorHelper.FieldBoolValue;
            }

            EditorGUILayout.LabelField(new GUIContent("Pitch", "Manages the rotation around the character's up axis."));

            EditorGUILayout.EndHorizontal();

            if (IsPitchEnabled)
            {
                if (EditorHelper.BoolField("Invert", "Determines if we invert the pitch", InvertPitch, RigController))
                {
                    lIsDirty    = true;
                    InvertPitch = EditorHelper.FieldBoolValue;
                }

                if (EditorHelper.FloatField("Speed", "Degrees per second to rotate.", PitchSpeed, RigController))
                {
                    lIsDirty   = true;
                    PitchSpeed = EditorHelper.FieldFloatValue;
                }

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(new GUIContent("Range", "Angular range (min & max) for the rotation from -180 to 180"), GUILayout.Width(EditorGUIUtility.labelWidth - (EditorGUIUtility.currentViewWidth < 292 ? 18f : 4f)));

                if (EditorHelper.FloatField(MinPitch, "Min Pitch", RigController))
                {
                    lIsDirty = true;
                    MinPitch = EditorHelper.FieldFloatValue;
                }

                if (EditorHelper.FloatField(MaxPitch, "Max Pitch", RigController))
                {
                    lIsDirty = true;
                    MaxPitch = EditorHelper.FieldFloatValue;
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();

            if (EditorHelper.FloatField("Smoothing", "Smoothing factor applied to the rotations. Use 0 to have no smoothing and 1 for lots of smoothing. 0.05 to 0.2 is usually good.", Smoothing, RigController))
            {
                lIsDirty  = true;
                Smoothing = EditorHelper.FieldFloatValue;
            }

            return(lIsDirty);
        }
Exemplo n.º 17
0
    public static void GenerateJsTypeInfo(bool displayDialog)
    {
        var    fileInfoSb = new StringBuilder();
        string workingDir = Application.dataPath.Replace("/Assets", "");
        var    args       = new args();

        // working dir
        args.AddFormat("/dir:\"{0}\"", workingDir);
        args.AddFormat("/out:\"{0}\"", JsTypeInfoFile);
        args.AddFormat("/template:\"{0}\"", JsTypeInfoFileTemplate);
        args.AddFormat("/format:\"{0}\"", JsTypeFormat);

        var exportList  = GetExportFiles();
        var exportCount = exportList.Count;

        foreach (var filePath in exportList)
        {
            fileInfoSb.AppendLine(filePath.Replace(Application.dataPath, ""));
            args.Add("\"" + filePath.Replace(workingDir, ".") + "\"");
        }

        // 把参数写到文件中,然后把这个文件路径做为参数传递给 skc5.exe
        string argFile = GetTempFileNameFullPath("JsTypeGenerator_Args.txt");
        string strArgs = args.Format(args.ArgsFormat.Space);

        File.WriteAllText(argFile, strArgs);

        string addTypeInfoFile = GetTempFileNameFullPath(FilesToAddJsType);

        File.WriteAllText(addTypeInfoFile, fileInfoSb.ToString());
        AssetDatabase.Refresh();

        if (displayDialog)
        {
            if (!EditorUtility.DisplayDialog("TIP",
                                             "Total: " + exportCount + "file prepare to Add [JsType]",
                                             "OK",
                                             "Cancel"))
            {
                Debug.Log("Operation canceled.");
                return;
            }
        }

#if UNITY_EDITOR_WIN
        string exePath   = Path.Combine(workingDir, JsTypeGeneratorPath);
        string arguments = String.Format("/paramFile:\"{0}\"", argFile);
#else
        string exePath   = "/usr/local/bin/mono";
        string arguments = Path.Combine(workingDir, JsTypeGeneratorPath) + string.Format(" /paramFile:\"{0}\"", argFile);
#endif
        var processInfo = new ProcessStartInfo
        {
            CreateNoWindow         = true,
            UseShellExecute        = false,
            RedirectStandardOutput = true,
            RedirectStandardError  = true,
            FileName  = exePath,
            Arguments = arguments
        };

        var    process   = Process.Start(processInfo);
        string outputLog = process.StandardOutput.ReadToEnd();
        string errorLog  = process.StandardError.ReadToEnd();
        // 等待结束
        process.WaitForExit();

        Debug.LogError(outputLog);
        int exitCode = process.ExitCode;
        process.Close();
        if (exitCode != 0)
        {
            EditorUtility.DisplayDialog("JsTypeGenerator", "Generate failed. exit code = " + exitCode, "OK");
            if (!String.IsNullOrEmpty(errorLog))
            {
                Debug.LogError(errorLog);
            }
            throw new SystemException(errorLog);
        }

        //每次生成JsTypeInfo,清空一下JsTypeNameSet
        _jsTypeNameSet = null;
        if (displayDialog)
        {
            EditorUtility.DisplayDialog("JsTypeGenerator", "GenerateJsTypeInfo success.", "OK");
        }

        // 刷新前改一下文件格式,减少编译时间
        EditorHelper.SetFileFormatToUTF8_BOM(JsTypeInfoFile);

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
        protected override void OnSPInspectorGUI()
        {
            this.serializedObject.Update();

            this.DrawDefaultInspectorExcept("_target", "_memberName", "_value", "_mode");
            this.DrawPropertyField("_target"); //uses the SelectableComponent PropertyDrawer

            var targProp   = this.serializedObject.FindProperty("_target");
            var memberProp = this.serializedObject.FindProperty("_memberName");
            var valueProp  = this.serializedObject.FindProperty("_value");
            var modeProp   = this.serializedObject.FindProperty("_mode");

            //SELECT MEMBER
            System.Reflection.MemberInfo selectedMember;
            memberProp.stringValue = SPEditorGUILayout.ReflectedPropertyField(EditorHelper.TempContent("Property", "The property on the target to set."),
                                                                              targProp.objectReferenceValue,
                                                                              memberProp.stringValue,
                                                                              out selectedMember);
            this.serializedObject.ApplyModifiedProperties();


            //MEMBER VALUE TO SET TO
            if (selectedMember != null)
            {
                var propType = com.spacepuppy.Dynamic.DynamicUtil.GetParameters(selectedMember).FirstOrDefault();
                var emode    = modeProp.GetEnumValue <i_SetValue.SetMode>();
                if (emode == i_SetValue.SetMode.Toggle)
                {
                    //EditorGUILayout.LabelField(EditorHelper.TempContent(valueProp.displayName), EditorHelper.TempContent(propType.Name));
                    var evtp = VariantReference.GetVariantType(propType);
                    GUI.enabled = false;
                    EditorGUILayout.EnumPopup(EditorHelper.TempContent(valueProp.displayName), evtp);
                    GUI.enabled = true;
                }
                else
                {
                    if (propType == typeof(object))
                    {
                        //draw the default variant as the method accepts anything
                        _variantDrawer.RestrictVariantType = false;
                        _variantDrawer.ForcedObjectType    = null;
                        _variantDrawer.OnGUI(EditorGUILayout.GetControlRect(), valueProp, EditorHelper.TempContent("Value", "The value to set to."));
                    }
                    else
                    {
                        var argType = VariantReference.GetVariantType(propType);
                        _variantDrawer.RestrictVariantType     = true;
                        _variantDrawer.VariantTypeRestrictedTo = argType;
                        _variantDrawer.ForcedObjectType        = propType;
                        _variantDrawer.OnGUI(EditorGUILayout.GetControlRect(), valueProp, EditorHelper.TempContent("Value", "The value to set to."));
                    }
                }

                if (com.spacepuppy.Dynamic.Evaluator.WillArithmeticallyCompute(propType))
                {
                    EditorGUILayout.PropertyField(modeProp);
                }
                else
                {
                    //modeProp.SetEnumValue(i_SetValue.SetMode.Set);
                    EditorGUI.BeginChangeCheck();
                    emode = (i_SetValue.SetMode)SPEditorGUILayout.EnumPopupExcluding(EditorHelper.TempContent(modeProp.displayName), emode, i_SetValue.SetMode.Decrement, i_SetValue.SetMode.Increment);
                    if (EditorGUI.EndChangeCheck())
                    {
                        modeProp.SetEnumValue(emode);
                    }
                }
            }
            else
            {
                modeProp.SetEnumValue(i_SetValue.SetMode.Set);
            }

            this.serializedObject.ApplyModifiedProperties();
        }
 private void _targetList_DrawHeader(Rect area)
 {
     EditorGUI.LabelField(area, _currentLabel, EditorHelper.TempContent("Trigger Targets"));
 }
Exemplo n.º 20
0
            public override void OnInspectorGUI()
            {
                base.OnInspectorGUI();

                if (AudioCollection.Instance == null)
                {
                    if (AudioCollection.Instance == null)
                    {
                        EditorGUILayout.HelpBox("AudioSFX require AudioCollection. " +
                                                "To create AudioCollection, select Resources folder then from Create Menu " +
                                                "select RUtilities/Create Audio Collection", MessageType.Error);
                    }
                    return;
                }

                if (mScript.mClips.Length > 0)
                {
                    EditorHelper.BoxVertical(() =>
                    {
                        for (int i = 0; i < mScript.mClips.Length; i++)
                        {
                            EditorHelper.BoxHorizontal(() =>
                            {
                                EditorHelper.TextField(mScript.mClips[i], "");
                                if (EditorHelper.ButtonColor("x", Color.red, 24))
                                {
                                    var list = mScript.mClips.ToList();
                                    list.Remove(mScript.mClips[i]);
                                    mScript.mClips = list.ToArray();
                                }
                            });
                        }
                    }, Color.yellow, true);
                }

                EditorHelper.BoxVertical(() =>
                {
                    mSearch = EditorHelper.TextField(mSearch, "Search");
                    if (!string.IsNullOrEmpty(mSearch))
                    {
                        var clips = AudioCollection.Instance.sfxClips;
                        if (clips != null && clips.Length > 0)
                        {
                            for (int i = 0; i < clips.Length; i++)
                            {
                                if (clips[i].name.ToLower().Contains(mSearch.ToLower()))
                                {
                                    if (GUILayout.Button(clips[i].name))
                                    {
                                        var list = mScript.mClips.ToList();
                                        if (!list.Contains(clips[i].name))
                                        {
                                            list.Add(clips[i].name);
                                            mScript.mClips = list.ToArray();
                                            mSearch        = "";
                                            EditorGUI.FocusTextInControl(null);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("No results", MessageType.Warning);
                        }
                    }
                }, Color.white, true);

                if (EditorHelper.ButtonColor("Open Sounds Collection"))
                {
                    Selection.activeObject = AudioCollection.Instance;
                }

                if (mButton != null)
                {
                    if (EditorHelper.ButtonColor("Add to OnClick event"))
                    {
                        UnityAction action = new UnityAction(mScript.PlaySFX);
                        UnityEventTools.AddVoidPersistentListener(mButton.onClick, action);
                    }
                }

                if (GUI.changed)
                {
                    EditorUtility.SetDirty(mScript);
                }
            }
 private void DrawAsMismatchedAttribute(Rect position, SerializedProperty property)
 {
     EditorGUI.LabelField(position, EditorHelper.TempContent("Mismatched type of PropertyDrawer attribute with field."));
 }
Exemplo n.º 22
0
        // **************************************************************************************************
        // Following properties and function only valid while editing
        // **************************************************************************************************

#if UNITY_EDITOR
        /// <summary>
        /// Used to render out the inspector for the shape
        /// </summary>
        /// <returns></returns>
        public override bool OnInspectorGUI(UnityEngine.Object rTarget)
        {
            bool lIsDirty = false;

            EditorHelper.DrawSmallTitle("Body Sphere");

            if (_Parent != null)
            {
                //ActorController lController = _Parent.GetComponent<ActorController>();
                //if (lController != null)
                //{
                //    if (lController.OverlapRadius < _Radius)
                //    {
                //        Color lGUIColor = GUI.color;
                //        GUI.color = new Color(1f, 0.7f, 0.7f, 1f);
                //        EditorGUILayout.HelpBox("Overlap radius is less than this radius. Increase overlap radius so collisions can be found.", MessageType.Warning);
                //        GUI.color = lGUIColor;
                //    }

                //    if (_Offset.y <= _Radius && lController.BaseRadius != _Radius && (_Transform == null || _Transform == _Parent))
                //    {
                //        Color lGUIColor = GUI.color;
                //        GUI.color = new Color(1f, 0.7f, 0.7f, 1f);
                //        EditorGUILayout.HelpBox("This shape sits on the ground. So, the 'Grounding Radius' above should probably be the same radius as this shape.", MessageType.Warning);
                //        GUI.color = lGUIColor;
                //    }

                //    //if (lController.MaxStepHeight > Offset.y && _IsEnabledOnGround)
                //    //{
                //    //    Color lGUIColor = GUI.color;
                //    //    GUI.color = new Color(1f, 0.7f, 0.7f, 1f);
                //    //    EditorGUILayout.HelpBox("The step height is higher than the offset. This could cause low collisions to be ignored.", MessageType.Warning);
                //    //    GUI.color = lGUIColor;
                //    //}
                //}
            }

            GUILayout.Space(5);

            if (EditorHelper.TextField("Name", "", Name, rTarget))
            {
                lIsDirty = true;
                Name     = EditorHelper.FieldStringValue;
            }

            if (EditorHelper.FloatField("Radius", "", Radius, rTarget))
            {
                lIsDirty = true;
                Radius   = EditorHelper.FieldFloatValue;
            }

            if (EditorHelper.BoolField("Use Unity Colliders", "Determines if we generate unity colliders to match the body shapes.", UseUnityColliders, rTarget))
            {
                lIsDirty          = true;
                UseUnityColliders = EditorHelper.FieldBoolValue;
            }

            GUILayout.Space(5f);

            if (EditorHelper.BoolField("Enabled on ground", "Determines if the shape is valid while on the ground.", IsEnabledOnGround, rTarget))
            {
                lIsDirty          = true;
                IsEnabledOnGround = EditorHelper.FieldBoolValue;
            }

            if (EditorHelper.BoolField("Enabled on ramp", "Determines if the shape is valid while on a slope.", IsEnabledOnSlope, rTarget))
            {
                lIsDirty         = true;
                IsEnabledOnSlope = EditorHelper.FieldBoolValue;
            }

            if (EditorHelper.BoolField("Enabled in air", "Determines if the shape is valid while in the air.", IsEnabledAboveGround, rTarget))
            {
                lIsDirty             = true;
                IsEnabledAboveGround = EditorHelper.FieldBoolValue;
            }

            GUILayout.Space(5);

            if (EditorHelper.ObjectField <Transform>("Center Transform", "", Transform, rTarget))
            {
                lIsDirty  = true;
                Transform = EditorHelper.FieldObjectValue as Transform;
            }

            if (EditorHelper.Vector3Field("Center Offset", "", Offset, rTarget))
            {
                lIsDirty = true;
                Offset   = EditorHelper.FieldVector3Value;
            }

            return(lIsDirty);
        }
Exemplo n.º 23
0
        protected void showHelp()
        {
            EditorHelper.BannerFB();

            scrollPosHelp = EditorGUILayout.BeginScrollView(scrollPosHelp, false, false);
            {
                GUILayout.Label("Resources", EditorStyles.boldLabel);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.BeginVertical();
                    {
                        if (GUILayout.Button(new GUIContent(" Manual", EditorHelper.Icon_Manual, "Show the manual.")))
                        {
                            Application.OpenURL(Util.Constants.ASSET_MANUAL_URL);
                        }

                        GUILayout.Space(6);

                        if (GUILayout.Button(new GUIContent(" Forum", EditorHelper.Icon_Forum, "Visit the forum page.")))
                        {
                            Application.OpenURL(Util.Constants.ASSET_FORUM_URL);
                        }
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical();
                    {
                        if (GUILayout.Button(new GUIContent(" API", EditorHelper.Icon_API, "Show the API.")))
                        {
                            Application.OpenURL(Util.Constants.ASSET_API_URL);
                        }

                        GUILayout.Space(6);

                        if (GUILayout.Button(new GUIContent(" Product", EditorHelper.Icon_Product, "Visit the product page.")))
                        {
                            Application.OpenURL(Util.Constants.ASSET_WEB_URL);
                        }
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();

                EditorHelper.SeparatorUI();

                GUILayout.Label("Videos", EditorStyles.boldLabel);

                /*
                 * GUILayout.BeginHorizontal();
                 * {
                 *  if (GUILayout.Button(new GUIContent(" Promo", EditorHelper.Video_Promo, "View the promotion video on 'Youtube'.")))
                 *  {
                 *      Application.OpenURL(Constants.ASSET_VIDEO_PROMO);
                 *      GAApi.Event(typeof(ConfigBase).Name, "ASSET_VIDEO_PROMO");
                 *  }
                 *
                 *  if (GUILayout.Button(new GUIContent(" Tutorial", EditorHelper.Video_Tutorial, "View the tutorial video on 'Youtube'.")))
                 *  {
                 *      Application.OpenURL(Constants.ASSET_VIDEO_TUTORIAL);
                 *      GAApi.Event(typeof(ConfigBase).Name, "ASSET_VIDEO_TUTORIAL");
                 *  }
                 * }
                 * GUILayout.EndHorizontal();
                 *
                 * GUILayout.Space(6);
                 */

                if (GUILayout.Button(new GUIContent(" All Videos", EditorHelper.Icon_Videos, "Visit our 'Youtube'-channel for more videos.")))
                {
                    Application.OpenURL(Util.Constants.ASSET_SOCIAL_YOUTUBE);
                }

                EditorHelper.SeparatorUI();

                GUILayout.Label("3rd Party Assets", EditorStyles.boldLabel);

                if (GUILayout.Button(new GUIContent(string.Empty, EditorHelper.Asset_PlayMaker, "More information about 'PlayMaker'.")))
                {
                    Application.OpenURL(Util.Constants.ASSET_3P_PLAYMAKER);
                }
            }
            EditorGUILayout.EndScrollView();

            GUILayout.Space(6);
        }
Exemplo n.º 24
0
    //在第一次渲染此控件时调用
    public void Init()
    {
        if (initFlag)
        {
            return;
        }
        initFlag = true;

        if (mainViewTexture == null)
        {
            mainViewTexture = new RenderTexture(512, 512, 24);
        }

        if (null == assistantViewTexture)
        {
            assistantViewTexture = new RenderTexture(128, 128, 24);
        }

        if (mainViewRoot == null)
        {
            mainViewRoot      = new GameObject();
            mainViewRoot.name = _GenMainViewRootName();
            //为此视图分配唯一的原点
            mainViewRoot.transform.position = _GenMainViewOrigin();
            if (!EditorHelper.IsDebugMode())
            {
                mainViewRoot.hideFlags = HideFlags.HideAndDontSave;
            }
            mainViewRoot.layer = MainViewCtrl.s_layer;
        }

        if (refModelBindingTarget == null)
        {
            refModelBindingTarget                         = new GameObject();
            refModelBindingTarget.name                    = "_RefModelBindingPoint";
            refModelBindingTarget.transform.parent        = mainViewRoot.transform;
            refModelBindingTarget.transform.localPosition = Vector3.zero;
            if (!EditorHelper.IsDebugMode())
            {
                refModelBindingTarget.hideFlags = HideFlags.HideAndDontSave;
            }
            refModelBindingTarget.layer = MainViewCtrl.s_layer;
        }

        if (editObjBindingTarget == null)
        {
            editObjBindingTarget                         = new GameObject();
            editObjBindingTarget.name                    = "_EditObjBindingPoint";
            editObjBindingTarget.transform.parent        = mainViewRoot.transform;
            editObjBindingTarget.transform.localPosition = Vector3.zero;
            if (!EditorHelper.IsDebugMode())
            {
                editObjBindingTarget.hideFlags = HideFlags.HideAndDontSave;
            }
            editObjBindingTarget.layer = MainViewCtrl.s_layer;
        }

        //非3D视图不创建栅格网格
        if (gridMeshObj == null && !Is2DView)
        {
            gridMeshObj                         = new GameObject();
            gridMeshObj.name                    = "_GridMeshObject";
            gridMeshObj.transform.parent        = mainViewRoot.transform;
            gridMeshObj.transform.localPosition = Vector3.zero;
            if (!EditorHelper.IsDebugMode())
            {
                gridMeshObj.hideFlags = HideFlags.HideAndDontSave;
            }
            gridMeshObj.layer = MainViewCtrl.s_layer;

            MeshRenderer gridMeshRenderer = gridMeshObj.AddComponent <MeshRenderer>();

            gridMeshRenderer.material = new Material(Shader.Find("Diffuse"));
            MeshFilter gridMeshFilter = gridMeshObj.AddComponent <MeshFilter>();
            Mesh       gridMesh       = new Mesh();
            _BuildGridMesh(gridMesh);
            gridMeshFilter.mesh = gridMesh;
        }

        #region MainCamera
        if (mainCam == null)
        {
            camObj                  = new GameObject();
            camObj.name             = "_MainViewCamera";
            camObj.transform.parent = mainViewRoot.transform;

            if (!is2DView)
            {
                camObj.transform.localPosition = new Vector3(0, 0, -5);
            }
            else
            {
                camObj.transform.localPosition = new Vector3(0, 0, -10);
            }

            camObj.layer = MainViewCtrl.s_layer;
            center       = Vector3.zero;
            radius       = 10f;

            if (!EditorHelper.IsDebugMode())
            {
                camObj.hideFlags = HideFlags.HideAndDontSave;
            }

            //若为3D视口
            if (!is2DView)
            {//初始化相机位置
                Transform camTrans               = camObj.transform;
                float     angleRotateAroundUp    = 135.0f;
                float     angleRotateAroundRight = 45.0f;

                Vector3 localPos = (camTrans.localPosition - center).normalized * radius;

                Quaternion q0 = Quaternion.AngleAxis(angleRotateAroundUp, camTrans.up);
                camTrans.localPosition = q0 * localPos;
                camTrans.Rotate(Vector3.up, angleRotateAroundUp, Space.Self);

                Quaternion q1 = Quaternion.AngleAxis(angleRotateAroundRight, camTrans.right);
                camTrans.Rotate(Vector3.right, angleRotateAroundRight, Space.Self);
                camTrans.localPosition = q1 * camTrans.localPosition;

                camTrans.localPosition += center;
            }


            Camera camera = camObj.AddComponent <Camera>();
            camera.clearFlags      = CameraClearFlags.Color;
            camera.backgroundColor = bkColor;


            camera.nearClipPlane = 1f;
            camera.farClipPlane  = 1000f;
            camera.targetTexture = mainViewTexture;

            if (!is2DView)
            {
                camera.orthographic = false;
                camera.aspect       = 1.0f;
            }
            else
            {
                camera.orthographic     = true;
                camera.orthographicSize = 10f;
            }
            camera.cullingMask = ~0;
            mainCam            = camera;
        }
        #endregion

        //if (null == axisMeshObj && !Is2DView)
        //{
        //    float angleRotateAroundUp = 135.0f;
        //    float angleRotateAroundRight = 45.0f;

        //    axisMeshObj = new GameObject();
        //    axisMeshObj.name = "_AxisMeshObjet";
        //    axisMeshObj.transform.parent = camObj.transform;
        //    axisMeshObj.transform.localPosition = new Vector3(0.5f, 0, 2f);
        //    axisMeshObj.transform.Rotate(Vector3.up, angleRotateAroundUp, Space.Self);
        //    //axisMeshObj.transform.Rotate(Vector3.forward, 0f, Space.World);
        //    axisMeshObj.transform.Rotate(Vector3.right, angleRotateAroundRight, Space.Self);

        //    if (!EditorHelper.IsDebugMode())
        //    {
        //        axisMeshObj.hideFlags = HideFlags.HideAndDontSave;
        //    }

        //    axisMeshObj.layer = MainViewCtrl.s_layer;

        //    MeshRenderer axisMeshRenderer = axisMeshObj.AddComponent<MeshRenderer>();

        //    axisMeshRenderer.material = new Material(Shader.Find("Transparent/Diffuse"));
        //    MeshFilter axisMeshFilter = axisMeshObj.AddComponent<MeshFilter>();
        //    //axisMeshRenderer.material.color = Color.green;

        //    Mesh axisMesh = new Mesh();
        //    _BuildTestCubeMesh(axisMesh);
        //    axisMeshFilter.mesh = axisMesh;
        //}

        #region AssistantCamera
        if (
            (null == assistantCam) &&
            isShowAxis
            )
        {
            assCentter = s_assistantViewOrigion;

            assistantCamObj      = new GameObject();
            assistantCamObj.name = "_AssistantCamera";
            assistantCamObj.transform.position = new Vector3(assCentter.x, assCentter.y, assCentter.z - assRadius);

            assistantCamObj.layer = MainViewCtrl.s_layer;

            if (!EditorHelper.IsDebugMode())
            {
                assistantCamObj.hideFlags = HideFlags.HideAndDontSave;
            }

            //若为3D视口
            if (!is2DView)
            {//初始化相机位置
                Transform assistantCamTrans      = assistantCamObj.transform;
                float     angleRotateAroundUp    = 135.0f;
                float     angleRotateAroundRight = 45.0f;

                Vector3 localPos = (assistantCamTrans.localPosition - assCentter).normalized * assRadius;

                Quaternion q0 = Quaternion.AngleAxis(angleRotateAroundUp, assistantCamTrans.up);
                assistantCamTrans.localPosition = q0 * localPos;
                assistantCamTrans.Rotate(Vector3.up, angleRotateAroundUp, Space.Self);

                Quaternion q1 = Quaternion.AngleAxis(angleRotateAroundRight, assistantCamTrans.right);
                assistantCamTrans.Rotate(Vector3.right, angleRotateAroundRight, Space.Self);
                assistantCamTrans.localPosition = q1 * assistantCamTrans.localPosition;

                assistantCamTrans.localPosition += assCentter;
            }

            Camera camera = assistantCamObj.AddComponent <Camera>();
            camera.clearFlags = CameraClearFlags.Color;
            Color32 color = Color.black;
            color.a = 0;
            camera.backgroundColor = color;

            camera.nearClipPlane = 1f;
            camera.farClipPlane  = 10;
            camera.targetTexture = assistantViewTexture;

            camera.orthographic = false;
            camera.aspect       = 1.0f;

            camera.cullingMask = ~0;
            assistantCam       = camera;
        }
        #endregion

        if (mainLight == null)
        {
            //将方向光挂接在相机下
            mainLight                         = new GameObject();
            mainLight.name                    = "_MainDirLight";
            mainLight.transform.parent        = camObj.transform;
            mainLight.transform.localPosition = Vector3.zero;
            mainLight.transform.localRotation = Quaternion.identity;
            if (!EditorHelper.IsDebugMode())
            {
                mainLight.hideFlags = HideFlags.HideAndDontSave;
            }
            Light light = mainLight.AddComponent <Light>();
            light.type      = LightType.Directional;
            light.intensity = 0.2f;
            mainLight.layer = MainViewCtrl.s_layer;
        }

        if (
            (null == assLight) &&
            isShowAxis
            )
        {
            //将方向光挂接在相机下
            assLight                         = new GameObject();
            assLight.name                    = "_AssDirLight";
            assLight.transform.parent        = assistantCamObj.transform;
            assLight.transform.localPosition = Vector3.zero;
            assLight.transform.localRotation = Quaternion.AngleAxis(180f, assLight.transform.up);
            if (!EditorHelper.IsDebugMode())
            {
                assLight.hideFlags = HideFlags.HideAndDontSave;
            }
            Light light = assLight.AddComponent <Light>();
            light.type      = LightType.Directional;
            light.intensity = 1.2f;

            light.cullingMask = unchecked ((int)0x80000000);
            assLight.layer    = MainViewCtrl.s_AssLayer;
        }
    }
            /// <summary>
            /// Custom inspector.
            /// </summary>
            protected override void Inspector()
            {
                VintageHudson thisTarget = (VintageHudson)target;

                thisTarget.Overlay = EditorHelper.Slider(@"Overlay", thisTarget.Overlay, 0.0f, 1.0f, 0.25f);
            }
Exemplo n.º 26
0
 static Clipboard()
 {
     instancePath = EditorHelper.GetScriptableAssetsPath() + "/Clipboard.asset";
 }
Exemplo n.º 27
0
 public override void Deactivate()
 {
     EditorHelper.SetDependencyProperty(textBlock, TextBlock.TextProperty, textEditor.Text);
     base.Deactivate();
 }
Exemplo n.º 28
0
 public static Clipboard GetInstance()
 {
     return(EditorHelper.LazyLoadScriptableAsset <Clipboard>(ref _instance, instancePath, true));
 }
Exemplo n.º 29
0
 private void RemoveDataTemplates()
 {
     EditorHelper.UnregisterResources(_resourceDictionary);
     _resourceDictionary = null;
 }
        public static string ReflectedPropertyAndCustomTweenAccessorField(Rect position, GUIContent label, object targObj, string selectedMemberName, DynamicMemberAccess access, out System.Type propType)
        {
            if (targObj != null)
            {
                var members   = DynamicUtil.GetEasilySerializedMembers(targObj, System.Reflection.MemberTypes.Field | System.Reflection.MemberTypes.Property, access).ToArray();
                var accessors = CustomTweenMemberAccessorFactory.GetCustomAccessorIds(targObj.GetType(), (d) => VariantReference.AcceptableType(d.MemberType));
                System.Array.Sort(accessors);

                using (var entries = TempCollection.GetList <GUIContent>(members.Length))
                {
                    int index = -1;
                    for (int i = 0; i < members.Length; i++)
                    {
                        var m = members[i];
                        if ((DynamicUtil.GetMemberAccessLevel(m) & DynamicMemberAccess.Write) != 0)
                        {
                            entries.Add(EditorHelper.TempContent(string.Format("{0} ({1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, DynamicUtil.GetValueWithMember(m, targObj))));
                        }
                        else
                        {
                            entries.Add(EditorHelper.TempContent(string.Format("{0} (readonly - {1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, DynamicUtil.GetValueWithMember(m, targObj))));
                        }

                        if (index < 0 && m.Name == selectedMemberName)
                        {
                            //index = i;
                            index = entries.Count - 1;
                        }
                    }

                    for (int i = 0; i < accessors.Length; i++)
                    {
                        entries.Add(EditorHelper.TempContent(accessors[i]));
                        if (index < 0 && accessors[i] == selectedMemberName)
                        {
                            index = entries.Count - 1;
                        }
                    }


                    index = EditorGUI.Popup(position, label, index, entries.ToArray());
                    //selectedMember = (index >= 0) ? members[index] : null;
                    //return (selectedMember != null) ? selectedMember.Name : null;

                    if (index < 0)
                    {
                        propType = null;
                        return(null);
                    }
                    else if (index < members.Length)
                    {
                        propType = DynamicUtil.GetReturnType(members[index]);
                        return(members[index].Name);
                    }
                    else
                    {
                        var nm = accessors[index - members.Length];

                        /*
                         * ITweenMemberAccessor acc;
                         * if (CustomTweenMemberAccessorFactory.TryGetMemberAccessor(targObj, nm, out acc))
                         * {
                         *  propType = acc.GetMemberType();
                         *  if (VariantReference.AcceptableType(propType))
                         *  {
                         *      return nm;
                         *  }
                         * }
                         */
                        CustomTweenMemberAccessorFactory.CustomAccessorData info;
                        if (CustomTweenMemberAccessorFactory.TryGetMemberAccessorInfo(targObj, nm, out info))
                        {
                            propType = info.MemberType;
                            if (VariantReference.AcceptableType(propType))
                            {
                                return(nm);
                            }
                        }
                    }

                    propType = null;
                    return(null);
                }
            }
            else
            {
                propType = null;
                EditorGUI.Popup(position, label, -1, new GUIContent[0]);
                return(null);
            }
        }