Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (15)
Tags (450)
master
2020.1
2020.2
2019.4
2019.3
2018.4
2017.4
2019.2
2019.1
2018.3
2018.2
2017.2
2018.1
2017.1
2017.3
202010b12
202010b11
202020a13
201940f1
2019年3月15日f1
202010b10
202020a12
202010b9
2019年3月14日f1
202020a11
2018年4月23日f1
2017440f1
2019年3月13日f1
202020a10
202010b8
2019年3月12日f1
202020a9
202010b7
2018年4月22日f1
202010b6
master
Branches (15)
Tags (450)
master
2020.1
2020.2
2019.4
2019.3
2018.4
2017.4
2019.2
2019.1
2018.3
2018.2
2017.2
2018.1
2017.1
2017.3
202010b12
202010b11
202020a13
201940f1
2019年3月15日f1
202010b10
202020a12
202010b9
2019年3月14日f1
202020a11
2018年4月23日f1
2017440f1
2019年3月13日f1
202020a10
202010b8
2019年3月12日f1
202020a9
202010b7
2018年4月22日f1
202010b6
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (15)
Tags (450)
master
2020.1
2020.2
2019.4
2019.3
2018.4
2017.4
2019.2
2019.1
2018.3
2018.2
2017.2
2018.1
2017.1
2017.3
202010b12
202010b11
202020a13
201940f1
2019年3月15日f1
202010b10
202020a12
202010b9
2019年3月14日f1
202020a11
2018年4月23日f1
2017440f1
2019年3月13日f1
202020a10
202010b8
2019年3月12日f1
202020a9
202010b7
2018年4月22日f1
202010b6
UVModuleUI.cs 11.71 KB
Copy Edit Raw Blame History
Unity Technologies authored 2020年04月14日 22:50 +08:00 . Unity 202020a7 C# reference source code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using UnityEngine;
using UnityEditorInternal;
namespace UnityEditor
{
class UVModuleUI : ModuleUI
{
SerializedProperty m_Mode;
SerializedProperty m_TimeMode;
SerializedProperty m_FPS;
SerializedMinMaxCurve m_FrameOverTime;
SerializedMinMaxCurve m_StartFrame;
SerializedProperty m_SpeedRange;
SerializedProperty m_TilesX;
SerializedProperty m_TilesY;
SerializedProperty m_AnimationType;
SerializedProperty m_RowMode;
SerializedProperty m_RowIndex;
SerializedProperty m_Sprites;
SerializedProperty m_Cycles;
SerializedProperty m_UVChannelMask;
class Texts
{
public GUIContent mode = EditorGUIUtility.TrTextContent("Mode", "Animation frames can either be specified on a regular grid texture, or as a list of Sprites.");
public GUIContent timeMode = EditorGUIUtility.TrTextContent("Time Mode", "Play frames either based on the lifetime of the particle, the speed of the particle, or at a constant FPS, regardless of particle lifetime.");
public GUIContent fps = EditorGUIUtility.TrTextContent("FPS", "Specify the Frames Per Second of the animation.");
public GUIContent frameOverTime = EditorGUIUtility.TrTextContent("Frame over Time", "Controls the uv animation frame of each particle over its lifetime. On the horizontal axis you will find the lifetime. On the vertical axis you will find the sheet index.");
public GUIContent startFrame = EditorGUIUtility.TrTextContent("Start Frame", "Phase the animation, so it starts on a frame other than 0.");
public GUIContent speedRange = EditorGUIUtility.TrTextContent("Speed Range", "Remaps speed in the defined range to a 0-1 value through the animation.");
public GUIContent tiles = EditorGUIUtility.TrTextContent("Tiles", "Defines the tiling of the texture.");
public GUIContent tilesX = EditorGUIUtility.TextContent("X");
public GUIContent tilesY = EditorGUIUtility.TextContent("Y");
public GUIContent animation = EditorGUIUtility.TrTextContent("Animation", "Specifies the animation type: Whole Sheet or Single Row. Whole Sheet will animate over the whole texture sheet from left to right, top to bottom. Single Row will animate a single row in the sheet from left to right.");
public GUIContent rowMode = EditorGUIUtility.TrTextContent("Row Mode", "Determine how the row is selected for each particle.");
public GUIContent row = EditorGUIUtility.TrTextContent("Row", "The row in the sheet which will be played.");
public GUIContent sprites = EditorGUIUtility.TrTextContent("Sprites", "The list of Sprites to be played.");
public GUIContent frame = EditorGUIUtility.TrTextContent("Frame", "The frame in the sheet which will be used.");
public GUIContent cycles = EditorGUIUtility.TrTextContent("Cycles", "Specifies how many times the animation will loop during the lifetime of the particle.");
public GUIContent uvChannelMask = EditorGUIUtility.TrTextContent("Affected UV Channels", "Specifies which UV channels will be animated.");
public GUIContent[] modes = new GUIContent[]
{
EditorGUIUtility.TrTextContent("Grid"),
EditorGUIUtility.TrTextContent("Sprites")
};
public GUIContent[] timeModes = new GUIContent[]
{
EditorGUIUtility.TrTextContent("Lifetime"),
EditorGUIUtility.TrTextContent("Speed"),
EditorGUIUtility.TrTextContent("FPS")
};
public GUIContent[] types = new GUIContent[]
{
EditorGUIUtility.TrTextContent("Whole Sheet"),
EditorGUIUtility.TrTextContent("Single Row")
};
public GUIContent[] rowModes = new GUIContent[]
{
EditorGUIUtility.TrTextContent("Custom"),
EditorGUIUtility.TrTextContent("Random"),
EditorGUIUtility.TrTextContent("Mesh Index")
};
}
private static Texts s_Texts;
public UVModuleUI(ParticleSystemUI owner, SerializedObject o, string displayName)
: base(owner, o, "UVModule", displayName)
{
m_ToolTip = "Particle UV animation. This allows you to specify a texture sheet (a texture with multiple tiles/sub frames) and animate or randomize over it per particle.";
}
protected override void Init()
{
// Already initialized?
if (m_TilesX != null)
return;
if (s_Texts == null)
s_Texts = new Texts();
m_Mode = GetProperty("mode");
m_TimeMode = GetProperty("timeMode");
m_FPS = GetProperty("fps");
m_FrameOverTime = new SerializedMinMaxCurve(this, s_Texts.frameOverTime, "frameOverTime");
m_StartFrame = new SerializedMinMaxCurve(this, s_Texts.startFrame, "startFrame");
m_StartFrame.m_AllowCurves = false;
m_SpeedRange = GetProperty("speedRange");
m_TilesX = GetProperty("tilesX");
m_TilesY = GetProperty("tilesY");
m_AnimationType = GetProperty("animationType");
m_RowMode = GetProperty("rowMode");
m_RowIndex = GetProperty("rowIndex");
m_Sprites = GetProperty("sprites");
m_Cycles = GetProperty("cycles");
m_UVChannelMask = GetProperty("uvChannelMask");
}
override public void OnInspectorGUI(InitialModuleUI initial)
{
int mode = GUIPopup(s_Texts.mode, m_Mode, s_Texts.modes);
if (!m_Mode.hasMultipleDifferentValues)
{
if (mode == (int)ParticleSystemAnimationMode.Grid)
{
GUIIntDraggableX2(s_Texts.tiles, s_Texts.tilesX, m_TilesX, s_Texts.tilesY, m_TilesY);
int type = GUIPopup(s_Texts.animation, m_AnimationType, s_Texts.types);
if (type == (int)ParticleSystemAnimationType.SingleRow)
{
GUIPopup(s_Texts.rowMode, m_RowMode, s_Texts.rowModes);
if (!m_RowMode.hasMultipleDifferentValues && m_RowMode.intValue == (int)ParticleSystemAnimationRowMode.Custom)
GUIInt(s_Texts.row, m_RowIndex);
m_FrameOverTime.m_RemapValue = (float)(m_TilesX.intValue);
m_StartFrame.m_RemapValue = (float)(m_TilesX.intValue);
}
else
{
m_FrameOverTime.m_RemapValue = (float)(m_TilesX.intValue * m_TilesY.intValue);
m_StartFrame.m_RemapValue = (float)(m_TilesX.intValue * m_TilesY.intValue);
}
}
else
{
DoListOfSpritesGUI();
ValidateSpriteList();
m_FrameOverTime.m_RemapValue = (float)(m_Sprites.arraySize);
m_StartFrame.m_RemapValue = (float)(m_Sprites.arraySize);
}
}
ParticleSystemAnimationTimeMode timeMode = (ParticleSystemAnimationTimeMode)GUIPopup(s_Texts.timeMode, m_TimeMode, s_Texts.timeModes);
if (!m_TimeMode.hasMultipleDifferentValues)
{
if (timeMode == ParticleSystemAnimationTimeMode.FPS)
{
GUIFloat(s_Texts.fps, m_FPS);
foreach (ParticleSystem ps in m_ParticleSystemUI.m_ParticleSystems)
{
if (ps.main.startLifetimeMultiplier == Mathf.Infinity)
{
EditorGUILayout.HelpBox("FPS mode does not work when using infinite particle lifetimes.", MessageType.Error, true);
break;
}
}
}
else if (timeMode == ParticleSystemAnimationTimeMode.Speed)
{
GUIMinMaxRange(s_Texts.speedRange, m_SpeedRange);
}
else
{
GUIMinMaxCurve(s_Texts.frameOverTime, m_FrameOverTime);
}
}
GUIMinMaxCurve(s_Texts.startFrame, m_StartFrame);
if (!m_TimeMode.hasMultipleDifferentValues && timeMode != ParticleSystemAnimationTimeMode.FPS)
GUIFloat(s_Texts.cycles, m_Cycles);
GUIEnumMaskUVChannelFlags(s_Texts.uvChannelMask, m_UVChannelMask);
}
private void DoListOfSpritesGUI()
{
if (m_Sprites.hasMultipleDifferentValues)
{
EditorGUILayout.HelpBox("Sprite editing is only available when all selected Particle Systems contain the same number of Sprites.", MessageType.Info, true);
return;
}
for (int i = 0; i < m_Sprites.arraySize; i++)
{
GUILayout.BeginHorizontal();
SerializedProperty spriteData = m_Sprites.GetArrayElementAtIndex(i);
SerializedProperty sprite = spriteData.FindPropertyRelative("sprite");
GUIObject(new GUIContent(" "), sprite, typeof(Sprite));
// add plus button to first element
if (i == 0)
{
if (GUILayout.Button(GUIContent.none, "OL Plus", GUILayout.Width(16)))
{
m_Sprites.InsertArrayElementAtIndex(m_Sprites.arraySize);
SerializedProperty newSpriteData = m_Sprites.GetArrayElementAtIndex(m_Sprites.arraySize - 1);
SerializedProperty newSprite = newSpriteData.FindPropertyRelative("sprite");
newSprite.objectReferenceValue = null;
}
}
// add minus button to all other elements
else
{
if (GUILayout.Button(GUIContent.none, "OL Minus", GUILayout.Width(16)))
m_Sprites.DeleteArrayElementAtIndex(i);
}
GUILayout.EndHorizontal();
}
}
private void ValidateSpriteList()
{
if (m_Sprites.hasMultipleDifferentValues)
return;
if (m_Sprites.arraySize <= 1)
return;
Texture texture = null;
for (int i = 0; i < m_Sprites.arraySize; i++)
{
SerializedProperty spriteData = m_Sprites.GetArrayElementAtIndex(i);
SerializedProperty prop = spriteData.FindPropertyRelative("sprite");
Sprite sprite = prop.objectReferenceValue as Sprite;
if (sprite != null)
{
if (texture == null)
{
texture = sprite.GetTextureForPlayMode();
}
else if (texture != sprite.GetTextureForPlayMode())
{
EditorGUILayout.HelpBox("All Sprites must share the same texture. Either pack all Sprites into one Texture by setting the Packing Tag, or use a Multiple Mode Sprite.", MessageType.Error, true);
break;
}
else if (sprite.border != Vector4.zero)
{
EditorGUILayout.HelpBox("Sprite borders are not supported. They will be ignored.", MessageType.Warning, true);
break;
}
}
}
}
}
} // namespace UnityEditor
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

Releases

No release

Contributors

All

Language(Optional)

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/billwillman/UnityCsReference.git
git@gitee.com:billwillman/UnityCsReference.git
billwillman
UnityCsReference
UnityCsReference
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /